class Cwallet::Wallet::Client

Public Class Methods

new(options={}) click to toggle source
Calls superclass method Cwallet::Wallet::NetHTTPClient::new
# File lib/cwallet/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]
  @debug = options[:debug] || false
  @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/cwallet/wallet/client.rb, line 18
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
debug() click to toggle source
# File lib/cwallet/wallet/client.rb, line 29
def debug
  !!@debug
end