Class: Binance::Client::REST_FUTURE::TimestampRequestMiddleware

Inherits:
Struct
  • Object
show all
Defined in:
lib/binance/client/rest/timestamp_request_middleware.rb

Overview

Generate a timestamp in milliseconds and append to query string

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#appObject

Returns the value of attribute app

Returns:

  • (Object)

    the current value of app



21
22
23
# File 'lib/binance/client/rest/timestamp_request_middleware.rb', line 21

def app
  @app
end

Instance Method Details

#call(env) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/binance/client/rest/timestamp_request_middleware.rb', line 22

def call(env)
					date = DateTime.now
		            date = Time.at(date.to_time.to_f-$diff).to_datetime if !$diff.nil?
    env.url.query = REST_FUTURE.add_query_param(
       env.url.query, 'timestamp', date.strftime('%Q')
    )
    app.call env
end