Class: Kucoin::Api::REST
- Inherits:
-
Object
- Object
- Kucoin::Api::REST
- Extended by:
- Endpoints
- Defined in:
- lib/kucoin/api/rest.rb,
lib/kucoin/api/rest/connection.rb
Defined Under Namespace
Classes: Connection
Constant Summary collapse
- BASE_URL =
'https://openapi-v2.kucoin.com'.freeze
- SANDBOX_BASE_URL =
'https://openapi-sandbox.kucoin.com'.freeze
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#api_passphrase ⇒ Object
readonly
Returns the value of attribute api_passphrase.
-
#api_secret ⇒ Object
readonly
Returns the value of attribute api_secret.
Instance Method Summary collapse
- #auth(endpoint) ⇒ Object
- #base_url ⇒ Object
-
#initialize(api_key: Kucoin::Api.default_key, api_secret: Kucoin::Api.default_secret, api_passphrase: Kucoin::Api.default_passphrase, adapter: Faraday.default_adapter, sandbox: false) ⇒ REST
constructor
A new instance of REST.
- #open(endpoint) ⇒ Object
- #sandbox? ⇒ Boolean
Methods included from Endpoints
endpoint_method, generate_endpoint_methods, get_klass
Constructor Details
#initialize(api_key: Kucoin::Api.default_key, api_secret: Kucoin::Api.default_secret, api_passphrase: Kucoin::Api.default_passphrase, adapter: Faraday.default_adapter, sandbox: false) ⇒ REST
Returns a new instance of REST.
14 15 16 17 18 19 20 |
# File 'lib/kucoin/api/rest.rb', line 14 def initialize api_key: Kucoin::Api.default_key, api_secret: Kucoin::Api.default_secret, api_passphrase: Kucoin::Api.default_passphrase, adapter: Faraday.default_adapter, sandbox: false @api_key = api_key @api_secret = api_secret @api_passphrase = api_passphrase @adapter = adapter @sandbox = sandbox end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
12 13 14 |
# File 'lib/kucoin/api/rest.rb', line 12 def adapter @adapter end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
11 12 13 |
# File 'lib/kucoin/api/rest.rb', line 11 def api_key @api_key end |
#api_passphrase ⇒ Object (readonly)
Returns the value of attribute api_passphrase.
11 12 13 |
# File 'lib/kucoin/api/rest.rb', line 11 def api_passphrase @api_passphrase end |
#api_secret ⇒ Object (readonly)
Returns the value of attribute api_secret.
11 12 13 |
# File 'lib/kucoin/api/rest.rb', line 11 def api_secret @api_secret end |
Instance Method Details
#auth(endpoint) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/kucoin/api/rest.rb', line 35 def auth endpoint Connection.new(endpoint, url: base_url) do |conn| conn.request :json conn.response :json, content_type: 'application/json' conn.use Kucoin::Api::Middleware::NonceRequest conn.use Kucoin::Api::Middleware::AuthRequest, api_key, api_secret, api_passphrase conn.adapter adapter end end |
#base_url ⇒ Object
23 24 25 |
# File 'lib/kucoin/api/rest.rb', line 23 def base_url sandbox? ? SANDBOX_BASE_URL : BASE_URL end |
#open(endpoint) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/kucoin/api/rest.rb', line 27 def open endpoint Connection.new(endpoint, url: base_url) do |conn| conn.request :json conn.response :json, content_type: 'application/json' conn.adapter adapter end end |
#sandbox? ⇒ Boolean
21 |
# File 'lib/kucoin/api/rest.rb', line 21 def sandbox?; @sandbox == true end |