tiramizoo 0.1.2 → 0.1.3
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/tiramizoo/version.rb +1 -1
- data/lib/tiramizoo.rb +45 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77c51eb69eb88c5986c101ade12428fb1f4dbf23
|
4
|
+
data.tar.gz: 2e0b72bb2860fdab5a320e11284cddd05ab32ee1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29591ec62999ec8f853df6ec2c7ba43d6bcd2f8d9a7f5bb46193989a3e0cfd8026e3acdb3aaca009a71544e60fdb94434c911f413078073ae48b0402e7c3975f
|
7
|
+
data.tar.gz: 3a3258c0e24c278100c62a78da50317ed2a4a1b1a9726069f08b937380d028a10c54a512d905a7126e86b1ac5eb4117a256f07cd04283cdd591efa55f2e7d147
|
data/lib/tiramizoo/version.rb
CHANGED
data/lib/tiramizoo.rb
CHANGED
@@ -66,5 +66,50 @@ module Tiramizoo
|
|
66
66
|
raise UnknownError
|
67
67
|
end
|
68
68
|
end
|
69
|
+
|
70
|
+
def calculate_distance(origin, destination)
|
71
|
+
response = connection.get({
|
72
|
+
:path => "/api/v1/distance",
|
73
|
+
:query => {
|
74
|
+
:origin => origin.values.join(","),
|
75
|
+
:destination => destination.values.join(",")
|
76
|
+
},
|
77
|
+
:headers => {"Api-Token" => api_token},
|
78
|
+
:idempotent => true,
|
79
|
+
:read_timeout => 1,
|
80
|
+
:write_timeout => 1
|
81
|
+
})
|
82
|
+
|
83
|
+
case response.status
|
84
|
+
when 200
|
85
|
+
JSON.parse(response.body)["distance"]
|
86
|
+
when 401
|
87
|
+
raise InvalidApiToken
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def geocode(address_line, postal_code, city, country_code)
|
92
|
+
response = connection.get({
|
93
|
+
:path => "/api/v1/geocode",
|
94
|
+
:query => {
|
95
|
+
:address_line => address_line,
|
96
|
+
:postal_code => postal_code,
|
97
|
+
:country_code => country_code,
|
98
|
+
:city => city
|
99
|
+
},
|
100
|
+
:headers => {"Api-Token" => api_token},
|
101
|
+
:idempotent => true,
|
102
|
+
:read_timeout => 1,
|
103
|
+
:write_timeout => 1
|
104
|
+
})
|
105
|
+
|
106
|
+
case response.status
|
107
|
+
when 200
|
108
|
+
JSON.parse(response.body)
|
109
|
+
when 401
|
110
|
+
raise InvalidApiToken
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
69
114
|
end
|
70
115
|
end
|