Class: Cryptoprocessing::Client
- Inherits:
-
Object
- Object
- Cryptoprocessing::Client
- Includes:
- Authentication, Accounts, Addresses, Callbacks, CoinbaseWallet, Trackers, Transactions, Configurable, Connection
- Defined in:
- lib/cryptoprocessing/client.rb,
lib/cryptoprocessing/client/accounts.rb,
lib/cryptoprocessing/client/trackers.rb,
lib/cryptoprocessing/client/addresses.rb,
lib/cryptoprocessing/client/callbacks.rb,
lib/cryptoprocessing/client/transactions.rb,
lib/cryptoprocessing/client/coinbase_wallet.rb
Overview
Cryptoprocessing API client masks default currency with BTC. But default currency can be simply overridden with blockchain_type property.
Defined Under Namespace
Modules: Accounts, Addresses, Callbacks, CoinbaseWallet, Trackers, Transactions
Constant Summary
Constants included from Transactions
Transactions::TRANSACTION_FEE_FASTEST, Transactions::TRANSACTION_FEE_HALF_HOUR, Transactions::TRANSACTION_FEE_HOUR, Transactions::TRANSACTION_SEND_TYPE, Transactions::TRANSACTION_SEND_TYPE_RAW
Instance Attribute Summary collapse
-
#logger ⇒ Logger
The logger.
Attributes included from Configurable
#access_token, #api_endpoint, #api_namespace, #blockchain_type, #email, #password, #user_agent
Class Method Summary collapse
-
.default_logger ⇒ Logger
Create and configure a logger.
-
.logger ⇒ Logger
The logger.
-
.rails_logger ⇒ Logger
Check to see if client is being used in a Rails environment and get the logger if present.
Instance Method Summary collapse
-
#access_token=(value) ⇒ Object
Set access token for authentication.
-
#email=(value) ⇒ Object
Set username for authentication.
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#inspect ⇒ String
Text representation of the client, masking tokens and passwords.
-
#password=(value) ⇒ Object
Set password for authentication.
Methods included from CoinbaseWallet
#accounts, #address_transactions, #primary_account
Methods included from Transactions
#create_transaction, #send_raw_transaction, #transactions, #transactions_by_address
Methods included from Trackers
Methods included from Addresses
#address, #addresses, #create_address
Methods included from Callbacks
Methods included from Accounts
Methods included from Connection
#agent, #auth_headers, #delete, #endpoint, #get, #post, #put, #request, #reset_agent
Methods included from Configurable
#configure, keys, #netrc?, #reset!, #same_options?
Methods included from Authentication
#login, #login_from_netrc, #register, #token_authenticated?
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
29 30 31 32 33 34 35 36 |
# File 'lib/cryptoprocessing/client.rb', line 29 def initialize( = {}) # Use options passed in, but fall back to module defaults Cryptoprocessing::Configurable.keys.each do |key| instance_variable_set(:"@#{key}", [key] || Cryptoprocessing.instance_variable_get(:"@#{key}")) end # login_from_netrc unless user_authenticated? || application_authenticated? end |
Instance Attribute Details
#logger ⇒ Logger
Returns The logger.
56 57 58 |
# File 'lib/cryptoprocessing/client.rb', line 56 def self.logger @logger ||= rails_logger || default_logger end |
Class Method Details
.default_logger ⇒ Logger
Create and configure a logger
62 63 64 65 66 |
# File 'lib/cryptoprocessing/client.rb', line 62 def self.default_logger logger = Logger.new($stdout) logger.level = Logger::WARN logger end |
.logger ⇒ Logger
Returns The logger.
56 57 58 |
# File 'lib/cryptoprocessing/client.rb', line 56 def self.logger @logger ||= rails_logger || default_logger end |
.rails_logger ⇒ Logger
Check to see if client is being used in a Rails environment and get the logger if present. Setting the ENV variable 'GOOGLE_API_USE_RAILS_LOGGER' to false will force the client to use its own logger.
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/cryptoprocessing/client.rb', line 73 def self.rails_logger if 'true' == ENV.fetch('CRYPTOPROCESSING_USE_RAILS_LOGGER', 'true') && defined?(::Rails) && ::Rails.respond_to?(:logger) && !::Rails.logger.nil? ::Rails.logger else nil end end |
Instance Method Details
#access_token=(value) ⇒ Object
Set access token for authentication
103 104 105 106 |
# File 'lib/cryptoprocessing/client.rb', line 103 def access_token=(value) reset_agent @access_token = value end |
#email=(value) ⇒ Object
Set username for authentication
87 88 89 90 |
# File 'lib/cryptoprocessing/client.rb', line 87 def email=(value) reset_agent @email = value end |
#inspect ⇒ String
Text representation of the client, masking tokens and passwords
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/cryptoprocessing/client.rb', line 41 def inspect inspected = super # mask password inspected = inspected.gsub! @password, "*******" if @password # Only show last 4 of token, secret if @access_token inspected = inspected.gsub! @access_token, "#{'*'*36}#{@access_token[36..-1]}" end inspected end |
#password=(value) ⇒ Object
Set password for authentication
95 96 97 98 |
# File 'lib/cryptoprocessing/client.rb', line 95 def password=(value) reset_agent @password = value end |