Class: DarujmeCz::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/darujme_cz/connection.rb

Constant Summary collapse

URL =
"https://www.darujme.cz/api/v1"

Instance Method Summary collapse

Constructor Details

#initialize(app_id:, api_key:) ⇒ Connection

Returns a new instance of Connection.

Parameters:

  • app_id (String)
  • api_key (String)


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

Parameters:

  • path (String)
  • params (Hash) (defaults to: {})


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

Raises:

  • (NotImplementedError)


27
28
29
30
# File 'lib/darujme_cz/connection.rb', line 27

def post(path, data = {})
  # @todo
  raise NotImplementedError
end