Class: Binance::Client::REST::SignRequestMiddleware

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

Overview

Sign the query string using HMAC(sha-256) and appends 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



5
6
7
# File 'lib/binance/client/rest/sign_request_middleware.rb', line 5

def app
  @app
end

#secret_keyObject

Returns the value of attribute secret_key

Returns:

  • (Object)

    the current value of secret_key



5
6
7
# File 'lib/binance/client/rest/sign_request_middleware.rb', line 5

def secret_key
  @secret_key
end

Instance Method Details

#call(env) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/binance/client/rest/sign_request_middleware.rb', line 6

def call(env)
  hash = OpenSSL::HMAC.hexdigest(
    OpenSSL::Digest.new('sha256'), secret_key, env.url.query
  )
  env.url.query = REST.add_query_param(env.url.query, 'signature', hash)

  app.call env
end