Skip to content

Instantly share code, notes, and snippets.

@shivpkumar
Created March 3, 2015 21:08
Show Gist options
  • Select an option

  • Save shivpkumar/034eb48bff3485a109ba to your computer and use it in GitHub Desktop.

Select an option

Save shivpkumar/034eb48bff3485a109ba to your computer and use it in GitHub Desktop.

Revisions

  1. shivpkumar created this gist Mar 3, 2015.
    20 changes: 20 additions & 0 deletions bringg.rb
    Original 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