ideal_postcodes 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +22 -0
  3. data/lib/ideal_postcodes.rb +1 -1
  4. data/lib/idealpostcodes/address.rb +28 -28
  5. data/lib/idealpostcodes/errors.rb +31 -26
  6. data/lib/idealpostcodes/key.rb +12 -11
  7. data/lib/idealpostcodes/postcode.rb +21 -20
  8. data/lib/idealpostcodes/util.rb +38 -25
  9. data/lib/idealpostcodes/version.rb +2 -2
  10. data/lib/idealpostcodes.rb +104 -92
  11. data/spec/addresses_spec.rb +63 -63
  12. data/spec/idealpostcodes_spec.rb +51 -51
  13. data/spec/keys_spec.rb +21 -21
  14. data/spec/postcodes_spec.rb +74 -63
  15. data/spec/spec_helper.rb +50 -29
  16. data/spec/vcr_cassettes/IdealPostcodes_Address_lookup_raises_an_exception_if_invalid_key.yml +39 -39
  17. data/spec/vcr_cassettes/IdealPostcodes_Address_lookup_raises_an_exception_if_limit_breached.yml +39 -39
  18. data/spec/vcr_cassettes/IdealPostcodes_Address_lookup_raises_an_exception_if_no_lookups_remaining.yml +39 -39
  19. data/spec/vcr_cassettes/IdealPostcodes_Address_lookup_returns_an_address_for_a_valid_UDPRN.yml +71 -71
  20. data/spec/vcr_cassettes/IdealPostcodes_Address_lookup_returns_nil_for_an_invalid_UDPRN.yml +39 -39
  21. data/spec/vcr_cassettes/IdealPostcodes_Address_search_is_sensitive_to_limit.yml +78 -78
  22. data/spec/vcr_cassettes/IdealPostcodes_Address_search_is_sensitive_to_page.yml +366 -366
  23. data/spec/vcr_cassettes/IdealPostcodes_Address_search_raises_an_exception_if_invalid_key.yml +39 -39
  24. data/spec/vcr_cassettes/IdealPostcodes_Address_search_raises_an_exception_if_limit_breached.yml +39 -39
  25. data/spec/vcr_cassettes/IdealPostcodes_Address_search_raises_an_exception_if_no_lookups_remaining.yml +39 -39
  26. data/spec/vcr_cassettes/IdealPostcodes_Address_search_returns_results_in_a_SearchResult_object.yml +270 -270
  27. data/spec/vcr_cassettes/IdealPostcodes_Key_lookup_details_returns_key_details.yml +58 -58
  28. data/spec/vcr_cassettes/IdealPostcodes_Key_lookup_returns_the_availability_status_of_a_key_false_key_.yml +42 -42
  29. data/spec/vcr_cassettes/IdealPostcodes_Key_lookup_returns_the_availability_status_of_a_key_true_key_.yml +42 -42
  30. data/spec/vcr_cassettes/IdealPostcodes_Postcode_find_by_location_is_sensitive_to_limit_parameter.yml +49 -49
  31. data/spec/vcr_cassettes/IdealPostcodes_Postcode_find_by_location_is_sensitive_to_radius_parament.yml +130 -130
  32. data/spec/vcr_cassettes/IdealPostcodes_Postcode_find_by_location_returns_an_array_of_postcodes_and_locations.yml +81 -81
  33. data/spec/vcr_cassettes/IdealPostcodes_Postcode_find_by_location_returns_an_empty_array_if_no_results_are_found.yml +40 -40
  34. data/spec/vcr_cassettes/IdealPostcodes_Postcode_lookup_raises_an_exception_if_invalid_key.yml +39 -39
  35. data/spec/vcr_cassettes/IdealPostcodes_Postcode_lookup_raises_an_exception_if_key_has_run_out_of_balance.yml +39 -39
  36. data/spec/vcr_cassettes/IdealPostcodes_Postcode_lookup_raises_an_exception_if_limit_has_been_reached.yml +39 -39
  37. data/spec/vcr_cassettes/IdealPostcodes_Postcode_lookup_returns_a_list_of_addresses_for_a_postcode.yml +265 -265
  38. data/spec/vcr_cassettes/IdealPostcodes_Postcode_lookup_returns_an_empty_array_if_postcode_does_not_exist.yml +39 -39
  39. data/spec/vcr_cassettes/IdealPostcodes_key_available_returns_false_if_key_is_unavailable.yml +42 -42
  40. data/spec/vcr_cassettes/IdealPostcodes_key_available_returns_true_if_key_is_available.yml +42 -42
  41. data/spec/vcr_cassettes/IdealPostcodes_key_details_raises_an_exception_if_no_secret_is_provided.yml +42 -42
  42. data/spec/vcr_cassettes/IdealPostcodes_key_details_returns_key_information.yml +58 -58
  43. data/spec/vcr_cassettes/IdealPostcodes_request_generates_a_HTTP_request.yml +265 -265
  44. data/spec/vcr_cassettes/IdealPostcodes_request_raises_authentication_error_if_invalid_key_is_provided.yml +39 -39
  45. data/spec/vcr_cassettes/IdealPostcodes_request_raises_limit_reached_error_if_a_limit_has_been_breached.yml +39 -39
  46. data/spec/vcr_cassettes/IdealPostcodes_request_raises_token_exhausted_error_if_key_balance_is_depleted.yml +39 -39
  47. metadata +4 -5
  48. data/.travis.yml +0 -9
