Class: GoogleMapsService::Client
- Inherits:
-
Object
- Object
- GoogleMapsService::Client
- Includes:
- Directions, DistanceMatrix, Elevation, Geocoding, Roads, TimeZone
- Defined in:
- lib/google_maps_service/client.rb
Constant Summary collapse
- USER_AGENT =
"GoogleGeoApiClientRuby/#{GoogleMapsService::VERSION}"- DEFAULT_BASE_URL =
"https://maps.googleapis.com"- RETRIABLE_ERRORS =
[GoogleMapsService::Error::ServerError, GoogleMapsService::Error::RateLimitError]
Constants included from Roads
Instance Attribute Summary collapse
-
#client_id ⇒ String
readonly
Client id for using Maps API for Work services.
-
#client_secret ⇒ String
readonly
Client secret for using Maps API for Work services.
-
#connect_timeout ⇒ Integer
readonly
Connection timeout for HTTP requests, in seconds.
-
#key ⇒ String
readonly
Secret key for accessing Google Maps Web Service.
-
#read_timeout ⇒ Integer
readonly
Read timeout for HTTP requests, in seconds.
-
#retry_timeout ⇒ Integer
readonly
Timeout across multiple retriable requests, in seconds.
Instance Method Summary collapse
-
#client ⇒ Hurley::Client
Get the current HTTP client.
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
Methods included from TimeZone
Methods included from Roads
#snap_to_roads, #snapped_speed_limits, #speed_limits
Methods included from Geocoding
Methods included from Elevation
#elevation, #elevation_along_path
Methods included from DistanceMatrix
Methods included from Directions
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
46 47 48 49 50 51 52 53 |
# File 'lib/google_maps_service/client.rb', line 46 def initialize(={}) @key = [:key] || GoogleMapsService.key @client_id = [:client_id] || GoogleMapsService.client_id @client_secret = [:client_secret] || GoogleMapsService.client_secret @connect_timeout = [:connect_timeout] || GoogleMapsService.connect_timeout @read_timeout = [:read_timeout] || GoogleMapsService.read_timeout @retry_timeout = [:retry_timeout] || GoogleMapsService.retry_timeout || 60 end |
Instance Attribute Details
#client_id ⇒ String (readonly)
Client id for using Maps API for Work services.
26 27 28 |
# File 'lib/google_maps_service/client.rb', line 26 def client_id @client_id end |
#client_secret ⇒ String (readonly)
Client secret for using Maps API for Work services.
30 31 32 |
# File 'lib/google_maps_service/client.rb', line 30 def client_secret @client_secret end |
#connect_timeout ⇒ Integer (readonly)
Connection timeout for HTTP requests, in seconds. You should specify read_timeout in addition to this option.
35 36 37 |
# File 'lib/google_maps_service/client.rb', line 35 def connect_timeout @connect_timeout end |
#key ⇒ String (readonly)
Secret key for accessing Google Maps Web Service. Can be obtained at developers.google.com/maps/documentation/geocoding/get-api-key#key
22 23 24 |
# File 'lib/google_maps_service/client.rb', line 22 def key @key end |
#read_timeout ⇒ Integer (readonly)
Read timeout for HTTP requests, in seconds. You should specify connect_timeout in addition to this
40 41 42 |
# File 'lib/google_maps_service/client.rb', line 40 def read_timeout @read_timeout end |
#retry_timeout ⇒ Integer (readonly)
Timeout across multiple retriable requests, in seconds.
44 45 46 |
# File 'lib/google_maps_service/client.rb', line 44 def retry_timeout @retry_timeout end |
Instance Method Details
#client ⇒ Hurley::Client
Get the current HTTP client
57 58 59 |
# File 'lib/google_maps_service/client.rb', line 57 def client @client ||= new_client end |