Class: Blockchain0x::Client
- Inherits:
-
Object
- Object
- Blockchain0x::Client
- Defined in:
- lib/blockchain0x/client.rb
Constant Summary collapse
- DEFAULT_BASE_URL =
'https://api.blockchain0x.com'- DEFAULT_TIMEOUT =
30- DEFAULT_MAX_RETRIES =
3- USER_AGENT =
"blockchain0x-ruby/#{VERSION}"
Instance Method Summary collapse
- #api_keys ⇒ Object
- #delete(path, idempotency_key: nil) ⇒ Object
-
#get(path, params: nil) ⇒ Object
—- low-level verb helpers ————————————–.
-
#initialize(api_key:, base_url: DEFAULT_BASE_URL, network: nil, timeout: DEFAULT_TIMEOUT, max_retries: DEFAULT_MAX_RETRIES, adapter: :net_http, connection: nil) ⇒ Client
constructor
A new instance of Client.
- #patch(path, body: nil, idempotency_key: nil) ⇒ Object
- #payment_requests ⇒ Object
- #payments ⇒ Object
- #post(path, body: nil, idempotency_key: nil) ⇒ Object
- #transactions ⇒ Object
Constructor Details
#initialize(api_key:, base_url: DEFAULT_BASE_URL, network: nil, timeout: DEFAULT_TIMEOUT, max_retries: DEFAULT_MAX_RETRIES, adapter: :net_http, connection: nil) ⇒ Client
Returns a new instance of Client.
40 41 42 43 44 45 46 47 48 |
# File 'lib/blockchain0x/client.rb', line 40 def initialize(api_key:, base_url: DEFAULT_BASE_URL, network: nil, timeout: DEFAULT_TIMEOUT, max_retries: DEFAULT_MAX_RETRIES, adapter: :net_http, connection: nil) raise ArgumentError, 'api_key is required' if api_key.nil? || api_key.empty? @api_key = api_key @network = (network || network_from_key(api_key)).to_s @max_retries = max_retries @connection = connection || build_connection(base_url, timeout, adapter) end |
Instance Method Details
#api_keys ⇒ Object
50 51 52 53 54 55 |
# File 'lib/blockchain0x/client.rb', line 50 def api_keys @api_keys ||= begin require_relative 'resources/api_keys' Resources::APIKeys.new(self) end end |
#delete(path, idempotency_key: nil) ⇒ Object
91 92 93 |
# File 'lib/blockchain0x/client.rb', line 91 def delete(path, idempotency_key: nil) request(:delete, path, idempotency_key: idempotency_key) end |
#get(path, params: nil) ⇒ Object
—- low-level verb helpers ————————————–
79 80 81 |
# File 'lib/blockchain0x/client.rb', line 79 def get(path, params: nil) request(:get, path, params: params) end |
#patch(path, body: nil, idempotency_key: nil) ⇒ Object
87 88 89 |
# File 'lib/blockchain0x/client.rb', line 87 def patch(path, body: nil, idempotency_key: nil) request(:patch, path, body: body, idempotency_key: idempotency_key) end |
#payment_requests ⇒ Object
57 58 59 60 61 62 |
# File 'lib/blockchain0x/client.rb', line 57 def payment_requests @payment_requests ||= begin require_relative 'resources/payment_requests' Resources::PaymentRequests.new(self) end end |
#payments ⇒ Object
64 65 66 67 68 69 |
# File 'lib/blockchain0x/client.rb', line 64 def payments @payments ||= begin require_relative 'resources/payments' Resources::Payments.new(self) end end |
#post(path, body: nil, idempotency_key: nil) ⇒ Object
83 84 85 |
# File 'lib/blockchain0x/client.rb', line 83 def post(path, body: nil, idempotency_key: nil) request(:post, path, body: body, idempotency_key: idempotency_key) end |
#transactions ⇒ Object
71 72 73 74 75 76 |
# File 'lib/blockchain0x/client.rb', line 71 def transactions @transactions ||= begin require_relative 'resources/transactions' Resources::Transactions.new(self) end end |