Class: Bitbot::Trader::Providers::MtGox::HttpClient::HmacMiddleware
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Bitbot::Trader::Providers::MtGox::HttpClient::HmacMiddleware
- Defined in:
- lib/bitbot/trader/providers/mt_gox/http_client/hmac_middleware.rb
Overview
Signs request with hmac signature
Instance Attribute Summary collapse
-
#key ⇒ String
readonly
private
API key.
-
#secret ⇒ String
readonly
private
API secret.
Class Method Summary collapse
-
.extract_params(env) ⇒ Array
private
Extracts headers, path and body.
Instance Method Summary collapse
-
#call(env) ⇒ Object
private
Adds signature to current request.
-
#initialize(app, options) ⇒ undefined
constructor
private
Initializes HmacMiddleware.
Constructor Details
#initialize(app, options) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes HmacMiddleware
56 57 58 59 60 |
# File 'lib/bitbot/trader/providers/mt_gox/http_client/hmac_middleware.rb', line 56 def initialize(app, ) super(app) @key = .fetch(:key) @secret = .fetch(:secret) end |
Instance Attribute Details
#key ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
API key
37 38 39 |
# File 'lib/bitbot/trader/providers/mt_gox/http_client/hmac_middleware.rb', line 37 def key @key end |
#secret ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
API secret
45 46 47 |
# File 'lib/bitbot/trader/providers/mt_gox/http_client/hmac_middleware.rb', line 45 def secret @secret end |
Class Method Details
.extract_params(env) ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extracts headers, path and body
23 24 25 26 27 28 29 |
# File 'lib/bitbot/trader/providers/mt_gox/http_client/hmac_middleware.rb', line 23 def self.extract_params(env) headers = env[:request_headers] path = env[:url].to_s.split("/2/").last body = env[:body] [headers, path, body] end |
Instance Method Details
#call(env) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Adds signature to current request
70 71 72 73 74 |
# File 'lib/bitbot/trader/providers/mt_gox/http_client/hmac_middleware.rb', line 70 def call(env) headers, path, body = self.class.extract_params(env) prepare_headers(headers, path, body) @app.call(env) end |