Class: Bittrex::Request
- Inherits:
-
Object
- Object
- Bittrex::Request
- Defined in:
- lib/request.rb
Constant Summary collapse
- BASE_URL =
'https://bittrex.com/api/v1.1'
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#api_secret ⇒ Object
readonly
Returns the value of attribute api_secret.
Instance Method Summary collapse
- #get(path, params = '') ⇒ Object
-
#initialize(api_key, api_secret) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(api_key, api_secret) ⇒ Request
Returns a new instance of Request.
6 7 8 9 |
# File 'lib/request.rb', line 6 def initialize(api_key, api_secret) @api_key = api_key @api_secret = api_secret end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
4 5 6 |
# File 'lib/request.rb', line 4 def api_key @api_key end |
#api_secret ⇒ Object (readonly)
Returns the value of attribute api_secret.
4 5 6 |
# File 'lib/request.rb', line 4 def api_secret @api_secret end |
Instance Method Details
#get(path, params = '') ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/request.rb', line 11 def get(path, params = '') begin nonce = Time.now.to_i final_url = "#{BASE_URL}#{path}?apikey=#{api_key}&nonce=#{nonce}&"+params hmac_sign = generate_sign(final_url) response = HTTParty.get(final_url, headers: { apisign: hmac_sign }) handle_response response.body rescue Exception => e nil end end |