Created
March 3, 2015 21:08
-
-
Save shivpkumar/034eb48bff3485a109ba to your computer and use it in GitHub Desktop.
Revisions
-
shivpkumar created this gist
Mar 3, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ module Bringg class Customer def self.create(params) params.merge!(timestamp: Time.now.to_i) params.merge!(access_token: "MY_ACCESS_TOKEN") params = params.sort.to_h query_params = params.to_query params.merge!(signature: OpenSSL::HMAC.hexdigest("sha1", "MY_SECRET_KEY", query_params)) uri = URI("http://api.bringg.com/partner_api/customers") request = Net::HTTP::Post.new(uri, initheader = {'Content-Type' =>'application/json'}) request.body = params.to_json response = Net::HTTP.start(uri.hostname, uri.port) do |http| http.request(request) end end end end