Class: GoogleMapsPlatform::TimeZoneApiController

Inherits:
BaseController show all
Defined in:
lib/google_maps_platform/controllers/time_zone_api_controller.rb

Overview

TimeZoneApiController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from GoogleMapsPlatform::BaseController

Instance Method Details

#timezone(location, timestamp, language: Language::EN) ⇒ ApiResponse

The Time Zone API provides a simple interface to request the time zone for locations on the surface of the earth, as well as the time offset from UTC for each of those locations. You request the time zone information for a specific latitude/longitude pair and date. The API returns the name of that time zone, the time offset from UTC, and the daylight savings offset. latitude,longitude tuple, ‘location=39.6034810,-119.6822510`, representing the location to look up. since midnight, January 1, 1970 UTC. The Time Zone API uses the timestamp to determine whether or not Daylight Savings should be applied, based on the time zone of the location. Note that the API does not take historical time zones into account. That is, if you specify a past timestamp, the API does not take into account the possibility that the location was previously in a different time zone. return results. * See the [list of supported languages](developers.google.com/maps/faq#languagesupport). Google often updates the supported languages, so this list may not be exhaustive.

  • If language is not supplied, the API attempts to use the preferred

language as specified in the Accept-Language header. * The API does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses are returned in the preferred language. Address components are all returned in the same language, which is chosen from the first component. * If a name is not available in the preferred language, the API uses the closest match. * The preferred language has a small influence on the set of results that the API chooses to return, and the order in which they are returned. The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another. For example, utca and _tér_ are synonyms for street in Hungarian.

Parameters:

  • location (String)

    Required parameter: A comma-separated

  • timestamp (Float)

    Required parameter: The desired time as seconds

  • language (Language) (defaults to: Language::EN)

    Optional parameter: The language in which to

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/google_maps_platform/controllers/time_zone_api_controller.rb', line 44

def timezone(location,
             timestamp,
             language: Language::EN)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/maps/api/timezone/json',
                                 Server::DEFAULT)
               .query_param(new_parameter(location, key: 'location')
                             .is_required(true))
               .query_param(new_parameter(timestamp, key: 'timestamp')
                             .is_required(true))
               .query_param(new_parameter(language, key: 'language'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('ApiKeyAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(TimeZoneResponse.method(:from_hash))
                .is_api_response(true))
    .execute
end