Class: Trustpilot::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/trustpilot/api.rb

Class Method Summary collapse

Class Method Details

.request(request) ⇒ Object

Sends a request to Trustpilot’s API

args:

request: Trustpilot::Request


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/trustpilot/api.rb', line 14

def request request
  client = build_client request

  response = client.request request.to_http_request

  error = ErrorChecker.new( response ).error_if_appropriate
  raise error if error

  JSON.parse response.body
rescue JSON::ParserError
  {}
end