Class: Kortana::Client
- Inherits:
-
Object
- Object
- Kortana::Client
- Defined in:
- lib/kortana/client.rb
Constant Summary collapse
- BASE_URLS =
{ "mainnet" => "https://console.kortana.network/api/v1", "testnet" => "https://console.kortana.network/api/v1" }.freeze
Instance Attribute Summary collapse
-
#banking ⇒ Object
readonly
Returns the value of attribute banking.
-
#blockchain ⇒ Object
readonly
Returns the value of attribute blockchain.
-
#cards ⇒ Object
readonly
Returns the value of attribute cards.
-
#compliance ⇒ Object
readonly
Returns the value of attribute compliance.
-
#contracts ⇒ Object
readonly
Returns the value of attribute contracts.
-
#merchants ⇒ Object
readonly
Returns the value of attribute merchants.
-
#payments ⇒ Object
readonly
Returns the value of attribute payments.
-
#settlement ⇒ Object
readonly
Returns the value of attribute settlement.
-
#wallets ⇒ Object
readonly
Returns the value of attribute wallets.
Instance Method Summary collapse
- #delete(path, headers = {}) ⇒ Object
- #get(path, params = {}, headers = {}) ⇒ Object
-
#initialize(api_key:, environment: "mainnet", base_url: nil, timeout: 30, max_retries: 3) ⇒ Client
constructor
A new instance of Client.
- #post(path, body = nil, headers = {}) ⇒ Object
- #put(path, body = nil, headers = {}) ⇒ Object
Constructor Details
#initialize(api_key:, environment: "mainnet", base_url: nil, timeout: 30, max_retries: 3) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/kortana/client.rb', line 11 def initialize(api_key:, environment: "mainnet", base_url: nil, timeout: 30, max_retries: 3) raise ConfigurationError, "api_key must not be empty" if api_key.nil? || api_key.strip.empty? raise ConfigurationError, "environment must be 'mainnet' or 'testnet'" unless %w[mainnet testnet].include?(environment) @api_key = api_key.strip @environment = environment @base_url = base_url || BASE_URLS[environment] @timeout = timeout @max_retries = max_retries setup_http_client setup_modules end |
Instance Attribute Details
#banking ⇒ Object (readonly)
Returns the value of attribute banking.
3 4 5 |
# File 'lib/kortana/client.rb', line 3 def banking @banking end |
#blockchain ⇒ Object (readonly)
Returns the value of attribute blockchain.
3 4 5 |
# File 'lib/kortana/client.rb', line 3 def blockchain @blockchain end |
#cards ⇒ Object (readonly)
Returns the value of attribute cards.
3 4 5 |
# File 'lib/kortana/client.rb', line 3 def cards @cards end |
#compliance ⇒ Object (readonly)
Returns the value of attribute compliance.
3 4 5 |
# File 'lib/kortana/client.rb', line 3 def compliance @compliance end |
#contracts ⇒ Object (readonly)
Returns the value of attribute contracts.
3 4 5 |
# File 'lib/kortana/client.rb', line 3 def contracts @contracts end |
#merchants ⇒ Object (readonly)
Returns the value of attribute merchants.
3 4 5 |
# File 'lib/kortana/client.rb', line 3 def merchants @merchants end |
#payments ⇒ Object (readonly)
Returns the value of attribute payments.
3 4 5 |
# File 'lib/kortana/client.rb', line 3 def payments @payments end |
#settlement ⇒ Object (readonly)
Returns the value of attribute settlement.
3 4 5 |
# File 'lib/kortana/client.rb', line 3 def settlement @settlement end |
#wallets ⇒ Object (readonly)
Returns the value of attribute wallets.
3 4 5 |
# File 'lib/kortana/client.rb', line 3 def wallets @wallets end |
Instance Method Details
#delete(path, headers = {}) ⇒ Object
37 38 39 |
# File 'lib/kortana/client.rb', line 37 def delete(path, headers = {}) request(:delete, path, nil, nil, headers) end |
#get(path, params = {}, headers = {}) ⇒ Object
25 26 27 |
# File 'lib/kortana/client.rb', line 25 def get(path, params = {}, headers = {}) request(:get, path, params, nil, headers) end |
#post(path, body = nil, headers = {}) ⇒ Object
29 30 31 |
# File 'lib/kortana/client.rb', line 29 def post(path, body = nil, headers = {}) request(:post, path, nil, body, headers) end |
#put(path, body = nil, headers = {}) ⇒ Object
33 34 35 |
# File 'lib/kortana/client.rb', line 33 def put(path, body = nil, headers = {}) request(:put, path, nil, body, headers) end |