module Kucoin::Rest::Authentication

Public Instance Methods

authenticate!(path, params) click to toggle source
# File lib/kucoin/rest/authentication.rb, line 5
def authenticate!(path, params)
  data              =   sign_message(path, params)
  
  {
    'KC-API-KEY'        =>  self.configuration.key,
    'KC-API-NONCE'      =>  data[:nonce],
    'KC-API-SIGNATURE'  =>  data[:signature],
  }
end
compose_params(params) click to toggle source
# File lib/kucoin/rest/authentication.rb, line 29
def compose_params(params)
  return params unless params.is_a? Hash
  uri               =   Addressable::URI.new
  uri.query_values  =   params
  uri.query
end
nonce() click to toggle source
# File lib/kucoin/rest/authentication.rb, line 15
def nonce
  (Time.now.to_f * 1000).to_i.to_s
end
sign_message(path, params = nil) click to toggle source
# File lib/kucoin/rest/authentication.rb, line 19
def sign_message(path, params = nil)
  path              =   signature_path(path)
  nonced            =   nonce
  params            =   compose_params(params)
  message           =   "#{path}/#{nonced}/#{params}"
  signature         =   ::Kucoin::Utilities::Encoding.sign(message, secret: self.configuration.secret)
  
  return {nonce: nonced, signature: signature}
end