Class: DarujmeCz::Connection
- Inherits:
-
Object
- Object
- DarujmeCz::Connection
- Defined in:
- lib/darujme_cz/connection.rb
Constant Summary collapse
- URL =
"https://www.darujme.cz/api/v1"
Instance Method Summary collapse
- #get(path, params = {}) ⇒ Object
-
#initialize(app_id:, api_key:) ⇒ Connection
constructor
A new instance of Connection.
- #post(path, data = {}) ⇒ Object
Constructor Details
#initialize(app_id:, api_key:) ⇒ Connection
Returns a new instance of Connection.
11 12 13 14 |
# File 'lib/darujme_cz/connection.rb', line 11 def initialize(app_id:, api_key:) @app_id = app_id @api_key = api_key end |
Instance Method Details
#get(path, params = {}) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/darujme_cz/connection.rb', line 18 def get(path, params = {}) begin response = RestClient.get "#{URL}/#{path}", params: { apiId: @app_id, apiSecret: @api_key }.merge(params) rescue RestClient::Exception => e handle_response_error(e) end parse_response(response) end |
#post(path, data = {}) ⇒ Object
27 28 29 30 |
# File 'lib/darujme_cz/connection.rb', line 27 def post(path, data = {}) # @todo raise NotImplementedError end |