Class: RuBittrex::Client
- Inherits:
-
Object
- Object
- RuBittrex::Client
- Includes:
- ClientApi
- Defined in:
- lib/ru_bittrex/client.rb
Constant Summary collapse
- API_URI =
'https://api.bittrex.com/v3'
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#secret ⇒ Object
readonly
Returns the value of attribute secret.
Instance Method Summary collapse
- #get(path, params = {}) ⇒ Object
-
#initialize(opts = {}) ⇒ Client
constructor
A new instance of Client.
Methods included from ClientApi
#account, #account_volume, #address, #addresses, #balance, #balances, #closed_deposits, #currencies, #currency, #deposit, #market, #markets, #open_deposits, #summaries, #summary, #ticker, #tickers
Constructor Details
#initialize(opts = {}) ⇒ Client
Returns a new instance of Client.
15 16 17 18 19 20 |
# File 'lib/ru_bittrex/client.rb', line 15 def initialize(opts = {}) raise AuthError.new('You must provide API key and Secret') unless opts[:secret] && opts[:api_key] @secret = opts[:secret] @api_key = opts[:api_key] end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
13 14 15 |
# File 'lib/ru_bittrex/client.rb', line 13 def api_key @api_key end |
#secret ⇒ Object (readonly)
Returns the value of attribute secret.
13 14 15 |
# File 'lib/ru_bittrex/client.rb', line 13 def secret @secret end |
Instance Method Details
#get(path, params = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ru_bittrex/client.rb', line 22 def get(path, params = {}) uri = encode_uri(path, params) = nonce content_hash = digest presign = .to_s + uri + 'GET' + content_hash resp = Faraday.get(uri) do |req| req.params = params # req.params['limit'] = 100 req.headers['Api-Key'] = @api_key req.headers['Api-Timestamp'] = .to_s req.headers['Api-Content-Hash'] = content_hash req.headers['Api-Signature'] = sign(presign) req.headers['Content-Type'] = 'application/json' # req.body = body.to_json end JSON.parse(resp.body) end |