Module: TriviaCrack::API::Common
Instance Method Summary collapse
-
#get(url, parameters: nil) ⇒ Object
Internal: Makes a GET request to the Trivia Crack API using the set of default headers.
-
#post(url, parameters: nil) ⇒ Object
Internal: Makes a POST request to the Trivia Crack API using the set of default headers.
Instance Method Details
#get(url, parameters: nil) ⇒ Object
Internal: Makes a GET request to the Trivia Crack API using the set of default headers.
url - The URL of the TriviaCrack API resource. parameters - The parameters to send with the request.
Returns a Unirest Response object with the server’s response. Raises TriviaCrack:Errors::RequestError if the request fails.
18 19 20 21 22 23 |
# File 'lib/triviacrack/api/common.rb', line 18 def get(url, parameters: nil) response = Unirest.get "#{API_HOST}#{url}", parameters: parameters, headers: default_headers check_response response end |
#post(url, parameters: nil) ⇒ Object
Internal: Makes a POST request to the Trivia Crack API using the set of default headers.
url - The URL of the TriviaCrack API resource. parameters - The parameters to send with the request.
Returns a Unirest Response object with the server’s response. Raises TriviaCrack:Errors::RequestError if the request fails.
33 34 35 36 37 38 |
# File 'lib/triviacrack/api/common.rb', line 33 def post(url, parameters: nil) response = Unirest.post "#{API_HOST}#{url}", parameters: parameters, headers: default_headers check_response response end |