Class: NetologyGroup::TasksClient::Client
- Inherits:
-
Object
- Object
- NetologyGroup::TasksClient::Client
- Defined in:
- lib/netology_group/tasks_client/client.rb
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #request(method:, path:, body: nil, api_version: nil, query: nil, response_class: Response, expects: [200, 201, 422]) ⇒ Hash
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
4 |
# File 'lib/netology_group/tasks_client/client.rb', line 4 def initialize; end |
Instance Method Details
#connection ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/netology_group/tasks_client/client.rb', line 21 def connection @connection ||= Excon.new( Config.endpoint.to_s, headers: { 'Content-Type' => 'application/json' } ) end |
#request(method:, path:, body: nil, api_version: nil, query: nil, response_class: Response, expects: [200, 201, 422]) ⇒ Hash
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/netology_group/tasks_client/client.rb', line 7 def request(method:, path:, body: nil, api_version: nil, query: nil, response_class: Response, expects: [200, 201, 422]) response = connection.request( method: method, path: "/api/v#{api_version || Config.default_api_version}#{path}", body: body, query: query, expects: expects ) response_class.new(response) # rescue Excon::Error # raise Error end |