Class: Njalla::V1::Client
- Inherits:
-
Object
- Object
- Njalla::V1::Client
- Includes:
- HTTParty
- Defined in:
- lib/njalla/v1/client.rb
Overview
Implements HTTP client
Instance Method Summary collapse
- #get(method, params = nil) ⇒ Object
-
#initialize(token:) ⇒ Client
constructor
A new instance of Client.
- #post(method, params) ⇒ Object
Constructor Details
#initialize(token:) ⇒ Client
Returns a new instance of Client.
14 15 16 |
# File 'lib/njalla/v1/client.rb', line 14 def initialize(token:) @token = token end |
Instance Method Details
#get(method, params = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/njalla/v1/client.rb', line 20 def get(method, params = nil) raise params.errors.inspect unless params&.success? self.class.get('/', headers: headers, body: { jsonrpc: '2.0', method: method, params: params&.to_h }.to_json) end |
#post(method, params) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/njalla/v1/client.rb', line 32 def post(method, params) raise params.errors.inspect unless params.success? self.class.post('/', headers: headers, body: { jsonrpc: '2.0', method: method, params: params.to_h }.to_json) end |