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_STATUSES =
[500, 503, 504]

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.



31
32
33
34
35
# File 'lib/google_maps_service/client.rb', line 31

def initialize(options={})
  @key = options[:key] || GoogleMapsService.key
  @client_id = options[:client_id] || GoogleMapsService.client_id
  @client_secret = options[:client_secret] || GoogleMapsService.client_secret
end

Instance Attribute Details

#client_idString (readonly)

Client id for using Maps API for Work services.

Returns:

  • (String)


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

def client_id
  @client_id
end

#client_secretString (readonly)

Client secret for using Maps API for Work services.

Returns:

  • (String)


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

def client_secret
  @client_secret
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)


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

def key
  @key
end

Instance Method Details

#clientHurley::Client

Get the current HTTP client

Returns:

  • (Hurley::Client)


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

def client
  @client ||= new_client
end