Module: GettyUp::API::Util
- Included in:
- CreateDownloadRequest, CreateSession, GetImageDetails, GetLargestImageDownloadAuthorization, RenewSession, SearchForImages
- Defined in:
- lib/getty_up/api/util.rb
Instance Method Summary collapse
Instance Method Details
#post_json(request, endpoint, debug = false) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/getty_up/api/util.rb', line 4 def post_json(request, endpoint, debug = false) if debug puts '--- Request to Getty --' puts request end #You may wish to replace this code with your preferred library for posting and receiving JSON data. uri = URI.parse(endpoint) http = Net::HTTP.new(uri.host, 443) http.use_ssl = true response = http.post(uri.path, request.to_json, {'Content-Type' =>'application/json'}).body if debug puts '--- Response from Getty --' puts response end JSON.parse(response) end |