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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9753a887d75f034b1fdb4ef4e98b4c21e936300f
4
- data.tar.gz: d612e145a37743a2625d9eb8fe01d4c80f82ca8e
3
+ metadata.gz: 77c51eb69eb88c5986c101ade12428fb1f4dbf23
4
+ data.tar.gz: 2e0b72bb2860fdab5a320e11284cddd05ab32ee1
5
5
  SHA512:
6
- metadata.gz: 467312aec377ba5f3c0ccbafb79fc43e554e7f8f76eccb649697a289d1ecc729a45580f73325a687a72a48160cb71118bab3b3e4d0d4c5395ff2e766b17ab7c0
7
- data.tar.gz: e29cc9d274fef01babae1ccc220ce2bac04b2d3ac3aeb4fde56f1f306b26ce7ac3bb4aa24bfc4c88d41fa125704350481203091d493da43ef7aa31acbbba64bf
6
+ metadata.gz: 29591ec62999ec8f853df6ec2c7ba43d6bcd2f8d9a7f5bb46193989a3e0cfd8026e3acdb3aaca009a71544e60fdb94434c911f413078073ae48b0402e7c3975f
7
+ data.tar.gz: 3a3258c0e24c278100c62a78da50317ed2a4a1b1a9726069f08b937380d028a10c54a512d905a7126e86b1ac5eb4117a256f07cd04283cdd591efa55f2e7d147
@@ -1,3 +1,3 @@
1
1
  module Tiramizoo
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiramizoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiramizoo