lib/gopay/client.rb in gopay-ruby-0.4.0.alpha vs lib/gopay/client.rb in gopay-ruby-0.4.1

- old
+ new

@@ -7,13 +7,11 @@ end def request(method, path, body_parameters: {}) token = token get_token_scope(method, path) content_type = get_content_type(path) - - body_parameters = content_type == 'application/json' ? body_parameters.to_json : from_hash_to_query(body_parameters) - + body_parameters = content_type == 'application/json' ? body_parameters.to_json : body_parameters begin response = RestClient::Request.execute(method: method, url: @config[:gate]+path, payload: body_parameters, headers: { "Accept" => "application/json", "Content-Type" => content_type, "Authorization" => "Bearer #{token}" }) rescue RestClient::ExceptionWithResponse => e raise Error.handle_gopay_error(e.response) end @@ -56,12 +54,8 @@ "Content-Type" => "application/x-www-form-urlencoded", "Authorization" => "Basic #{Base64.encode64(@config[:client_id] + ':' + @config[:client_secret])}" }) JSON.parse(response.body)["access_token"] end - - def from_hash_to_query(hash) - hash = hash == "{}" ? "{}" : URI.escape(hash.collect { |key,val| "#{CGI.escape(key.to_s)}=#{CGI.escape(val.to_s)}" }.join('&')) - return hash - end + end -end \ No newline at end of file +end