Class: Coinbase::Configuration
- Inherits:
-
Object
- Object
- Coinbase::Configuration
- Defined in:
- lib/coinbase.rb
Overview
Configuration object for the Coinbase SDK.
Instance Attribute Summary collapse
-
#api_key_name ⇒ Object
Returns the value of attribute api_key_name.
-
#api_key_private_key ⇒ Object
Returns the value of attribute api_key_private_key.
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#debug_api ⇒ Object
Returns the value of attribute debug_api.
-
#default_network ⇒ Object
Returns the value of attribute default_network.
-
#max_network_tries ⇒ Object
Returns the value of attribute max_network_tries.
-
#use_server_signer ⇒ Object
Returns the value of attribute use_server_signer.
Instance Method Summary collapse
-
#api_client ⇒ Coinbase::Client::ApiClient
Returns the API client.
-
#from_json(file_path = 'cdp_api_key.json') ⇒ Object
Sets configuration values based on the provided CDP API Key JSON file.
-
#initialize ⇒ Configuration
constructor
Initializes the configuration object.
Constructor Details
#initialize ⇒ Configuration
Initializes the configuration object.
82 83 84 85 86 87 88 |
# File 'lib/coinbase.rb', line 82 def initialize @api_url = 'https://api.cdp.coinbase.com' @debug_api = false @use_server_signer = false @max_network_tries = 3 @default_network = Coinbase::Network::BASE_SEPOLIA end |
Instance Attribute Details
#api_key_name ⇒ Object
Returns the value of attribute api_key_name.
79 80 81 |
# File 'lib/coinbase.rb', line 79 def api_key_name @api_key_name end |
#api_key_private_key ⇒ Object
Returns the value of attribute api_key_private_key.
79 80 81 |
# File 'lib/coinbase.rb', line 79 def api_key_private_key @api_key_private_key end |
#api_url ⇒ Object
Returns the value of attribute api_url.
79 80 81 |
# File 'lib/coinbase.rb', line 79 def api_url @api_url end |
#debug_api ⇒ Object
Returns the value of attribute debug_api.
79 80 81 |
# File 'lib/coinbase.rb', line 79 def debug_api @debug_api end |
#default_network ⇒ Object
Returns the value of attribute default_network.
90 91 92 |
# File 'lib/coinbase.rb', line 90 def default_network @default_network end |
#max_network_tries ⇒ Object
Returns the value of attribute max_network_tries.
79 80 81 |
# File 'lib/coinbase.rb', line 79 def max_network_tries @max_network_tries end |
#use_server_signer ⇒ Object
Returns the value of attribute use_server_signer.
79 80 81 |
# File 'lib/coinbase.rb', line 79 def use_server_signer @use_server_signer end |
Instance Method Details
#api_client ⇒ Coinbase::Client::ApiClient
Returns the API client.
117 118 119 |
# File 'lib/coinbase.rb', line 117 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.
103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/coinbase.rb', line 103 def from_json(file_path = 'cdp_api_key.json') # Expand paths to respect shortcuts like ~. file_path = File.(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 |