Class: Provide::Services::Tourguide

Inherits:
ApiClient
  • Object
show all
Defined in:
lib/provide-ruby/services/tourguide.rb

Instance Attribute Summary

Attributes inherited from ApiClient

#base_url, #token

Instance Method Summary collapse

Methods inherited from ApiClient

#delete, #get, #post, #put, #send_request

Constructor Details

#initialize(scheme = 'http', host, token) ⇒ Tourguide

Returns a new instance of Tourguide.



5
6
7
8
9
# File 'lib/provide-ruby/services/tourguide.rb', line 5

def initialize(scheme = 'http', host, token)
  @scheme = scheme
  @host = host
  @token = token
end

Instance Method Details

#directions(from_latitude, from_longitude, to_latitude, to_longitude, waypoints = nil, departure = 'now', alternatives = 0) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/provide-ruby/services/tourguide.rb', line 11

def directions(from_latitude, from_longitude, to_latitude, to_longitude, waypoints = nil, departure = 'now', alternatives = 0)
  parse client.get('directions', {
    :alternatives => alternatives,
    :departure => departure,
    :from_latitude => from_latitude,
    :from_longitude => from_longitude,
    :to_latitude => to_latitude,
    :to_longitude => to_longitude,
    :waypoints => waypoints,
  })
end

#eta(from_latitude, from_longitude, to_latitude, to_longitude, waypoints = nil, departure = 'now', alternatives = 0) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/provide-ruby/services/tourguide.rb', line 23

def eta(from_latitude, from_longitude, to_latitude, to_longitude, waypoints = nil, departure = 'now', alternatives = 0)
  parse client.get('directions/eta', {
    :alternatives => alternatives,
    :departure => departure,
    :from_latitude => from_latitude,
    :from_longitude => from_longitude,
    :to_latitude => to_latitude,
    :to_longitude => to_longitude,
    :waypoints => waypoints,
  })
end

#geocode(street_number = nil, street = nil, city = nil, state = nil, postal_code = nil) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/provide-ruby/services/tourguide.rb', line 35

def geocode(street_number = nil, street = nil, city = nil, state = nil, postal_code = nil)
  parse client.get('geocoder', {
    :street_number => street_number,
    :street => street,
    :city => city,
    :state => state,
    :postal_code => postal_code,
  })
end

#matrix(origin_coords, destination_coords) ⇒ Object



52
53
54
55
56
57
# File 'lib/provide-ruby/services/tourguide.rb', line 52

def matrix(origin_coords, destination_coords)
  parse client.get('matrix', {
    :origin_coords => origin_coords,
    :destination_coords => destination_coords,
  })
end

#place_details(place_id) ⇒ Object



59
60
61
62
63
# File 'lib/provide-ruby/services/tourguide.rb', line 59

def place_details(place_id)
  parse client.get('places', {
    :place_id => place_id,
  })
end

#places_autocomplete(query, latitude, longitude, radius = 15, type = nil, components = nil) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/provide-ruby/services/tourguide.rb', line 65

def places_autocomplete(query, latitude, longitude, radius = 15, type = nil, components = nil)
  params = {
    :q => query,
    :latitude => latitude,
    :longitude => longitude,
    :radius => radius,
  }
  params[:type] = type if type
  params[:components] = components = components if components
  parse client.get('places/autocomplete', params)
end

#reverse_geocode(latitude, longitude) ⇒ Object



45
46
47
48
49
50
# File 'lib/provide-ruby/services/tourguide.rb', line 45

def reverse_geocode(latitude, longitude)
  parse client.get('geocoder', {
    :latitude => latitude,
    :longitude => longitude,
  })
end

#timezones(latitude, longitude) ⇒ Object



77
78
79
80
81
82
# File 'lib/provide-ruby/services/tourguide.rb', line 77

def timezones(latitude, longitude)
  parse client.get('timezones', {
    :latitude => latitude,
    :longitude => longitude,
  })
end