@@ -1,273 +1,273 @@
1
1
  ---
2
2
  http_interactions:
3
- - request:
4
- method: get
5
- uri: https://localhost:1337/v1/addresses?api_key=gandhi&query=ID1%201QD
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - '*/*; q=0.5, application/xml'
12
- Accept-Encoding:
13
- - gzip, deflate
14
- User-Agent:
15
- - Ruby
16
- response:
17
- status:
18
- code: 200
19
- message: OK
20
- headers:
21
- Access-Control-Allow-Origin:
22
- - '*'
23
- Content-Type:
24
- - application/json; charset=utf-8
25
- Content-Length:
26
- - '7199'
27
- Etag:
28
- - '"-1433768766"'
29
- Date:
30
- - Fri, 12 Dec 2014 17:40:26 GMT
31
- Connection:
32
- - keep-alive
33
- body:
34
- encoding: UTF-8
35
- string: |-
36
- {
37
- "result": {
38
- "total": 7,
39
- "limit": 10,
40
- "page": 0,
41
- "hits": [
42
- {
43
- "postcode": "ID1 1QD",
44
- "postcode_inward": "1QD",
45
- "postcode_outward": "ID1",
46
- "post_town": "LONDON",
47
- "dependant_locality": "",
48
- "double_dependant_locality": "",
49
- "thoroughfare": "Barons Court Road",
50
- "dependant_thoroughfare": "",
51
- "building_number": "2",
52
- "building_name": "",
53
- "sub_building_name": "",
54
- "po_box": "",
55
- "department_name": "",
56
- "organisation_name": "",
57
- "udprn": 25962203,
58
- "postcode_type": "S",
59
- "su_organisation_indicator": "",
60
- "delivery_point_suffix": "1G",
61
- "line_1": "2 Barons Court Road",
62
- "line_2": "",
63
- "line_3": "",
64
- "premise": "2",
65
- "country": "England",
66
- "county": "",
67
- "district": "Hammersmith and Fulham",
68
- "ward": "North End",
69
- "longitude": -0.208644362766368,
70
- "latitude": 51.4899488390558,
71
- "eastings": 524466,
72
- "northings": 178299
73
- },
74
- {
75
- "postcode": "ID1 1QD",
76
- "postcode_inward": "1QD",
77
- "postcode_outward": "ID1",
78
- "post_town": "LONDON",
79
- "dependant_locality": "",
80
- "double_dependant_locality": "",
81
- "thoroughfare": "Barons Court Road",
82
- "dependant_thoroughfare": "",
83
- "building_number": "2",
84
- "building_name": "Basement Flat",
85
- "sub_building_name": "",
86
- "po_box": "",
87
- "department_name": "",
88
- "organisation_name": "",
89
- "udprn": 52618355,
90
- "postcode_type": "S",
91
- "su_organisation_indicator": "",
92
- "delivery_point_suffix": "3A",
93
- "line_1": "Basement Flat",
94
- "line_2": "2 Barons Court Road",
95
- "line_3": "",
96
- "premise": "Basement Flat, 2",
97
- "country": "England",
98
- "county": "",
99
- "district": "Hammersmith and Fulham",
100
- "ward": "North End",
101
- "longitude": -0.208644362766368,
102
- "latitude": 51.4899488390558,
103
- "eastings": 524466,
104
- "northings": 178299
105
- },
106
- {
107
- "postcode": "ID1 1QD",
108
- "postcode_inward": "1QD",
109
- "postcode_outward": "ID1",
110
- "post_town": "LONDON",
111
- "dependant_locality": "",
112
- "double_dependant_locality": "",
113
- "thoroughfare": "Barons Court Road",
114
- "dependant_thoroughfare": "",
115
- "building_number": "4",
116
- "building_name": "",
117
- "sub_building_name": "",
118
- "po_box": "",
119
- "department_name": "",
120
- "organisation_name": "",
121
- "udprn": 25962215,
122
- "postcode_type": "S",
123
- "su_organisation_indicator": "",
124
- "delivery_point_suffix": "1W",
125
- "line_1": "4 Barons Court Road",
126
- "line_2": "",
127
- "line_3": "",
128
- "premise": "4",
129
- "country": "England",
130
- "county": "",
131
- "district": "Hammersmith and Fulham",
132
- "ward": "North End",
133
- "longitude": -0.208644362766368,
134
- "latitude": 51.4899488390558,
135
- "eastings": 524466,
136
- "northings": 178299
137
- },
138
- {
139
- "postcode": "ID1 1QD",
140
- "postcode_inward": "1QD",
141
- "postcode_outward": "ID1",
142
- "post_town": "LONDON",
143
- "dependant_locality": "",
144
- "double_dependant_locality": "",
145
- "thoroughfare": "Barons Court Road",
146
- "dependant_thoroughfare": "",
147
- "building_number": "4",
148
- "building_name": "",
149
- "sub_building_name": "Basement",
150
- "po_box": "",
151
- "department_name": "",
152
- "organisation_name": "",
153
- "udprn": 25962189,
154
- "postcode_type": "S",
155
- "su_organisation_indicator": "",
156
- "delivery_point_suffix": "2P",
157
- "line_1": "Basement",
158
- "line_2": "4 Barons Court Road",
159
- "line_3": "",
160
- "premise": "Basement, 4",
161
- "country": "England",
162
- "county": "",
163
- "district": "Hammersmith and Fulham",
164
- "ward": "North End",
165
- "longitude": -0.208644362766368,
166
- "latitude": 51.4899488390558,
167
- "eastings": 524466,
168
- "northings": 178299
169
- },
170
- {
171
- "postcode": "ID1 1QD",
172
- "postcode_inward": "1QD",
173
- "postcode_outward": "ID1",
174
- "post_town": "LONDON",
175
- "dependant_locality": "",
176
- "double_dependant_locality": "",
177
- "thoroughfare": "Barons Court Road",
178
- "dependant_thoroughfare": "",
179
- "building_number": "6",
180
- "building_name": "",
181
- "sub_building_name": "",
182
- "po_box": "",
183
- "department_name": "",
184
- "organisation_name": "",
185
- "udprn": 25962218,
186
- "postcode_type": "S",
187
- "su_organisation_indicator": "",
188
- "delivery_point_suffix": "1Y",
189
- "line_1": "6 Barons Court Road",
190
- "line_2": "",
191
- "line_3": "",
192
- "premise": "6",
193
- "country": "England",
194
- "county": "",
195
- "district": "Hammersmith and Fulham",
196
- "ward": "North End",
197
- "longitude": -0.208644362766368,
198
- "latitude": 51.4899488390558,
199
- "eastings": 524466,
200
- "northings": 178299
201
- },
202
- {
203
- "postcode": "ID1 1QD",
204
- "postcode_inward": "1QD",
205
- "postcode_outward": "ID1",
206
- "post_town": "LONDON",
207
- "dependant_locality": "",
208
- "double_dependant_locality": "",
209
- "thoroughfare": "Barons Court Road",
210
- "dependant_thoroughfare": "",
211
- "building_number": "8",
212
- "building_name": "",
213
- "sub_building_name": "",
214
- "po_box": "",
215
- "department_name": "",
216
- "organisation_name": "",
217
- "udprn": 25962219,
218
- "postcode_type": "S",
219
- "su_organisation_indicator": "",
220
- "delivery_point_suffix": "1Z",
221
- "line_1": "8 Barons Court Road",
222
- "line_2": "",
223
- "line_3": "",
224
- "premise": "8",
225
- "country": "England",
226
- "county": "",
227
- "district": "Hammersmith and Fulham",
228
- "ward": "North End",
229
- "longitude": -0.208644362766368,
230
- "latitude": 51.4899488390558,
231
- "eastings": 524466,
232
- "northings": 178299
233
- },
234
- {
235
- "postcode": "ID1 1QD",
236
- "postcode_inward": "1QD",
237
- "postcode_outward": "ID1",
238
- "post_town": "LONDON",
239
- "dependant_locality": "",
240
- "double_dependant_locality": "",
241
- "thoroughfare": "Barons Court Road",
242
- "dependant_thoroughfare": "",
243
- "building_number": "59",
244
- "building_name": "",
245
- "sub_building_name": "",
246
- "po_box": "",
247
- "department_name": "",
248
- "organisation_name": "ID Consulting Limited",
249
- "udprn": 25946509,
250
- "postcode_type": "S",
251
- "su_organisation_indicator": "Y",
252
- "delivery_point_suffix": "1N",
253
- "line_1": "ID Consulting Limited",
254
- "line_2": "59 Barons Court Road",
255
- "line_3": "",
256
- "premise": "59",
257
- "country": "England",
258
- "county": "",
259
- "district": "Hammersmith and Fulham",
260
- "ward": "North End",
261
- "longitude": -0.208644362766368,
262
- "latitude": 51.4899488390558,
263
- "eastings": 524466,
264
- "northings": 178299
265
- }
266
- ]
267
- },
268
- "code": 2000,
269
- "message": "Success"
270
- }
271
- http_version:
272
- recorded_at: Fri, 12 Dec 2014 17:40:26 GMT
3
+ - request:
4
+ method: get
5
+ uri: https://localhost:1337/v1/addresses?api_key=gandhi&query=ID1%201QD
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ""
9
+ headers:
10
+ Accept:
11
+ - "*/*; q=0.5, application/xml"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Access-Control-Allow-Origin:
22
+ - "*"
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ Content-Length:
26
+ - "7199"
27
+ Etag:
28
+ - '"-1433768766"'
29
+ Date:
30
+ - Fri, 12 Dec 2014 17:40:26 GMT
31
+ Connection:
32
+ - keep-alive
33
+ body:
34
+ encoding: UTF-8
35
+ string: |-
36
+ {
37
+ "result": {
38
+ "total": 7,
39
+ "limit": 10,
40
+ "page": 0,
41
+ "hits": [
42
+ {
43
+ "postcode": "ID1 1QD",
44
+ "postcode_inward": "1QD",
45
+ "postcode_outward": "ID1",
46
+ "post_town": "LONDON",
47
+ "dependant_locality": "",
48
+ "double_dependant_locality": "",
49
+ "thoroughfare": "Barons Court Road",
50
+ "dependant_thoroughfare": "",
51
+ "building_number": "2",
52
+ "building_name": "",
53
+ "sub_building_name": "",
54
+ "po_box": "",
55
+ "department_name": "",
56
+ "organisation_name": "",
57
+ "udprn": 25962203,
58
+ "postcode_type": "S",
59
+ "su_organisation_indicator": "",
60
+ "delivery_point_suffix": "1G",
61
+ "line_1": "2 Barons Court Road",
62
+ "line_2": "",
63
+ "line_3": "",
64
+ "premise": "2",
65
+ "country": "England",
66
+ "county": "",
67
+ "district": "Hammersmith and Fulham",
68
+ "ward": "North End",
69
+ "longitude": -0.208644362766368,
70
+ "latitude": 51.4899488390558,
71
+ "eastings": 524466,
72
+ "northings": 178299
73
+ },
74
+ {
75
+ "postcode": "ID1 1QD",
76
+ "postcode_inward": "1QD",
77
+ "postcode_outward": "ID1",
78
+ "post_town": "LONDON",
79
+ "dependant_locality": "",
80
+ "double_dependant_locality": "",
81
+ "thoroughfare": "Barons Court Road",
82
+ "dependant_thoroughfare": "",
83
+ "building_number": "2",
84
+ "building_name": "Basement Flat",
85
+ "sub_building_name": "",
86
+ "po_box": "",
87
+ "department_name": "",
88
+ "organisation_name": "",
89
+ "udprn": 52618355,
90
+ "postcode_type": "S",
91
+ "su_organisation_indicator": "",
92
+ "delivery_point_suffix": "3A",
93
+ "line_1": "Basement Flat",
94
+ "line_2": "2 Barons Court Road",
95
+ "line_3": "",
96
+ "premise": "Basement Flat, 2",
97
+ "country": "England",
98
+ "county": "",
99
+ "district": "Hammersmith and Fulham",
100
+ "ward": "North End",
101
+ "longitude": -0.208644362766368,
102
+ "latitude": 51.4899488390558,
103
+ "eastings": 524466,
104
+ "northings": 178299
105
+ },
106
+ {
107
+ "postcode": "ID1 1QD",
108
+ "postcode_inward": "1QD",
109
+ "postcode_outward": "ID1",
110
+ "post_town": "LONDON",
111
+ "dependant_locality": "",
112
+ "double_dependant_locality": "",
113
+ "thoroughfare": "Barons Court Road",
114
+ "dependant_thoroughfare": "",
115
+ "building_number": "4",
116
+ "building_name": "",
117
+ "sub_building_name": "",
118
+ "po_box": "",
119
+ "department_name": "",
120
+ "organisation_name": "",
121
+ "udprn": 25962215,
122
+ "postcode_type": "S",
123
+ "su_organisation_indicator": "",
124
+ "delivery_point_suffix": "1W",
125
+ "line_1": "4 Barons Court Road",
126
+ "line_2": "",
127
+ "line_3": "",
128
+ "premise": "4",
129
+ "country": "England",
130
+ "county": "",
131
+ "district": "Hammersmith and Fulham",
132
+ "ward": "North End",
133
+ "longitude": -0.208644362766368,
134
+ "latitude": 51.4899488390558,
135
+ "eastings": 524466,
136
+ "northings": 178299
137
+ },
138
+ {
139
+ "postcode": "ID1 1QD",
140
+ "postcode_inward": "1QD",
141
+ "postcode_outward": "ID1",
142
+ "post_town": "LONDON",
143
+ "dependant_locality": "",
144
+ "double_dependant_locality": "",
145
+ "thoroughfare": "Barons Court Road",
146
+ "dependant_thoroughfare": "",
147
+ "building_number": "4",
148
+ "building_name": "",
149
+ "sub_building_name": "Basement",
150
+ "po_box": "",
151
+ "department_name": "",
152
+ "organisation_name": "",
153
+ "udprn": 25962189,
154
+ "postcode_type": "S",
155
+ "su_organisation_indicator": "",
156
+ "delivery_point_suffix": "2P",
157
+ "line_1": "Basement",
158
+ "line_2": "4 Barons Court Road",
159
+ "line_3": "",
160
+ "premise": "Basement, 4",
161
+ "country": "England",
162
+ "county": "",
163
+ "district": "Hammersmith and Fulham",
164
+ "ward": "North End",
165
+ "longitude": -0.208644362766368,
166
+ "latitude": 51.4899488390558,
167
+ "eastings": 524466,
168
+ "northings": 178299
169
+ },
170
+ {
171
+ "postcode": "ID1 1QD",
172
+ "postcode_inward": "1QD",
173
+ "postcode_outward": "ID1",
174
+ "post_town": "LONDON",
175
+ "dependant_locality": "",
176
+ "double_dependant_locality": "",
177
+ "thoroughfare": "Barons Court Road",
178
+ "dependant_thoroughfare": "",
179
+ "building_number": "6",
180
+ "building_name": "",
181
+ "sub_building_name": "",
182
+ "po_box": "",
183
+ "department_name": "",
184
+ "organisation_name": "",
185
+ "udprn": 25962218,
186
+ "postcode_type": "S",
187
+ "su_organisation_indicator": "",
188
+ "delivery_point_suffix": "1Y",
189
+ "line_1": "6 Barons Court Road",
190
+ "line_2": "",
191
+ "line_3": "",
192
+ "premise": "6",
193
+ "country": "England",
194
+ "county": "",
195
+ "district": "Hammersmith and Fulham",
196
+ "ward": "North End",
197
+ "longitude": -0.208644362766368,
198
+ "latitude": 51.4899488390558,
199
+ "eastings": 524466,
200
+ "northings": 178299
201
+ },
202
+ {
203
+ "postcode": "ID1 1QD",
204
+ "postcode_inward": "1QD",
205
+ "postcode_outward": "ID1",
206
+ "post_town": "LONDON",
207
+ "dependant_locality": "",
208
+ "double_dependant_locality": "",
209
+ "thoroughfare": "Barons Court Road",
210
+ "dependant_thoroughfare": "",
211
+ "building_number": "8",
212
+ "building_name": "",
213
+ "sub_building_name": "",
214
+ "po_box": "",
215
+ "department_name": "",
216
+ "organisation_name": "",
217
+ "udprn": 25962219,
218
+ "postcode_type": "S",
219
+ "su_organisation_indicator": "",
220
+ "delivery_point_suffix": "1Z",
221
+ "line_1": "8 Barons Court Road",
222
+ "line_2": "",
223
+ "line_3": "",
224
+ "premise": "8",
225
+ "country": "England",
226
+ "county": "",
227
+ "district": "Hammersmith and Fulham",
228
+ "ward": "North End",
229
+ "longitude": -0.208644362766368,
230
+ "latitude": 51.4899488390558,
231
+ "eastings": 524466,
232
+ "northings": 178299
233
+ },
234
+ {
235
+ "postcode": "ID1 1QD",
236
+ "postcode_inward": "1QD",
237
+ "postcode_outward": "ID1",
238
+ "post_town": "LONDON",
239
+ "dependant_locality": "",
240
+ "double_dependant_locality": "",
241
+ "thoroughfare": "Barons Court Road",
242
+ "dependant_thoroughfare": "",
243
+ "building_number": "59",
244
+ "building_name": "",
245
+ "sub_building_name": "",
246
+ "po_box": "",
247
+ "department_name": "",
248
+ "organisation_name": "ID Consulting Limited",
249
+ "udprn": 25946509,
250
+ "postcode_type": "S",
251
+ "su_organisation_indicator": "Y",
252
+ "delivery_point_suffix": "1N",
253
+ "line_1": "ID Consulting Limited",
254
+ "line_2": "59 Barons Court Road",
255
+ "line_3": "",
256
+ "premise": "59",
257
+ "country": "England",
258
+ "county": "",
259
+ "district": "Hammersmith and Fulham",
260
+ "ward": "North End",
261
+ "longitude": -0.208644362766368,
262
+ "latitude": 51.4899488390558,
263
+ "eastings": 524466,
264
+ "northings": 178299
265
+ }
266
+ ]
267
+ },
268
+ "code": 2000,
269
+ "message": "Success"
270
+ }
271
+ http_version:
272
+ recorded_at: Fri, 12 Dec 2014 17:40:26 GMT
273
273
  recorded_with: VCR 2.9.3