Class: Binance::Client::REST::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



7
8
9
# File 'lib/binance/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
# File 'lib/binance/client/rest/timestamp_request_middleware.rb', line 8

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