Class: GoogleMapsApis::Client
- Inherits:
-
Object
- Object
- GoogleMapsApis::Client
- Includes:
- Services::Directions, Services::DistanceMatrix, Services::Elevation, Services::Geocoding, Services::Places, Services::Roads, Services::TimeZone
- Defined in:
- lib/google_maps_apis/client.rb
Overview
Core client functionality, common across all API requests (including performing HTTP requests).
Constant Summary collapse
- DEFAULT_BASE_URL =
Default Google Maps Web Service base endpoints
'https://maps.googleapis.com'
- RETRIABLE_ERRORS =
Errors those could be retriable.
[GoogleMapsApis::Error::ServerError, GoogleMapsApis::Error::RateLimitError]
Constants included from Services::Roads
Services::Roads::ROADS_BASE_URL
Instance Attribute Summary collapse
-
#client_id ⇒ String
Client id for using Maps API for Work services.
-
#client_secret ⇒ String
Client secret for using Maps API for Work services.
-
#key ⇒ String
Secret key for accessing Google Maps Web Service.
-
#queries_per_second ⇒ Integer
readonly
Number of queries per second permitted.
-
#retry_timeout ⇒ Integer
Timeout across multiple retriable requests, in seconds.
Instance Method Summary collapse
-
#client ⇒ Faraday::Client
Get the current HTTP client.
-
#initialize(**options) ⇒ Client
constructor
Construct Google Maps Web Service API client.
Methods included from Services::Places
Methods included from Services::TimeZone
Methods included from Services::Roads
#nearest_roads, #snap_to_roads, #snapped_speed_limits, #speed_limits
Methods included from Services::Geocoding
Methods included from Services::Elevation
#elevation, #elevation_along_path
Methods included from Services::DistanceMatrix
Methods included from Services::Directions
Constructor Details
#initialize(**options) ⇒ Client
Construct Google Maps Web Service API client.
You can configure Hurley::Client
through request_options
and ssl_options
parameters.
You can also directly get the Hurley::Client
object via #client method.
112 113 114 115 116 117 118 119 120 |
# File 'lib/google_maps_apis/client.rb', line 112 def initialize(**) [:key, :client_id, :client_secret, :retry_timeout, :queries_per_second, :request_options, :ssl_options, :connection].each do |key| self.instance_variable_set("@#{key}".to_sym, [key] || GoogleMapsApis.instance_variable_get("@#{key}")) end initialize_query_tickets end |
Instance Attribute Details
#client_id ⇒ String
Client id for using Maps API for Work services.
43 44 45 |
# File 'lib/google_maps_apis/client.rb', line 43 def client_id @client_id end |
#client_secret ⇒ String
Client secret for using Maps API for Work services.
47 48 49 |
# File 'lib/google_maps_apis/client.rb', line 47 def client_secret @client_secret end |
#key ⇒ String
Secret key for accessing Google Maps Web Service. Can be obtained at https://developers.google.com/maps/documentation/geocoding/get-api-key#key.
39 40 41 |
# File 'lib/google_maps_apis/client.rb', line 39 def key @key end |
#queries_per_second ⇒ Integer (readonly)
Number of queries per second permitted. If the rate limit is reached, the client will sleep for the appropriate amount of time before it runs the current query.
57 58 59 |
# File 'lib/google_maps_apis/client.rb', line 57 def queries_per_second @queries_per_second end |
#retry_timeout ⇒ Integer
Timeout across multiple retriable requests, in seconds.
51 52 53 |
# File 'lib/google_maps_apis/client.rb', line 51 def retry_timeout @retry_timeout end |
Instance Method Details
#client ⇒ Faraday::Client
Get the current HTTP client.
124 125 126 |
# File 'lib/google_maps_apis/client.rb', line 124 def client @client ||= new_client end |