Class: Rescuetime::Requester
- Inherits:
-
Object
- Object
- Rescuetime::Requester
- Defined in:
- lib/rescuetime/requester.rb
Overview
The Rescuetime::Requestable module contains client methods relating to sending HTTP requests
Constant Summary collapse
- INVALID =
Contains bodies of error responses recieved from rescuetime.com. If one of these responses is recieved, an error will be raised.
{ key_not_found: '"error":"# key not found","messages":"key not found"', query: '"error": "# query error",'\ '"messages": "Error: Likely a badly formatted or missing parameter"' }.freeze
Class Method Summary collapse
-
.get(host, params) ⇒ String
Performs the GET request to the specified host.
Class Method Details
.get(host, params) ⇒ String
Performs the GET request to the specified host. Before making the request, it checks for API key presence and raises an exception if it is not present. All other exceptions require the request to go through.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rescuetime/requester.rb', line 37 def get(host, params) # guard clause: fail if no API key is present key = CoreExtensions::String.new params[:key].to_s # adds #present? key.present? || raise(Errors::MissingCredentialsError) uri = set_uri host, params response = Net::HTTP.get_response uri fail_or_return_body response end |