Class: GoogleMapsService::Client
- Inherits:
-
Object
- Object
- GoogleMapsService::Client
- Includes:
- Apis::Directions, Apis::DistanceMatrix, Apis::Elevation, Apis::Geocoding, Apis::Places, 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 ⇒ Object deprecated Deprecated.
-
#initialize(**options) ⇒ Client
constructor
Construct Google Maps Web Service API client.
Methods included from Apis::TimeZone
Methods included from Apis::Roads
#nearest_roads, #snap_to_roads, #snapped_speed_limits, #speed_limits
Methods included from Apis::Places
#place, #places, #places_nearby, #places_photo
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
Construct Google Maps Web Service API client.
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/google_maps_service/client.rb', line 80 def initialize(**) [:key, :client_id, :client_secret, :retry_timeout, :queries_per_second].each do |key| instance_variable_set("@#{key}".to_sym, [key] || GoogleMapsService.instance_variable_get("@#{key}")) end [:request_options, :ssl_options, :connection].each do |key| if .has_key?(key) raise "GoogleMapsService::Client.new no longer supports #{key}." end end initialize_query_tickets end |
Instance Attribute Details
#client_id ⇒ String
Client id for using Maps API for Work services.
40 41 42 |
# File 'lib/google_maps_service/client.rb', line 40 def client_id @client_id end |
#client_secret ⇒ String
Client secret for using Maps API for Work services.
44 45 46 |
# File 'lib/google_maps_service/client.rb', line 44 def client_secret @client_secret end |
#key ⇒ String
Secret key for accessing Google Maps Web Service. Can be obtained at developers.google.com/maps/documentation/geocoding/get-api-key#key.
36 37 38 |
# File 'lib/google_maps_service/client.rb', line 36 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.
54 55 56 |
# File 'lib/google_maps_service/client.rb', line 54 def queries_per_second @queries_per_second end |
#retry_timeout ⇒ Integer
Timeout across multiple retriable requests, in seconds.
48 49 50 |
# File 'lib/google_maps_service/client.rb', line 48 def retry_timeout @retry_timeout end |
Instance Method Details
#client ⇒ Object
Get the current HTTP client.
96 97 98 |
# File 'lib/google_maps_service/client.rb', line 96 def client raise "GoogleMapsService::Client.client is no longer implemented." end |