class Coinbase::Wallet::Client

Public Class Methods

new(options={}) click to toggle source
Calls superclass method Coinbase::Wallet::NetHTTPClient::new
# File lib/coinbase/wallet/client.rb, line 7
def initialize(options={})
  [ :api_key, :api_secret ].each do |opt|
    raise unless options.has_key? opt
  end
  @api_key = options[:api_key]
  @api_secret = options[:api_secret]
  @api_uri = URI.parse(options[:api_url] || BASE_API_URL)
  super(@api_uri, options)
end

Public Instance Methods

auth_headers(method, path, body) click to toggle source
# File lib/coinbase/wallet/client.rb, line 17
def auth_headers(method, path, body)
  ts = Time.now.to_i.to_s
  signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'),
                                      @api_secret,
                                      ts + method + path + body.to_s)
  { 'CB-ACCESS-KEY' => @api_key,
    'CB-ACCESS-SIGN' => signature,
    'CB-ACCESS-TIMESTAMP' => ts,
    'CB-VERSION' => API_VERSION }
end