Module: WorldTimeApi::Request

Includes:
HTTParty
Defined in:
lib/world_time_api/request.rb

Overview

The Request module contains methods for making HTTP requests to the World Time API.

Constant Summary collapse

Call =

Makes an HTTP GET request to the specified URL and returns the response as a hash.

Returns:

  • (Hash)

    A hash representing the response body, or an error hash if there was a problem with the request.

->(url) {
  begin
    response = get(url)

    return WorldTimeApi::Error["Invalid timezone"] if response.code != 200

    WorldTimeApi::Response[response]
  rescue StandardError
    WorldTimeApi::Error["Connection error"]
  end
}