Skip to content

Instantly share code, notes, and snippets.

@daviddavis
Forked from ehelms/gist:6476483
Last active December 22, 2015 12:59
Show Gist options
  • Save daviddavis/6476530 to your computer and use it in GitHub Desktop.
Save daviddavis/6476530 to your computer and use it in GitHub Desktop.
args << generate_payload(options) if [:post, :put].include?(method)
def generate_payload(options)
if options[:payload].is_a?(String)
return options[:payload]
elsif options[:payload].is_a?(Hash)
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
@daviddavis
Copy link
Author

The method upload_bits would thus call:

call(:put, path("#{upload_id}/#{offset}/"), :payload => content)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment