Class: Kortana::Client

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, environment: "mainnet", base_url: nil, timeout: 30, max_retries: 3) ⇒ Client

Returns a new instance of Client.

Raises:



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

#bankingObject (readonly)

Returns the value of attribute banking.



3
4
5
# File 'lib/kortana/client.rb', line 3

def banking
  @banking
end

#blockchainObject (readonly)

Returns the value of attribute blockchain.



3
4
5
# File 'lib/kortana/client.rb', line 3

def blockchain
  @blockchain
end

#cardsObject (readonly)

Returns the value of attribute cards.



3
4
5
# File 'lib/kortana/client.rb', line 3

def cards
  @cards
end

#complianceObject (readonly)

Returns the value of attribute compliance.



3
4
5
# File 'lib/kortana/client.rb', line 3

def compliance
  @compliance
end

#contractsObject (readonly)

Returns the value of attribute contracts.



3
4
5
# File 'lib/kortana/client.rb', line 3

def contracts
  @contracts
end

#merchantsObject (readonly)

Returns the value of attribute merchants.



3
4
5
# File 'lib/kortana/client.rb', line 3

def merchants
  @merchants
end

#paymentsObject (readonly)

Returns the value of attribute payments.



3
4
5
# File 'lib/kortana/client.rb', line 3

def payments
  @payments
end

#settlementObject (readonly)

Returns the value of attribute settlement.



3
4
5
# File 'lib/kortana/client.rb', line 3

def settlement
  @settlement
end

#walletsObject (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