Class: Lago::Api::Connection
- Inherits:
-
Object
- Object
- Lago::Api::Connection
- Defined in:
- lib/lago/api/connection.rb
Constant Summary collapse
- RESPONSE_SUCCESS_CODES =
[200, 201, 202, 204].freeze
Instance Method Summary collapse
- #delete(body, path = uri.path) ⇒ Object
- #get(path) ⇒ Object
-
#initialize(api_key, uri) ⇒ Connection
constructor
A new instance of Connection.
- #post(body, path = uri.path) ⇒ Object
- #put(path = uri.path, lago_id:, body:) ⇒ Object
Constructor Details
#initialize(api_key, uri) ⇒ Connection
Returns a new instance of Connection.
8 9 10 11 |
# File 'lib/lago/api/connection.rb', line 8 def initialize(api_key, uri) @api_key = api_key @uri = uri end |
Instance Method Details
#delete(body, path = uri.path) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/lago/api/connection.rb', line 36 def delete(body, path = uri.path) response = http_client.send_request( 'DELETE', path, prepare_payload(body), headers ) handle_response(response) end |
#get(path) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/lago/api/connection.rb', line 47 def get(path) response = http_client.send_request( 'GET', path, prepare_payload(nil), headers ) handle_response(response) end |
#post(body, path = uri.path) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/lago/api/connection.rb', line 13 def post(body, path = uri.path) response = http_client.send_request( 'POST', path, prepare_payload(body), headers ) handle_response(response) end |
#put(path = uri.path, lago_id:, body:) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lago/api/connection.rb', line 24 def put(path = uri.path, lago_id:, body:) uri_path = "#{path}/#{lago_id}" response = http_client.send_request( 'PUT', uri_path, prepare_payload(body), headers ) handle_response(response) end |