Created
September 7, 2013 15:17
-
-
Save ehelms/6476483 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
args << generate_payload(options) if [:post, :put].include?(method) | |
def generate_payload(options) | |
if options.has_key?(:body) | |
return options[:body] | |
elsif options.has_key?(:payload) | |
return format_payload(options[:payload]) | |
end | |
end | |
def format_payload(payload) | |
if !payload.nil? | |
if payload[:optional] | |
if payload[:required] | |
payload = payload[:required].merge(payload[:optional]) | |
else | |
payload = payload[:optional] | |
end | |
elsif options[:payload][:delta] | |
payload = payload | |
else | |
payload = payload[:required] | |
end | |
else | |
payload = {} | |
end | |
return payload.to_json | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment