Class: GoogleMapsPlatform::GeolocationApiController
- Inherits:
-
BaseController
- Object
- BaseController
- GoogleMapsPlatform::GeolocationApiController
- Defined in:
- lib/google_maps_platform/controllers/geolocation_api_controller.rb
Overview
GeolocationApiController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#geolocate(body: nil) ⇒ ApiResponse
Geolocation API returns a location and accuracy radius based on information about cell towers and WiFi nodes that the mobile client can detect.
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
#geolocate(body: nil) ⇒ ApiResponse
Geolocation API returns a location and accuracy radius based on information about cell towers and WiFi nodes that the mobile client can detect. This document describes the protocol used to send this data to the server and to return a response to the client. Communication is done over HTTPS using POST. Both request and response are formatted as JSON, and the content type of both is application/json. You must specify a key in your request, included as the value of a`key` parameter. A key is your application’s API key. This key identifies your application for purposes of quota management. Learn how to [get a key](developers.google.com/maps/documentation/geolocation/get-api- key). be formatted as JSON.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/google_maps_platform/controllers/geolocation_api_controller.rb', line 23 def geolocate(body: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/geolocation/v1/geolocate', Server::DEFAULT) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('ApiKeyAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GeolocationResponse.method(:from_hash)) .is_api_response(true) .local_error('400', '400 BAD REQUEST', ErrorResponseException) .local_error('404', '404 NOT FOUND', ErrorResponseException)) .execute end |