Class: CoinbaseExchangeSignatureMaker
- Inherits:
-
Object
- Object
- CoinbaseExchangeSignatureMaker
- Defined in:
- lib/coinbase_exchange.rb
Instance Method Summary collapse
-
#initialize(key, secret, passphrase) ⇒ CoinbaseExchangeSignatureMaker
constructor
A new instance of CoinbaseExchangeSignatureMaker.
- #signature(request_url = '', body = '', timestamp = nil, method = 'GET') ⇒ Object
Constructor Details
#initialize(key, secret, passphrase) ⇒ CoinbaseExchangeSignatureMaker
Returns a new instance of CoinbaseExchangeSignatureMaker.
7 8 9 10 11 |
# File 'lib/coinbase_exchange.rb', line 7 def initialize(key, secret, passphrase) @key = key @secret = secret @passphrase = passphrase end |
Instance Method Details
#signature(request_url = '', body = '', timestamp = nil, method = 'GET') ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/coinbase_exchange.rb', line 13 def signature(request_url='', body='', =nil, method='GET') body = body.to_json if body.is_a?(Hash) = Time.now.to_i if ! what = "#{}#{method.upcase}#{request_url}#{body}"; # create a sha256 hmac with the secret secret = Base64.decode64(@secret) hash = OpenSSL::HMAC.digest('sha256', secret, what) Base64.strict_encode64(hash) end |