provide-ruby 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/provide-ruby/services/tourguide.rb +99 -0
- data/lib/provide-ruby/version.rb +1 -1
- data/lib/provide-ruby.rb +2 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a6aae64fec68e62ebbb87b1cf7b9695ce0a0929
|
4
|
+
data.tar.gz: 70ea991ade7497793af7ddb6f243ca9fc8cb2b3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12dab8b9eebba927b51c99ff43501845e40884ad66887a57d2f6369dcf5c5bb67d68208f9ad355727bafd2b41a3377b7ccdd689cf8bda16ccfcb882a33582e1e
|
7
|
+
data.tar.gz: a0b6dbd573b5602936f6c9257a7df2c4c4eb6dbec15594b62b2c1ccf79e95e0858616f598865a16a8a363445d838081aed1c25ec0d5c46c1787e02e72e1a38d3
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Provide
|
2
|
+
module Services
|
3
|
+
class Tourguide < Provide::ApiClient
|
4
|
+
|
5
|
+
def initialize(scheme = 'http', host)
|
6
|
+
@scheme = scheme
|
7
|
+
@host = host
|
8
|
+
end
|
9
|
+
|
10
|
+
def directions(from_latitude, from_longitude, to_latitude, to_longitude, waypoints = nil, departure = 'now', alternatives = 0)
|
11
|
+
parse client.get('directions', {
|
12
|
+
:alternatives => alternatives,
|
13
|
+
:departure => departure,
|
14
|
+
:from_latitude => from_latitude,
|
15
|
+
:from_longitude => from_longitude,
|
16
|
+
:to_latitude => to_latitude,
|
17
|
+
:to_longitude => to_longitude,
|
18
|
+
:waypoints => waypoints,
|
19
|
+
})
|
20
|
+
end
|
21
|
+
|
22
|
+
def eta(from_latitude, from_longitude, to_latitude, to_longitude, waypoints = nil, departure = 'now', alternatives = 0)
|
23
|
+
parse client.get('directions/eta', {
|
24
|
+
:alternatives => alternatives,
|
25
|
+
:departure => departure,
|
26
|
+
:from_latitude => from_latitude,
|
27
|
+
:from_longitude => from_longitude,
|
28
|
+
:to_latitude => to_latitude,
|
29
|
+
:to_longitude => to_longitude,
|
30
|
+
:waypoints => waypoints,
|
31
|
+
})
|
32
|
+
end
|
33
|
+
|
34
|
+
def geocode(street_number = nil, street = nil, city = nil, state = nil, postal_code = nil)
|
35
|
+
parse client.get('geocoder', {
|
36
|
+
:street_number => street_number,
|
37
|
+
:street => street,
|
38
|
+
:city => city,
|
39
|
+
:state => state,
|
40
|
+
:postal_code => postal_code,
|
41
|
+
})
|
42
|
+
end
|
43
|
+
|
44
|
+
def reverse_geocode(latitude, longitude)
|
45
|
+
parse client.get('geocoder', {
|
46
|
+
:latitude => latitude,
|
47
|
+
:longitude => longitude,
|
48
|
+
})
|
49
|
+
end
|
50
|
+
|
51
|
+
def matrix(origin_coords, destination_coords)
|
52
|
+
parse client.get('matrix', {
|
53
|
+
:origin_coords => origin_coords,
|
54
|
+
:destination_coords => destination_coords,
|
55
|
+
})
|
56
|
+
end
|
57
|
+
|
58
|
+
def place_details(place_id)
|
59
|
+
parse client.get('places', {
|
60
|
+
:place_id => place_id,
|
61
|
+
})
|
62
|
+
end
|
63
|
+
|
64
|
+
def places_autocomplete(query, latitude, longitude, radius = 15)
|
65
|
+
parse client.get('places/autocomplete', {
|
66
|
+
:q => query,
|
67
|
+
:latitude => latitude,
|
68
|
+
:longitude => longitude,
|
69
|
+
:radius => radius,
|
70
|
+
})
|
71
|
+
end
|
72
|
+
|
73
|
+
def timezones(latitude, longitude)
|
74
|
+
parse client.get('timezones', {
|
75
|
+
:latitude => latitude,
|
76
|
+
:longitude => longitude,
|
77
|
+
})
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def client
|
83
|
+
@client ||= begin
|
84
|
+
Provide::ApiClient.new(@scheme, @host, 'api/v1/')
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def parse(response)
|
89
|
+
begin
|
90
|
+
return response.code, JSON.parse(response.body)
|
91
|
+
rescue
|
92
|
+
raise Exception.new({
|
93
|
+
:code => response.code,
|
94
|
+
})
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/lib/provide-ruby/version.rb
CHANGED
data/lib/provide-ruby.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: provide-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Thomas
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- bin/setup
|
115
115
|
- lib/provide-ruby.rb
|
116
116
|
- lib/provide-ruby/api_client.rb
|
117
|
+
- lib/provide-ruby/services/tourguide.rb
|
117
118
|
- lib/provide-ruby/version.rb
|
118
119
|
- provide-ruby.gemspec
|
119
120
|
homepage: https://github.com/provideapp/provide-ruby.git
|