Class: GoogleMapsService::Client

Inherits:
Object
  • Object
show all
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

Roads::ROADS_BASE_URL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TimeZone

#timezone

Methods included from Roads

#snap_to_roads, #snapped_speed_limits, #speed_limits

Methods included from Geocoding

#geocode, #reverse_geocode

Methods included from Elevation

#elevation, #elevation_along_path

Methods included from DistanceMatrix

#distance_matrix

Methods included from Directions

#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(options={})
  @key = options[:key] || GoogleMapsService.key
  @client_id = options[:client_id] || GoogleMapsService.client_id
  @client_secret = options[:client_secret] || GoogleMapsService.client_secret
  @connect_timeout = options[:connect_timeout] || GoogleMapsService.connect_timeout
  @read_timeout = options[:read_timeout] || GoogleMapsService.read_timeout
  @retry_timeout = options[:retry_timeout] || GoogleMapsService.retry_timeout || 60
end

Instance Attribute Details

#client_idString (readonly)

Client id for using Maps API for Work services.

Returns:

  • (String)


26
27
28
# File 'lib/google_maps_service/client.rb', line 26

def client_id
  @client_id
end

#client_secretString (readonly)

Client secret for using Maps API for Work services.

Returns:

  • (String)


30
31
32
# File 'lib/google_maps_service/client.rb', line 30

def client_secret
  @client_secret
end

#connect_timeoutInteger (readonly)

Connection timeout for HTTP requests, in seconds. You should specify read_timeout in addition to this option.

Returns:

  • (Integer)


35
36
37
# File 'lib/google_maps_service/client.rb', line 35

def connect_timeout
  @connect_timeout
end

#keyString (readonly)

Secret key for accessing Google Maps Web Service. Can be obtained at developers.google.com/maps/documentation/geocoding/get-api-key#key

Returns:

  • (String)


22
23
24
# File 'lib/google_maps_service/client.rb', line 22

def key
  @key
end

#read_timeoutInteger (readonly)

Read timeout for HTTP requests, in seconds. You should specify connect_timeout in addition to this

Returns:

  • (Integer)


40
41
42
# File 'lib/google_maps_service/client.rb', line 40

def read_timeout
  @read_timeout
end

#retry_timeoutInteger (readonly)

Timeout across multiple retriable requests, in seconds.

Returns:

  • (Integer)


44
45
46
# File 'lib/google_maps_service/client.rb', line 44

def retry_timeout
  @retry_timeout
end

Instance Method Details

#clientHurley::Client

Get the current HTTP client

Returns:

  • (Hurley::Client)


57
58
59
# File 'lib/google_maps_service/client.rb', line 57

def client
  @client ||= new_client
end