Class: CoinbaseCustody::Client
- Inherits:
-
Object
- Object
- CoinbaseCustody::Client
show all
- Includes:
- Util
- Defined in:
- lib/coinbase_custody/client.rb
Overview
Constant Summary
Constants included
from Util
Util::BASE_API_URL
Instance Method Summary
collapse
Methods included from Util
#format_response, #pagination_params, #send_request
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
10
11
12
13
14
15
16
17
|
# File 'lib/coinbase_custody/client.rb', line 10
def initialize
@url = COINBASE_CUSTODY_CONFIG[:url]
@access_key = COINBASE_CUSTODY_CONFIG[:api_access_key]
@passphrase = COINBASE_CUSTODY_CONFIG[:passphrase]
[@url, @access_key, @passphrase].each do |opt|
raise 'Missing coinbase custody credentials' if opt.blank?
end
end
|
Instance Method Details
#get(path, params = {}) ⇒ Object
33
34
35
36
37
|
# File 'lib/coinbase_custody/client.rb', line 33
def get(path, params = {})
http_request(request_params: params) do |request_params|
HTTParty.get("#{@url}#{path}", request_params)
end
end
|
19
20
21
22
23
24
25
|
# File 'lib/coinbase_custody/client.rb', line 19
def
{
'Content-Type' => 'application/json',
'Cb-Access-Key' => @access_key,
'Cb-Access-Passphrase' => @passphrase
}
end
|
#http_request(request_params: {}, body: nil) {|request_params| ... } ⇒ Object
27
28
29
30
31
|
# File 'lib/coinbase_custody/client.rb', line 27
def http_request(request_params: {}, body: nil)
request_params.merge!(headers: )
request_params.merge!(body: body.to_json) if body.present?
yield(request_params) if block_given?
end
|
#post(path, body: nil) ⇒ Object
39
40
41
42
43
|
# File 'lib/coinbase_custody/client.rb', line 39
def post(path, body: nil)
http_request(body: body) do |request_params|
HTTParty.post("#{@url}#{path}", request_params)
end
end
|