class Tapbot::Client

Public Instance Methods

auth_headers(url, body="") click to toggle source
# File lib/tapbot/client.rb, line 11
def auth_headers(url, body="")
    ts = Time.now.to_i.to_s
    if rest_secret && rest_token && url
      signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'),
                                          rest_secret,
                                          rest_token + ts + (Tapbot::Configuration::BASE_URI + url) + body.to_s)
          
                                        
      { 
        "Content-Type" => "application/json", 
        "Accept" => "application/json",
        "User-Agent" => Tapbot::Configuration::USER_AGENT,
        'TP-REST-TOKEN' => rest_token,
        'TP-ACCESS-SIGNATURE' => signature,
        'TP-ACCESS-TIMESTAMP' => ts,
        'TP-API-VERSION' => Tapbot::Configuration::API_VERSION }
    else
      raise Tapbot::Error, "Invalid credentials"
    end
end