Class: GoogleMapsService::Client
- Inherits:
-
Object
- Object
- GoogleMapsService::Client
- Includes:
- Apis::Directions, Apis::DistanceMatrix, Apis::Elevation, Apis::Geocoding, Apis::Roads, Apis::TimeZone
- Defined in:
- lib/google_maps_service/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.
[GoogleMapsService::Error::ServerError, GoogleMapsService::Error::RateLimitError]
Constants included from Apis::Roads
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 ⇒ Hurley::Client
Get the current HTTP client.
-
#initialize(**options) ⇒ Client
constructor
Construct Google Maps Web Service API client.
Methods included from Apis::TimeZone
Methods included from Apis::Roads
#snap_to_roads, #snapped_speed_limits, #speed_limits
Methods included from Apis::Geocoding
Methods included from Apis::Elevation
#elevation, #elevation_along_path
Methods included from Apis::DistanceMatrix
Methods included from Apis::Directions
Constructor Details
#initialize(**options) ⇒ Client
113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/google_maps_service/client.rb', line 113 def initialize(**) @key = [:key] || GoogleMapsService.key @client_id = [:client_id] || GoogleMapsService.client_id @client_secret = [:client_secret] || GoogleMapsService.client_secret @retry_timeout = [:retry_timeout] || GoogleMapsService.retry_timeout || 60 @queries_per_second = [:queries_per_second] || GoogleMapsService.queries_per_second @request_options = [:request_options] || GoogleMapsService. @ssl_options = [:ssl_options] || GoogleMapsService. @connection = [:connection] || GoogleMapsService.connection # initialize_qps if @queries_per_second end |
Instance Attribute Details
#client_id ⇒ String
Client id for using Maps API for Work services.
41 42 43 |
# File 'lib/google_maps_service/client.rb', line 41 def client_id @client_id end |
#client_secret ⇒ String
Client secret for using Maps API for Work services.
45 46 47 |
# File 'lib/google_maps_service/client.rb', line 45 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.
37 38 39 |
# File 'lib/google_maps_service/client.rb', line 37 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.
55 56 57 |
# File 'lib/google_maps_service/client.rb', line 55 def queries_per_second @queries_per_second end |
#retry_timeout ⇒ Integer
Timeout across multiple retriable requests, in seconds.
49 50 51 |
# File 'lib/google_maps_service/client.rb', line 49 def retry_timeout @retry_timeout end |
Instance Method Details
#client ⇒ Hurley::Client
Get the current HTTP client.
129 130 131 |
# File 'lib/google_maps_service/client.rb', line 129 def client @client ||= new_client end |