require 'multi_json' module GettyConnect module Request def delete(path, options={}, use_ssl=false) request(:delete, path, options, use_ssl) end def get(path, options={}, use_ssl=false) request(:get, path, options, use_ssl) end def patch(path, options={}, use_ssl=false) request(:patch, path, options, use_ssl) end def post(path, options={}, use_ssl=false) request(:post, path, options, use_ssl) end def put(path, options={}, use_ssl=false) request(:put, path, options, use_ssl) end private def request(method, path, options, use_ssl) response = connection(use_ssl).send(method) do |request| case method when :delete, :get request.url(path, options) when :patch, :post, :put request.path = path request.body = MultiJson.dump(options) unless options.empty? else request.body = options unless options.empty? end end response.body end end end