Class: BitgoClient::Client
- Inherits:
-
Object
- Object
- BitgoClient::Client
- Defined in:
- lib/bitgo_client/client.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
Instance Method Summary collapse
-
#initialize(access_token) ⇒ Client
constructor
A new instance of Client.
- #request(url, payload = nil, method: :get) ⇒ Object
Constructor Details
#initialize(access_token) ⇒ Client
Returns a new instance of Client.
7 8 9 |
# File 'lib/bitgo_client/client.rb', line 7 def initialize(access_token) @access_token = access_token end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
5 6 7 |
# File 'lib/bitgo_client/client.rb', line 5 def access_token @access_token end |
Instance Method Details
#request(url, payload = nil, method: :get) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bitgo_client/client.rb', line 11 def request(url, payload = nil, method: :get) request = Typhoeus::Request.new( url, method: method, headers: { "Authorization" => "Bearer #{access_token}", "Content-Type" => "application/json" }, body: (payload ? payload.to_json : nil) ) request.run response = request.response raise BitgoClient::Errors::RequestError.new("BitGo API response error.", response) if response.failure? JSON.parse(response.body) end |