Class: CirroIOV2::RequestClients::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/cirro_io_v2/request_clients/base.rb

Direct Known Subclasses

Jwt

Instance Method Summary collapse

Instance Method Details

#make_request(*args) ⇒ Object

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/cirro_io_v2/request_clients/base.rb', line 18

def make_request(*args)
  raise NotImplementedError
end

#request(*args, **named_args) ⇒ Object

Interface of all request clients. It returns the response if the request was successful (HTTP::2xx) and raises a CirroIOV2::HTTPError together with the response if the request was not successful



7
8
9
10
11
12
13
14
15
16
# File 'lib/cirro_io_v2/request_clients/base.rb', line 7

def request(*args, **named_args)
  response = make_request(*args, **named_args)
  raise Errors::HTTPError, response unless response.success?

  response
rescue Faraday::ParsingError => e
  raise Errors::ResponseNotJsonError, e
rescue Faraday::ClientError => e
  raise Errors::ClientError, e
end