Module: Kucoin::Rest::Authentication
- Included in:
- Client
- Defined in:
- lib/kucoin/rest/authentication.rb
Instance Method Summary collapse
- #authenticate!(path, params) ⇒ Object
- #compose_params(params) ⇒ Object
- #nonce ⇒ Object
- #sign_message(path, params = nil) ⇒ Object
Instance Method Details
#authenticate!(path, params) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/kucoin/rest/authentication.rb', line 5 def authenticate!(path, params) data = (path, params) { 'KC-API-KEY' => self.configuration.key, 'KC-API-NONCE' => data[:nonce], 'KC-API-SIGNATURE' => data[:signature], } end |
#compose_params(params) ⇒ Object
29 30 31 32 33 34 |
# 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 ⇒ Object
15 16 17 |
# 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) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/kucoin/rest/authentication.rb', line 19 def (path, params = nil) path = signature_path(path) nonced = nonce params = compose_params(params) = "#{path}/#{nonced}/#{params}" signature = ::Kucoin::Utilities::Encoding.sign(, secret: self.configuration.secret) return {nonce: nonced, signature: signature} end |