Class: Wazirx::Client::REST::TimestampRequestMiddleware
- Inherits:
-
Struct
- Object
- Struct
- Wazirx::Client::REST::TimestampRequestMiddleware
- Defined in:
- lib/wazirx/client/rest/timestamp_request_middleware.rb
Overview
Generate a timestamp in milliseconds and append to query string
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
Instance Method Summary collapse
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app
7 8 9 |
# File 'lib/wazirx/client/rest/timestamp_request_middleware.rb', line 7 def app @app end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/wazirx/client/rest/timestamp_request_middleware.rb', line 8 def call(env) key = 'timestamp' value = DateTime.now.strftime('%Q') if env.method == :get env.url.query = REST.add_query_param( env.url.query, key, value ) else body = REST.sort_body env.body, key, value env.body = JSON.generate(body) end app.call env end |