loqate 0.9.0 → 0.10.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/.yardstick.yml +3 -254
- data/CHANGELOG.md +8 -0
- data/README.md +12 -0
- data/lib/loqate/geocoding/gateway.rb +55 -1
- data/lib/loqate/geocoding/place.rb +30 -0
- data/lib/loqate/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c32e6dafdb5718d79353dc403a5be5b67449fee4a9e1e5e0dfe1449d6d5989b9
|
|
4
|
+
data.tar.gz: 8a5d0e9b5573f40554e9faba5b11718b6824e71d9da3f5531b951b1fbec988c8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e526913afe9f0cbd20e2e1da861bef024cde0f0c98628a40705a4e1387019d9edce0c8f4e573bc398b8b04f15788dae4c783044ec5f3ec4084fe6d7bc7ed42e8
|
|
7
|
+
data.tar.gz: ae6f0884d34bb364c6b4eca12ae12a04471a8b00115d3bb469a5ade95dc8057b87afc6c820aeefba63d741e65edd2f47c6984cbc926b97c38ea220ae1252205a
|
data/.yardstick.yml
CHANGED
|
@@ -13,263 +13,12 @@ rules:
|
|
|
13
13
|
enabled: true
|
|
14
14
|
exclude: []
|
|
15
15
|
ExampleTag:
|
|
16
|
-
enabled:
|
|
16
|
+
enabled: false
|
|
17
17
|
exclude:
|
|
18
|
-
- Loqate::Address::Address#==
|
|
19
|
-
- Loqate::Address::Address#attributes
|
|
20
|
-
- Loqate::Address::Address#description
|
|
21
|
-
- Loqate::Address::Address#highlight
|
|
22
|
-
- Loqate::Address::Address#id
|
|
23
|
-
- Loqate::Address::Address#initialize
|
|
24
|
-
- Loqate::Address::Address#text
|
|
25
|
-
- Loqate::Address::Address#type
|
|
26
|
-
- Loqate::Address::Gateway#initialize
|
|
27
|
-
- Loqate::APIResult#errors?
|
|
28
|
-
- Loqate::APIResult#initialize
|
|
29
|
-
- Loqate::APIResult#items
|
|
30
|
-
- Loqate::Bank::AccountValidation#bank
|
|
31
|
-
- Loqate::Bank::AccountValidation#bank_bic
|
|
32
|
-
- Loqate::Bank::AccountValidation#branch
|
|
33
|
-
- Loqate::Bank::AccountValidation#branch_bic
|
|
34
|
-
- Loqate::Bank::AccountValidation#chaps_supported
|
|
35
|
-
- Loqate::Bank::AccountValidation#contact_address_line1
|
|
36
|
-
- Loqate::Bank::AccountValidation#contact_address_line2
|
|
37
|
-
- Loqate::Bank::AccountValidation#contact_fax
|
|
38
|
-
- Loqate::Bank::AccountValidation#contact_phone
|
|
39
|
-
- Loqate::Bank::AccountValidation#contact_post_town
|
|
40
|
-
- Loqate::Bank::AccountValidation#contact_postcode
|
|
41
|
-
- Loqate::Bank::AccountValidation#correct?
|
|
42
|
-
- Loqate::Bank::AccountValidation#corrected_account_number
|
|
43
|
-
- Loqate::Bank::AccountValidation#corrected_sort_code
|
|
44
|
-
- Loqate::Bank::AccountValidation#faster_payments_supported
|
|
45
|
-
- Loqate::Bank::AccountValidation#iban
|
|
46
|
-
- Loqate::Bank::AccountValidation#is_correct
|
|
47
|
-
- Loqate::Bank::AccountValidation#is_direct_debit_capable
|
|
48
|
-
- Loqate::Bank::AccountValidation#status_information
|
|
49
|
-
- Loqate::Bank::BatchAccountValidation#bank
|
|
50
|
-
- Loqate::Bank::BatchAccountValidation#bank_bic
|
|
51
|
-
- Loqate::Bank::BatchAccountValidation#branch
|
|
52
|
-
- Loqate::Bank::BatchAccountValidation#branch_bic
|
|
53
|
-
- Loqate::Bank::BatchAccountValidation#contact_address_line1
|
|
54
|
-
- Loqate::Bank::BatchAccountValidation#contact_address_line2
|
|
55
|
-
- Loqate::Bank::BatchAccountValidation#contact_fax
|
|
56
|
-
- Loqate::Bank::BatchAccountValidation#contact_phone
|
|
57
|
-
- Loqate::Bank::BatchAccountValidation#contact_post_town
|
|
58
|
-
- Loqate::Bank::BatchAccountValidation#contact_postcode
|
|
59
|
-
- Loqate::Bank::BatchAccountValidation#correct?
|
|
60
|
-
- Loqate::Bank::BatchAccountValidation#corrected_account_number
|
|
61
|
-
- Loqate::Bank::BatchAccountValidation#corrected_sort_code
|
|
62
|
-
- Loqate::Bank::BatchAccountValidation#iban
|
|
63
|
-
- Loqate::Bank::BatchAccountValidation#is_correct
|
|
64
|
-
- Loqate::Bank::BatchAccountValidation#is_direct_debit_capable
|
|
65
|
-
- Loqate::Bank::BatchAccountValidation#original_account_number
|
|
66
|
-
- Loqate::Bank::BatchAccountValidation#original_sort_code
|
|
67
|
-
- Loqate::Bank::BatchAccountValidation#status_information
|
|
68
|
-
- Loqate::Bank::Branch#bank
|
|
69
|
-
- Loqate::Bank::Branch#bank_bic
|
|
70
|
-
- Loqate::Bank::Branch#branch
|
|
71
|
-
- Loqate::Bank::Branch#branch_bic
|
|
72
|
-
- Loqate::Bank::Branch#chaps_supported
|
|
73
|
-
- Loqate::Bank::Branch#contact_address_line1
|
|
74
|
-
- Loqate::Bank::Branch#contact_address_line2
|
|
75
|
-
- Loqate::Bank::Branch#contact_fax
|
|
76
|
-
- Loqate::Bank::Branch#contact_phone
|
|
77
|
-
- Loqate::Bank::Branch#contact_post_town
|
|
78
|
-
- Loqate::Bank::Branch#contact_postcode
|
|
79
|
-
- Loqate::Bank::Branch#faster_payments_supported
|
|
80
|
-
- Loqate::Bank::CardValidation#card_number
|
|
81
|
-
- Loqate::Bank::CardValidation#card_type
|
|
82
|
-
- Loqate::Bank::Gateway#build_branch_from
|
|
83
|
-
- Loqate::Bank::Gateway#initialize
|
|
84
|
-
- Loqate::Geocoding::Country#country_name
|
|
85
|
-
- Loqate::Geocoding::Country#country_iso2
|
|
86
|
-
- Loqate::Geocoding::Country#country_iso3
|
|
87
|
-
- Loqate::Geocoding::Country#country_iso_number
|
|
88
|
-
- Loqate::Geocoding::Gateway#position_to_country!
|
|
89
|
-
- Loqate::Geocoding::Gateway#directions!
|
|
90
|
-
- Loqate::Geocoding::Gateway#geocode!
|
|
91
|
-
- Loqate::Geocoding::Location#name
|
|
92
|
-
- Loqate::Geocoding::Location#latitude
|
|
93
|
-
- Loqate::Geocoding::Location#longitude
|
|
94
|
-
- Loqate::Bank::InternationalAccountValidation#correct?
|
|
95
|
-
- Loqate::Bank::InternationalAccountValidation#is_correct
|
|
96
|
-
- Loqate::Email::BatchEmailValidation#account
|
|
97
|
-
- Loqate::Email::BatchEmailValidation#domain
|
|
98
|
-
- Loqate::Email::BatchEmailValidation#email_address
|
|
99
|
-
- Loqate::Email::BatchEmailValidation#invalid?
|
|
100
|
-
- Loqate::Email::BatchEmailValidation#is_disposible
|
|
101
|
-
- Loqate::Email::BatchEmailValidation#is_system_mailbox
|
|
102
|
-
- Loqate::Email::BatchEmailValidation#status
|
|
103
|
-
- Loqate::Email::BatchEmailValidation#unknown?
|
|
104
|
-
- Loqate::Email::BatchEmailValidation#unverified?
|
|
105
|
-
- Loqate::Email::BatchEmailValidation#valid?
|
|
106
|
-
- Loqate::Configuration#api_key
|
|
107
|
-
- Loqate::Configuration#host
|
|
108
|
-
- Loqate::Configuration#initialize
|
|
109
|
-
- Loqate::Configuration#language
|
|
110
|
-
- Loqate::Address::DetailedAddress#==
|
|
111
|
-
- Loqate::Address::DetailedAddress#initialize
|
|
112
|
-
- Loqate::Email::Gateway#initialize
|
|
113
|
-
- Loqate::Email::EmailValidation#domain
|
|
114
|
-
- Loqate::Email::EmailValidation#duration
|
|
115
|
-
- Loqate::Email::EmailValidation#email_address
|
|
116
|
-
- Loqate::Email::EmailValidation#invalid?
|
|
117
|
-
- Loqate::Email::EmailValidation#is_complainer_or_fraud_risk
|
|
118
|
-
- Loqate::Email::EmailValidation#is_disposable_or_temporary
|
|
119
|
-
- Loqate::Email::EmailValidation#response_code
|
|
120
|
-
- Loqate::Email::EmailValidation#response_message
|
|
121
|
-
- Loqate::Email::EmailValidation#timeout?
|
|
122
|
-
- Loqate::Email::EmailValidation#user_account
|
|
123
|
-
- Loqate::Email::EmailValidation#valid?
|
|
124
|
-
- Loqate::Email::EmailValidation#valid_domain?
|
|
125
|
-
- Loqate::Error#cause
|
|
126
|
-
- Loqate::Error#description
|
|
127
|
-
- Loqate::Error#id
|
|
128
|
-
- Loqate::Error#initialize
|
|
129
|
-
- Loqate::Error#resolution
|
|
130
|
-
- Loqate::Gateway#address
|
|
131
|
-
- Loqate::Gateway#bank
|
|
132
|
-
- Loqate::Gateway#config
|
|
133
|
-
- Loqate::Gateway#email
|
|
134
|
-
- Loqate::Gateway#geocoding
|
|
135
|
-
- Loqate::Gateway#initialize
|
|
136
|
-
- Loqate::Gateway#phone
|
|
137
|
-
- Loqate::Geocoding::Gateway#directions
|
|
138
|
-
- Loqate::Geocoding::Gateway#initialize
|
|
139
|
-
- Loqate::Geocoding::Direction#segment_number
|
|
140
|
-
- Loqate::Geocoding::Direction#step_number
|
|
141
|
-
- Loqate::Geocoding::Direction#action
|
|
142
|
-
- Loqate::Geocoding::Direction#description
|
|
143
|
-
- Loqate::Geocoding::Direction#road
|
|
144
|
-
- Loqate::Geocoding::Direction#step_time
|
|
145
|
-
- Loqate::Geocoding::Direction#step_distance
|
|
146
|
-
- Loqate::Geocoding::Direction#total_time
|
|
147
|
-
- Loqate::Geocoding::Direction#total_distance
|
|
148
|
-
- Loqate::Phone::Gateway#initialize
|
|
149
|
-
- Loqate::Phone::PhoneNumberValidation#country_prefix
|
|
150
|
-
- Loqate::Phone::PhoneNumberValidation#is_valid
|
|
151
|
-
- Loqate::Phone::PhoneNumberValidation#national_format
|
|
152
|
-
- Loqate::Phone::PhoneNumberValidation#network_code
|
|
153
|
-
- Loqate::Phone::PhoneNumberValidation#network_country
|
|
154
|
-
- Loqate::Phone::PhoneNumberValidation#network_name
|
|
155
|
-
- Loqate::Phone::PhoneNumberValidation#number_type
|
|
156
|
-
- Loqate::Phone::PhoneNumberValidation#phone_number
|
|
157
|
-
- Loqate::Phone::PhoneNumberValidation#request_processed
|
|
158
|
-
- Loqate::Phone::PhoneNumberValidation#valid?
|
|
159
|
-
- Loqate::Result#code
|
|
160
|
-
- Loqate::Result#value
|
|
161
|
-
- Loqate::Result::Failure#error
|
|
162
|
-
- Loqate::Result::Failure#failure?
|
|
163
|
-
- Loqate::Result::Failure#success?
|
|
164
|
-
- Loqate::Result::Success#failure?
|
|
165
|
-
- Loqate::Result::Success#success?
|
|
166
18
|
ReturnTag:
|
|
167
|
-
enabled:
|
|
168
|
-
exclude:
|
|
169
|
-
- Loqate::Address::Address#==
|
|
170
|
-
- Loqate::Address::Address#attributes
|
|
171
|
-
- Loqate::Address::Address#description
|
|
172
|
-
- Loqate::Address::Address#highlight
|
|
173
|
-
- Loqate::Address::Address#id
|
|
174
|
-
- Loqate::Address::Address#text
|
|
175
|
-
- Loqate::Address::Address#type
|
|
176
|
-
- Loqate::Address::Gateway#build_addresses_from
|
|
177
|
-
- Loqate::Address::Gateway#build_detailed_address_from
|
|
178
|
-
- Loqate::Address::Gateway#build_error_from
|
|
179
|
-
- Loqate::Address::Gateway#client
|
|
180
|
-
- Loqate::Address::Gateway#error_mapper
|
|
181
|
-
- Loqate::Address::Gateway#mapper
|
|
182
|
-
- Loqate::Bank::Gateway#build_account_validation_from
|
|
183
|
-
- Loqate::Bank::Gateway#build_account_validations_from
|
|
184
|
-
- Loqate::Bank::Gateway#build_branch_from
|
|
185
|
-
- Loqate::Bank::Gateway#build_card_validation_from
|
|
186
|
-
- Loqate::Bank::Gateway#build_error_from
|
|
187
|
-
- Loqate::Bank::Gateway#build_int_acc_validation_from
|
|
188
|
-
- Loqate::Bank::Gateway#client
|
|
189
|
-
- Loqate::Bank::Gateway#error_mapper
|
|
190
|
-
- Loqate::Bank::Gateway#mapper
|
|
191
|
-
- Loqate::Client#authenticate_params
|
|
192
|
-
- Loqate::Client#configuration
|
|
193
|
-
- Loqate::Client#format_params
|
|
194
|
-
- Loqate::Client#headers
|
|
195
|
-
- Loqate::Address::DetailedAddress#==
|
|
196
|
-
- Loqate::Email::Gateway#build_email_validation_from
|
|
197
|
-
- Loqate::Email::Gateway#build_email_validations_from
|
|
198
|
-
- Loqate::Email::Gateway#build_error_from
|
|
199
|
-
- Loqate::Email::Gateway#client
|
|
200
|
-
- Loqate::Email::Gateway#error_mapper
|
|
201
|
-
- Loqate::Email::Gateway#mapper
|
|
202
|
-
- Loqate::Error#attributes
|
|
203
|
-
- Loqate::Gateway#client
|
|
204
|
-
- Loqate::Geocoding::Gateway#build_country_from
|
|
205
|
-
- Loqate::Geocoding::Gateway#build_location_from
|
|
206
|
-
- Loqate::Geocoding::Gateway#error_mapper
|
|
207
|
-
- Loqate::Geocoding::Gateway#client
|
|
208
|
-
- Loqate::Geocoding::Gateway#mapper
|
|
209
|
-
- Loqate::Geocoding::Gateway#build_error_from
|
|
210
|
-
- Loqate::Geocoding::Gateway#build_directions_from
|
|
211
|
-
- Loqate::Phone::Gateway#build_error_from
|
|
212
|
-
- Loqate::Phone::Gateway#build_phone_validation_from
|
|
213
|
-
- Loqate::Phone::Gateway#client
|
|
214
|
-
- Loqate::Phone::Gateway#error_mapper
|
|
215
|
-
- Loqate::Phone::Gateway#mapper
|
|
216
|
-
- Loqate::Result::Failure#error
|
|
217
|
-
- Loqate::Util#camelize
|
|
218
|
-
- Loqate::Util#underscore
|
|
219
|
-
- Loqate::Util.camelize
|
|
220
|
-
- Loqate::Util.underscore
|
|
19
|
+
enabled: false
|
|
221
20
|
Summary::Presence:
|
|
222
|
-
enabled:
|
|
223
|
-
exclude:
|
|
224
|
-
- Loqate::Address::Address#==
|
|
225
|
-
- Loqate::Address::Address#attributes
|
|
226
|
-
- Loqate::Address::Address#description
|
|
227
|
-
- Loqate::Address::Address#highlight
|
|
228
|
-
- Loqate::Address::Address#id
|
|
229
|
-
- Loqate::Address::Address#text
|
|
230
|
-
- Loqate::Address::Address#type
|
|
231
|
-
- Loqate::Address::Gateway#build_addresses_from
|
|
232
|
-
- Loqate::Address::Gateway#build_detailed_address_from
|
|
233
|
-
- Loqate::Address::Gateway#build_error_from
|
|
234
|
-
- Loqate::Address::Gateway#client
|
|
235
|
-
- Loqate::Address::Gateway#error_mapper
|
|
236
|
-
- Loqate::Address::Gateway#mapper
|
|
237
|
-
- Loqate::Bank::Gateway#build_account_validation_from
|
|
238
|
-
- Loqate::Bank::Gateway#build_account_validations_from
|
|
239
|
-
- Loqate::Bank::Gateway#build_branch_from
|
|
240
|
-
- Loqate::Bank::Gateway#build_card_validation_from
|
|
241
|
-
- Loqate::Bank::Gateway#build_error_from
|
|
242
|
-
- Loqate::Bank::Gateway#build_int_acc_validation_from
|
|
243
|
-
- Loqate::Bank::Gateway#client
|
|
244
|
-
- Loqate::Bank::Gateway#error_mapper
|
|
245
|
-
- Loqate::Bank::Gateway#mapper
|
|
246
|
-
- Loqate::Client#authenticate_params
|
|
247
|
-
- Loqate::Client#configuration
|
|
248
|
-
- Loqate::Client#format_params
|
|
249
|
-
- Loqate::Client#headers
|
|
250
|
-
- Loqate::Address::DetailedAddress#==
|
|
251
|
-
- Loqate::Address::DetailedAddress#initialize
|
|
252
|
-
- Loqate::Email::Gateway#build_email_validation_from
|
|
253
|
-
- Loqate::Email::Gateway#build_email_validations_from
|
|
254
|
-
- Loqate::Email::Gateway#build_error_from
|
|
255
|
-
- Loqate::Email::Gateway#client
|
|
256
|
-
- Loqate::Email::Gateway#error_mapper
|
|
257
|
-
- Loqate::Email::Gateway#mapper
|
|
258
|
-
- Loqate::Error#attributes
|
|
259
|
-
- Loqate::Gateway#client
|
|
260
|
-
- Loqate::Geocoding::Gateway#build_country_from
|
|
261
|
-
- Loqate::Geocoding::Gateway#error_mapper
|
|
262
|
-
- Loqate::Geocoding::Gateway#client
|
|
263
|
-
- Loqate::Geocoding::Gateway#mapper
|
|
264
|
-
- Loqate::Geocoding::Gateway#build_error_from
|
|
265
|
-
- Loqate::Geocoding::Gateway#build_directions_from
|
|
266
|
-
- Loqate::Geocoding::Gateway#build_location_from
|
|
267
|
-
- Loqate::Phone::Gateway#build_error_from
|
|
268
|
-
- Loqate::Phone::Gateway#build_phone_validation_from
|
|
269
|
-
- Loqate::Phone::Gateway#client
|
|
270
|
-
- Loqate::Phone::Gateway#error_mapper
|
|
271
|
-
- Loqate::Phone::Gateway#mapper
|
|
272
|
-
- Loqate::Result::Failure#error
|
|
21
|
+
enabled: false
|
|
273
22
|
Summary::Length:
|
|
274
23
|
enabled: false
|
|
275
24
|
Summary::Delimiter:
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.10.0] - 2018-12-12
|
|
8
|
+
### Added
|
|
9
|
+
- A service to find the nearest places around a given coordinate
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- Disabled the Yardstick rules `ExampleTag`, `ReturnTag` and `Summary::Presence`.
|
|
13
|
+
|
|
7
14
|
## [0.9.0] - 2018-12-11
|
|
8
15
|
### Added
|
|
9
16
|
- Geocoding service of the Geocoding API
|
|
@@ -66,6 +73,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
66
73
|
- Initial core functionality
|
|
67
74
|
- Codebase maintenance tools
|
|
68
75
|
|
|
76
|
+
[0.10.0]: https://github.com/wilsonsilva/loqate/compare/v0.9.0...v0.10.0
|
|
69
77
|
[0.9.0]: https://github.com/wilsonsilva/loqate/compare/v0.8.0...v0.9.0
|
|
70
78
|
[0.8.0]: https://github.com/wilsonsilva/loqate/compare/v0.7.0...v0.8.0
|
|
71
79
|
[0.7.0]: https://github.com/wilsonsilva/loqate/compare/v0.6.0...v0.7.0
|
data/README.md
CHANGED
|
@@ -23,6 +23,7 @@ Client to address verification, postcode lookup, & data quality services from Lo
|
|
|
23
23
|
- [Finding directions](#finding-directions)
|
|
24
24
|
- [Geocoding a location](#geocoding-a-location)
|
|
25
25
|
- [Finding a country based on coordinates](#finding-a-country-based-on-coordinates)
|
|
26
|
+
- [Finding nearest places](#finding-nearest-places)
|
|
26
27
|
- [Phone API](#phone-api)
|
|
27
28
|
- [Validating a phone number](#validating-a-phone-number)
|
|
28
29
|
- [Email API](#phone-api)
|
|
@@ -156,6 +157,17 @@ country = gateway.geocoding.position_to_country!(latitude: 52.1321, longitude: -
|
|
|
156
157
|
country.country_name # => 'United Kingdom'
|
|
157
158
|
```
|
|
158
159
|
|
|
160
|
+
#### Finding nearest places
|
|
161
|
+
```ruby
|
|
162
|
+
nearest_places = gateway.geocoding.retrieve_nearest_places!(
|
|
163
|
+
centre_point: [-33.440113067627, 149.578567504883],
|
|
164
|
+
maximum_items: 5,
|
|
165
|
+
maximum_radius: 10,
|
|
166
|
+
filter_options: 'HideVillages'
|
|
167
|
+
)
|
|
168
|
+
nearest_places.first.location # => 'South Bathurst, NSW, Australia'
|
|
169
|
+
```
|
|
170
|
+
|
|
159
171
|
### Phone API
|
|
160
172
|
|
|
161
173
|
The Phone API consists of a single API request:
|
|
@@ -3,6 +3,7 @@ require 'loqate/result'
|
|
|
3
3
|
require 'loqate/geocoding/country'
|
|
4
4
|
require 'loqate/geocoding/direction'
|
|
5
5
|
require 'loqate/geocoding/location'
|
|
6
|
+
require 'loqate/geocoding/place'
|
|
6
7
|
require 'loqate/mappers/error_mapper'
|
|
7
8
|
require 'loqate/mappers/generic_mapper'
|
|
8
9
|
|
|
@@ -13,6 +14,7 @@ module Loqate
|
|
|
13
14
|
DIRECTIONS_ENDPOINT = '/DistancesAndDirections/Interactive/Directions/v2.00/json3.ws'.freeze
|
|
14
15
|
GEOCODE_ENDPOINT = '/Geocoding/International/Geocode/v1.10/json3.ws'.freeze
|
|
15
16
|
POSITION_TO_COUNTRY_ENDPOINT = '/Geocoding/International/PositionToCountry/v1.00/json3.ws'.freeze
|
|
17
|
+
NEAREST_PLACES_ENDPOINT = '/Geocoding/International/RetrieveNearestPlaces/v1.00/json3.ws'.freeze
|
|
16
18
|
|
|
17
19
|
include Result::Mixin
|
|
18
20
|
|
|
@@ -141,7 +143,7 @@ module Loqate
|
|
|
141
143
|
# @example
|
|
142
144
|
# result = geocoding_gateway.position_to_country(latitude: 52.1321, longitude: -2.1001)
|
|
143
145
|
#
|
|
144
|
-
# @return [Result
|
|
146
|
+
# @return [Result] A result wrapping a country or wrapping nil if no country is found.
|
|
145
147
|
#
|
|
146
148
|
def position_to_country(options)
|
|
147
149
|
response = client.get(POSITION_TO_COUNTRY_ENDPOINT, options)
|
|
@@ -164,6 +166,52 @@ module Loqate
|
|
|
164
166
|
unwrap_result_or_raise { position_to_country(options) }
|
|
165
167
|
end
|
|
166
168
|
|
|
169
|
+
# Calculates the nearest places of interest of a given category to a given location.
|
|
170
|
+
#
|
|
171
|
+
# @param [Hash] options The coordinates of the position to search against.
|
|
172
|
+
# @option options [String] :country The ISO3 character code for the country to search in. This parameter is
|
|
173
|
+
# optional, but if you wish to use a place for the centre point the country code must be provided.
|
|
174
|
+
# @option options [String] :centre_point A postcode or coordinates (latitude, longitude) of the centre of the
|
|
175
|
+
# search. Can also be a place name (corresponding country code must be provided).
|
|
176
|
+
# @option options [Integer] :maximum_items The maximum number of items to return. If 0, all items are returned.
|
|
177
|
+
# @option options [Float] :maximum_radius The maximum search distance in KM between the origin and a point of
|
|
178
|
+
# interest. If blank or 0, all items are returned.
|
|
179
|
+
# @option options [Float] :filter_options The type of filter to apply where the search returns a list of towns.
|
|
180
|
+
#
|
|
181
|
+
# @example Retrieving the nearest places around a coordinate
|
|
182
|
+
# result = geocoding_gateway.retrieve_nearest_places(
|
|
183
|
+
# centre_point: [-33.440113067627, 149.578567504883],
|
|
184
|
+
# maximum_items: 5,
|
|
185
|
+
# maximum_radius: 10
|
|
186
|
+
# )
|
|
187
|
+
#
|
|
188
|
+
# @example Retrieving the nearest places around a postcode
|
|
189
|
+
# result = geocoding_gateway.retrieve_nearest_places(
|
|
190
|
+
# centre_point: 'NW10 6RB',
|
|
191
|
+
# maximum_items: 5,
|
|
192
|
+
# maximum_radius: 10
|
|
193
|
+
# )
|
|
194
|
+
#
|
|
195
|
+
# @return [Result] A result wrapping a list of places.
|
|
196
|
+
#
|
|
197
|
+
def retrieve_nearest_places(options)
|
|
198
|
+
response = client.get(NEAREST_PLACES_ENDPOINT, options)
|
|
199
|
+
|
|
200
|
+
response.errors? && build_error_from(response.items.first) || build_places_from(response.items)
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# Calculates the nearest places of interest of a given category to a given location.
|
|
204
|
+
#
|
|
205
|
+
# @raise [Error] If the result is not a success
|
|
206
|
+
#
|
|
207
|
+
# @see Loqate::Geocoding::Geocoding#retrieve_nearest_places
|
|
208
|
+
#
|
|
209
|
+
# @return [Array<Place>] A list of places.
|
|
210
|
+
#
|
|
211
|
+
def retrieve_nearest_places!(options)
|
|
212
|
+
unwrap_result_or_raise { retrieve_nearest_places(options) }
|
|
213
|
+
end
|
|
214
|
+
|
|
167
215
|
private
|
|
168
216
|
|
|
169
217
|
# @api private
|
|
@@ -192,6 +240,12 @@ module Loqate
|
|
|
192
240
|
country = mapper.map_one(item, Country)
|
|
193
241
|
Success(country)
|
|
194
242
|
end
|
|
243
|
+
|
|
244
|
+
# @api private
|
|
245
|
+
def build_places_from(items)
|
|
246
|
+
places = mapper.map(items, Place)
|
|
247
|
+
Success(places)
|
|
248
|
+
end
|
|
195
249
|
end
|
|
196
250
|
end
|
|
197
251
|
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Loqate
|
|
2
|
+
module Geocoding
|
|
3
|
+
# A result from the API call to find the nearest places.
|
|
4
|
+
class Place < Dry::Struct::Value
|
|
5
|
+
# The postcode that is nearest to the given location.
|
|
6
|
+
#
|
|
7
|
+
# @return [String]
|
|
8
|
+
#
|
|
9
|
+
attribute :location, Types::Strict::String
|
|
10
|
+
|
|
11
|
+
# The distance in KM from the CentrePoint to this record.
|
|
12
|
+
#
|
|
13
|
+
# @return [Float]
|
|
14
|
+
#
|
|
15
|
+
attribute :distance, Types::Coercible::Float
|
|
16
|
+
|
|
17
|
+
# The WGS84 latitude coordinate of the location.
|
|
18
|
+
#
|
|
19
|
+
# @return [Float]
|
|
20
|
+
#
|
|
21
|
+
attribute :latitude, Types::Coercible::Float
|
|
22
|
+
|
|
23
|
+
# The WGS84 longitude coordinate of the location.
|
|
24
|
+
#
|
|
25
|
+
# @return [Float]
|
|
26
|
+
#
|
|
27
|
+
attribute :longitude, Types::Coercible::Float
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
data/lib/loqate/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: loqate
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Wilson Silva
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-12-
|
|
11
|
+
date: 2018-12-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: dry-struct
|
|
@@ -365,6 +365,7 @@ files:
|
|
|
365
365
|
- lib/loqate/geocoding/direction.rb
|
|
366
366
|
- lib/loqate/geocoding/gateway.rb
|
|
367
367
|
- lib/loqate/geocoding/location.rb
|
|
368
|
+
- lib/loqate/geocoding/place.rb
|
|
368
369
|
- lib/loqate/mappers/error_mapper.rb
|
|
369
370
|
- lib/loqate/mappers/generic_mapper.rb
|
|
370
371
|
- lib/loqate/phone/gateway.rb
|