Class: Coinbase::Wallet::AsyncClient

Inherits:
EMHTTPClient show all
Defined in:
lib/coinbase/wallet/client.rb

Constant Summary

Constants inherited from APIClient

Coinbase::Wallet::APIClient::CALLBACK_DIGEST

Instance Method Summary collapse

Methods inherited from APIClient

#account, #accounts, #address, #address_transactions, #addresses, #auth_info, #buy, #buy_price, callback_signing_public_key, #callback_signing_public_key, #cancel_request, #checkout, #checkout_orders, #checkouts, #commit_buy, #commit_deposit, #commit_sell, #commit_withdrawal, #complete_request, #create_account, #create_address, #create_checkout, #create_checkout_order, #create_order, #currencies, #current_user, #delete, #delete_account, #deposit, #exchange_rates, #get, #historic_prices, #list_buy, #list_buys, #list_deposit, #list_deposits, #list_sell, #list_sells, #list_withdrawal, #list_withdrawals, #merchant, #notification, #notifications, #order, #orders, #payment_method, #payment_methods, #post, #primary_account, #put, #refund_order, #request, #resend_request, #sell, #sell_price, #send, #set_primary_account, #spot_price, #time, #transaction, #transactions, #transfer, #update_account, #update_current_user, #user, verify_callback, #verify_callback, whitelisted_certificates, #withdraw

Constructor Details

#initialize(options = {}) ⇒ AsyncClient

Returns a new instance of AsyncClient.



80
81
82
83
84
85
86
87
# File 'lib/coinbase/wallet/client.rb', line 80

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)
end

Instance Method Details

#auth_headers(method, path, body) ⇒ Object



89
90
91
92
93
94
95
96
97
98
# File 'lib/coinbase/wallet/client.rb', line 89

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