Class: Coinbase::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/coinbase.rb

Overview

Configuration object for the Coinbase SDK.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Initializes the configuration object.



61
62
63
64
65
# File 'lib/coinbase.rb', line 61

def initialize
  @api_url = 'https://api.cdp.coinbase.com'
  @debug_api = false
  @use_server_signer = false
end

Instance Attribute Details

#api_key_nameObject

Returns the value of attribute api_key_name.



58
59
60
# File 'lib/coinbase.rb', line 58

def api_key_name
  @api_key_name
end

#api_key_private_keyObject

Returns the value of attribute api_key_private_key.



58
59
60
# File 'lib/coinbase.rb', line 58

def api_key_private_key
  @api_key_private_key
end

#api_urlObject

Returns the value of attribute api_url.



58
59
60
# File 'lib/coinbase.rb', line 58

def api_url
  @api_url
end

#debug_apiObject

Returns the value of attribute debug_api.



58
59
60
# File 'lib/coinbase.rb', line 58

def debug_api
  @debug_api
end

#use_server_signerObject

Returns the value of attribute use_server_signer.



58
59
60
# File 'lib/coinbase.rb', line 58

def use_server_signer
  @use_server_signer
end

Instance Method Details

#api_clientCoinbase::Client::ApiClient

Returns the API client.

Returns:



84
85
86
# File 'lib/coinbase.rb', line 84

def api_client
  @api_client ||= Coinbase::Client::ApiClient.new(Middleware.config)
end

#from_json(file_path = 'cdp_api_key.json') ⇒ Object

Sets configuration values based on the provided CDP API Key JSON file. file in the root directory by default.

Parameters:

  • file_path (String) (defaults to: 'cdp_api_key.json')

    (Optional) the path to the CDP API Key JSON file

Raises:



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/coinbase.rb', line 70

def from_json(file_path = 'cdp_api_key.json')
  # Expand paths to respect shortcuts like ~.
  file_path = File.expand_path(file_path)

  raise InvalidConfiguration, 'Invalid configuration file type' unless file_path.end_with?('.json')

  file = File.read(file_path)
  data = JSON.parse(file)
  @api_key_name = data['name']
  @api_key_private_key = data['privateKey']
end