ideal_postcodes 2.0.0 → 3.0.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.
Files changed (223) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +3 -16
  3. data/LICENSE +1 -21
  4. data/README.md +13 -332
  5. data/lib/ideal_postcodes/base_client.rb +88 -0
  6. data/lib/ideal_postcodes/client.rb +42 -0
  7. data/lib/ideal_postcodes/errors.rb +59 -0
  8. data/lib/ideal_postcodes/generated.rb +83 -0
  9. data/lib/ideal_postcodes/model.rb +73 -0
  10. data/lib/ideal_postcodes/operations.rb +866 -0
  11. data/lib/ideal_postcodes/responses/address_response.rb +19 -0
  12. data/lib/ideal_postcodes/responses/api_key_details_response.rb +21 -0
  13. data/lib/ideal_postcodes/responses/api_key_response.rb +21 -0
  14. data/lib/ideal_postcodes/responses/api_key_usage_response.rb +21 -0
  15. data/lib/ideal_postcodes/responses/autocomplete_response.rb +19 -0
  16. data/lib/ideal_postcodes/responses/cleanse_response.rb +31 -0
  17. data/lib/ideal_postcodes/responses/config_response.rb +21 -0
  18. data/lib/ideal_postcodes/responses/configs_response.rb +21 -0
  19. data/lib/ideal_postcodes/responses/delete_config_response.rb +19 -0
  20. data/lib/ideal_postcodes/responses/delete_licensee_response.rb +19 -0
  21. data/lib/ideal_postcodes/responses/email_response.rb +31 -0
  22. data/lib/ideal_postcodes/responses/gbr_resolve_address_response.rb +21 -0
  23. data/lib/ideal_postcodes/responses/licensee_response.rb +21 -0
  24. data/lib/ideal_postcodes/responses/licensees_response.rb +21 -0
  25. data/lib/ideal_postcodes/responses/phone_number_response.rb +31 -0
  26. data/lib/ideal_postcodes/responses/place_response.rb +19 -0
  27. data/lib/ideal_postcodes/responses/postcode_response.rb +30 -0
  28. data/lib/ideal_postcodes/responses/resolve_place_response.rb +24 -0
  29. data/lib/ideal_postcodes/transport.rb +61 -0
  30. data/lib/ideal_postcodes/types/ab_address.rb +283 -0
  31. data/lib/ideal_postcodes/types/abp_address.rb +674 -0
  32. data/lib/ideal_postcodes/types/address.rb +290 -0
  33. data/lib/ideal_postcodes/types/address_list_item.rb +592 -0
  34. data/lib/ideal_postcodes/types/address_result.rb +24 -0
  35. data/lib/ideal_postcodes/types/address_suggestion.rb +27 -0
  36. data/lib/ideal_postcodes/types/api_key.rb +27 -0
  37. data/lib/ideal_postcodes/types/api_key_automated_topup.rb +17 -0
  38. data/lib/ideal_postcodes/types/api_key_current_purchase.rb +27 -0
  39. data/lib/ideal_postcodes/types/api_key_daily_limit.rb +21 -0
  40. data/lib/ideal_postcodes/types/api_key_datasets.rb +202 -0
  41. data/lib/ideal_postcodes/types/api_key_details.rb +90 -0
  42. data/lib/ideal_postcodes/types/api_key_individual_limit.rb +16 -0
  43. data/lib/ideal_postcodes/types/api_key_monthly_limit.rb +21 -0
  44. data/lib/ideal_postcodes/types/api_key_notifications.rb +35 -0
  45. data/lib/ideal_postcodes/types/autocomplete_result.rb +25 -0
  46. data/lib/ideal_postcodes/types/available_context.rb +35 -0
  47. data/lib/ideal_postcodes/types/ban_address.rb +179 -0
  48. data/lib/ideal_postcodes/types/bev_address.rb +288 -0
  49. data/lib/ideal_postcodes/types/cannar_address.rb +297 -0
  50. data/lib/ideal_postcodes/types/carrier.rb +31 -0
  51. data/lib/ideal_postcodes/types/config.rb +34 -0
  52. data/lib/ideal_postcodes/types/configs_result.rb +15 -0
  53. data/lib/ideal_postcodes/types/deleted_config.rb +13 -0
  54. data/lib/ideal_postcodes/types/deleted_licensee.rb +13 -0
  55. data/lib/ideal_postcodes/types/ecad_address.rb +393 -0
  56. data/lib/ideal_postcodes/types/ecaf_address.rb +204 -0
  57. data/lib/ideal_postcodes/types/email.rb +45 -0
  58. data/lib/ideal_postcodes/types/fodbosa_address.rb +201 -0
  59. data/lib/ideal_postcodes/types/gbr_cleanse_match.rb +70 -0
  60. data/lib/ideal_postcodes/types/gbr_cleanse_no_match.rb +47 -0
  61. data/lib/ideal_postcodes/types/geonames_place.rb +153 -0
  62. data/lib/ideal_postcodes/types/gnaf_address.rb +463 -0
  63. data/lib/ideal_postcodes/types/here_address.rb +174 -0
  64. data/lib/ideal_postcodes/types/invalid_phone_number.rb +50 -0
  65. data/lib/ideal_postcodes/types/kadaster_address.rb +480 -0
  66. data/lib/ideal_postcodes/types/kartverket_address.rb +342 -0
  67. data/lib/ideal_postcodes/types/key_usage_day.rb +16 -0
  68. data/lib/ideal_postcodes/types/key_usage_result.rb +36 -0
  69. data/lib/ideal_postcodes/types/licensee.rb +50 -0
  70. data/lib/ideal_postcodes/types/licensee_daily_usage.rb +29 -0
  71. data/lib/ideal_postcodes/types/licensees_result.rb +23 -0
  72. data/lib/ideal_postcodes/types/mois_address.rb +440 -0
  73. data/lib/ideal_postcodes/types/mr_address.rb +99 -0
  74. data/lib/ideal_postcodes/types/native_record.rb +368 -0
  75. data/lib/ideal_postcodes/types/nyb_address.rb +99 -0
  76. data/lib/ideal_postcodes/types/paf_address.rb +96 -0
  77. data/lib/ideal_postcodes/types/pafa_address.rb +104 -0
  78. data/lib/ideal_postcodes/types/pafw_address.rb +99 -0
  79. data/lib/ideal_postcodes/types/phone_number.rb +50 -0
  80. data/lib/ideal_postcodes/types/place.rb +79 -0
  81. data/lib/ideal_postcodes/types/place_result.rb +21 -0
  82. data/lib/ideal_postcodes/types/place_suggestion.rb +32 -0
  83. data/lib/ideal_postcodes/types/sdfi_address.rb +520 -0
  84. data/lib/ideal_postcodes/types/swt_address.rb +247 -0
  85. data/lib/ideal_postcodes/types/uk_address_suggestion.rb +45 -0
  86. data/lib/ideal_postcodes/types/uk_address_suggestion_urls.rb +21 -0
  87. data/lib/ideal_postcodes/types/unknown_email.rb +43 -0
  88. data/lib/ideal_postcodes/types/upujp_address.rb +763 -0
  89. data/lib/ideal_postcodes/types/usps_address.rb +294 -0
  90. data/lib/ideal_postcodes/version.rb +5 -0
  91. data/lib/ideal_postcodes.rb +14 -2
  92. data/sig/ideal_postcodes/base_client.rbs +40 -0
  93. data/sig/ideal_postcodes/client.rbs +35 -0
  94. data/sig/ideal_postcodes/errors.rbs +27 -0
  95. data/sig/ideal_postcodes/model.rbs +37 -0
  96. data/sig/ideal_postcodes/operations.rbs +207 -0
  97. data/sig/ideal_postcodes/responses/address_response.rbs +13 -0
  98. data/sig/ideal_postcodes/responses/api_key_details_response.rbs +13 -0
  99. data/sig/ideal_postcodes/responses/api_key_response.rbs +13 -0
  100. data/sig/ideal_postcodes/responses/api_key_usage_response.rbs +13 -0
  101. data/sig/ideal_postcodes/responses/autocomplete_response.rbs +13 -0
  102. data/sig/ideal_postcodes/responses/cleanse_response.rbs +19 -0
  103. data/sig/ideal_postcodes/responses/config_response.rbs +13 -0
  104. data/sig/ideal_postcodes/responses/configs_response.rbs +13 -0
  105. data/sig/ideal_postcodes/responses/delete_config_response.rbs +13 -0
  106. data/sig/ideal_postcodes/responses/delete_licensee_response.rbs +13 -0
  107. data/sig/ideal_postcodes/responses/email_response.rbs +19 -0
  108. data/sig/ideal_postcodes/responses/gbr_resolve_address_response.rbs +13 -0
  109. data/sig/ideal_postcodes/responses/licensee_response.rbs +13 -0
  110. data/sig/ideal_postcodes/responses/licensees_response.rbs +13 -0
  111. data/sig/ideal_postcodes/responses/phone_number_response.rbs +19 -0
  112. data/sig/ideal_postcodes/responses/place_response.rbs +13 -0
  113. data/sig/ideal_postcodes/responses/postcode_response.rbs +16 -0
  114. data/sig/ideal_postcodes/responses/resolve_place_response.rbs +13 -0
  115. data/sig/ideal_postcodes/transport.rbs +39 -0
  116. data/sig/ideal_postcodes/types/ab_address.rbs +57 -0
  117. data/sig/ideal_postcodes/types/abp_address.rbs +126 -0
  118. data/sig/ideal_postcodes/types/address.rbs +136 -0
  119. data/sig/ideal_postcodes/types/address_list_item.rbs +160 -0
  120. data/sig/ideal_postcodes/types/address_result.rbs +12 -0
  121. data/sig/ideal_postcodes/types/address_suggestion.rbs +11 -0
  122. data/sig/ideal_postcodes/types/api_key.rbs +11 -0
  123. data/sig/ideal_postcodes/types/api_key_automated_topup.rbs +9 -0
  124. data/sig/ideal_postcodes/types/api_key_current_purchase.rbs +11 -0
  125. data/sig/ideal_postcodes/types/api_key_daily_limit.rbs +10 -0
  126. data/sig/ideal_postcodes/types/api_key_datasets.rbs +46 -0
  127. data/sig/ideal_postcodes/types/api_key_details.rbs +22 -0
  128. data/sig/ideal_postcodes/types/api_key_individual_limit.rbs +9 -0
  129. data/sig/ideal_postcodes/types/api_key_monthly_limit.rbs +10 -0
  130. data/sig/ideal_postcodes/types/api_key_notifications.rbs +13 -0
  131. data/sig/ideal_postcodes/types/autocomplete_result.rbs +15 -0
  132. data/sig/ideal_postcodes/types/available_context.rbs +13 -0
  133. data/sig/ideal_postcodes/types/ban_address.rbs +46 -0
  134. data/sig/ideal_postcodes/types/bev_address.rbs +67 -0
  135. data/sig/ideal_postcodes/types/cannar_address.rbs +62 -0
  136. data/sig/ideal_postcodes/types/carrier.rbs +14 -0
  137. data/sig/ideal_postcodes/types/config.rbs +14 -0
  138. data/sig/ideal_postcodes/types/configs_result.rbs +9 -0
  139. data/sig/ideal_postcodes/types/deleted_config.rbs +9 -0
  140. data/sig/ideal_postcodes/types/deleted_licensee.rbs +9 -0
  141. data/sig/ideal_postcodes/types/ecad_address.rbs +84 -0
  142. data/sig/ideal_postcodes/types/ecaf_address.rbs +45 -0
  143. data/sig/ideal_postcodes/types/email.rbs +16 -0
  144. data/sig/ideal_postcodes/types/fodbosa_address.rbs +43 -0
  145. data/sig/ideal_postcodes/types/gbr_cleanse_match.rbs +25 -0
  146. data/sig/ideal_postcodes/types/gbr_cleanse_no_match.rbs +28 -0
  147. data/sig/ideal_postcodes/types/geonames_place.rbs +42 -0
  148. data/sig/ideal_postcodes/types/gnaf_address.rbs +104 -0
  149. data/sig/ideal_postcodes/types/here_address.rbs +37 -0
  150. data/sig/ideal_postcodes/types/invalid_phone_number.rbs +17 -0
  151. data/sig/ideal_postcodes/types/kadaster_address.rbs +98 -0
  152. data/sig/ideal_postcodes/types/kartverket_address.rbs +78 -0
  153. data/sig/ideal_postcodes/types/key_usage_day.rbs +10 -0
  154. data/sig/ideal_postcodes/types/key_usage_result.rbs +13 -0
  155. data/sig/ideal_postcodes/types/licensee.rbs +17 -0
  156. data/sig/ideal_postcodes/types/licensee_daily_usage.rbs +12 -0
  157. data/sig/ideal_postcodes/types/licensees_result.rbs +11 -0
  158. data/sig/ideal_postcodes/types/mois_address.rbs +97 -0
  159. data/sig/ideal_postcodes/types/mr_address.rbs +27 -0
  160. data/sig/ideal_postcodes/types/native_record.rbs +34 -0
  161. data/sig/ideal_postcodes/types/nyb_address.rbs +27 -0
  162. data/sig/ideal_postcodes/types/paf_address.rbs +27 -0
  163. data/sig/ideal_postcodes/types/pafa_address.rbs +27 -0
  164. data/sig/ideal_postcodes/types/pafw_address.rbs +27 -0
  165. data/sig/ideal_postcodes/types/phone_number.rbs +17 -0
  166. data/sig/ideal_postcodes/types/place.rbs +29 -0
  167. data/sig/ideal_postcodes/types/place_result.rbs +15 -0
  168. data/sig/ideal_postcodes/types/place_suggestion.rbs +12 -0
  169. data/sig/ideal_postcodes/types/sdfi_address.rbs +108 -0
  170. data/sig/ideal_postcodes/types/swt_address.rbs +57 -0
  171. data/sig/ideal_postcodes/types/uk_address_suggestion.rbs +13 -0
  172. data/sig/ideal_postcodes/types/uk_address_suggestion_urls.rbs +10 -0
  173. data/sig/ideal_postcodes/types/unknown_email.rbs +16 -0
  174. data/sig/ideal_postcodes/types/upujp_address.rbs +156 -0
  175. data/sig/ideal_postcodes/types/usps_address.rbs +63 -0
  176. metadata +186 -175
  177. data/.travis.yml +0 -9
  178. data/Gemfile +0 -2
  179. data/Rakefile +0 -15
  180. data/ideal-postcodes-ruby.gemspec +0 -25
  181. data/lib/idealpostcodes/address.rb +0 -31
  182. data/lib/idealpostcodes/errors.rb +0 -33
  183. data/lib/idealpostcodes/key.rb +0 -13
  184. data/lib/idealpostcodes/postcode.rb +0 -22
  185. data/lib/idealpostcodes/util.rb +0 -29
  186. data/lib/idealpostcodes/version.rb +0 -3
  187. data/lib/idealpostcodes.rb +0 -112
  188. data/spec/addresses_spec.rb +0 -68
  189. data/spec/idealpostcodes_spec.rb +0 -56
  190. data/spec/keys_spec.rb +0 -25
  191. data/spec/postcodes_spec.rb +0 -66
  192. data/spec/spec_helper.rb +0 -68
  193. data/spec/vcr_cassettes/IdealPostcodes_Address_lookup_raises_an_exception_if_invalid_key.yml +0 -42
  194. data/spec/vcr_cassettes/IdealPostcodes_Address_lookup_raises_an_exception_if_limit_breached.yml +0 -42
  195. data/spec/vcr_cassettes/IdealPostcodes_Address_lookup_raises_an_exception_if_no_lookups_remaining.yml +0 -42
  196. data/spec/vcr_cassettes/IdealPostcodes_Address_lookup_returns_an_address_for_a_valid_UDPRN.yml +0 -74
  197. data/spec/vcr_cassettes/IdealPostcodes_Address_lookup_returns_nil_for_an_invalid_UDPRN.yml +0 -42
  198. data/spec/vcr_cassettes/IdealPostcodes_Address_search_is_sensitive_to_limit.yml +0 -81
  199. data/spec/vcr_cassettes/IdealPostcodes_Address_search_is_sensitive_to_page.yml +0 -369
  200. data/spec/vcr_cassettes/IdealPostcodes_Address_search_raises_an_exception_if_invalid_key.yml +0 -42
  201. data/spec/vcr_cassettes/IdealPostcodes_Address_search_raises_an_exception_if_limit_breached.yml +0 -42
  202. data/spec/vcr_cassettes/IdealPostcodes_Address_search_raises_an_exception_if_no_lookups_remaining.yml +0 -42
  203. data/spec/vcr_cassettes/IdealPostcodes_Address_search_returns_results_in_a_SearchResult_object.yml +0 -273
  204. data/spec/vcr_cassettes/IdealPostcodes_Key_lookup_details_returns_key_details.yml +0 -62
  205. data/spec/vcr_cassettes/IdealPostcodes_Key_lookup_returns_the_availability_status_of_a_key_false_key_.yml +0 -45
  206. data/spec/vcr_cassettes/IdealPostcodes_Key_lookup_returns_the_availability_status_of_a_key_true_key_.yml +0 -45
  207. data/spec/vcr_cassettes/IdealPostcodes_Postcode_find_by_location_is_sensitive_to_limit_parameter.yml +0 -52
  208. data/spec/vcr_cassettes/IdealPostcodes_Postcode_find_by_location_is_sensitive_to_radius_parament.yml +0 -133
  209. data/spec/vcr_cassettes/IdealPostcodes_Postcode_find_by_location_returns_an_array_of_postcodes_and_locations.yml +0 -84
  210. data/spec/vcr_cassettes/IdealPostcodes_Postcode_find_by_location_returns_an_empty_array_if_no_results_are_found.yml +0 -43
  211. data/spec/vcr_cassettes/IdealPostcodes_Postcode_lookup_raises_an_exception_if_invalid_key.yml +0 -42
  212. data/spec/vcr_cassettes/IdealPostcodes_Postcode_lookup_raises_an_exception_if_key_has_run_out_of_balance.yml +0 -42
  213. data/spec/vcr_cassettes/IdealPostcodes_Postcode_lookup_raises_an_exception_if_limit_has_been_reached.yml +0 -42
  214. data/spec/vcr_cassettes/IdealPostcodes_Postcode_lookup_returns_a_list_of_addresses_for_a_postcode.yml +0 -268
  215. data/spec/vcr_cassettes/IdealPostcodes_Postcode_lookup_returns_an_empty_array_if_postcode_does_not_exist.yml +0 -42
  216. data/spec/vcr_cassettes/IdealPostcodes_key_available_returns_false_if_key_is_unavailable.yml +0 -45
  217. data/spec/vcr_cassettes/IdealPostcodes_key_available_returns_true_if_key_is_available.yml +0 -45
  218. data/spec/vcr_cassettes/IdealPostcodes_key_details_raises_an_exception_if_no_secret_is_provided.yml +0 -45
  219. data/spec/vcr_cassettes/IdealPostcodes_key_details_returns_key_information.yml +0 -62
  220. data/spec/vcr_cassettes/IdealPostcodes_request_generates_a_HTTP_request.yml +0 -268
  221. data/spec/vcr_cassettes/IdealPostcodes_request_raises_authentication_error_if_invalid_key_is_provided.yml +0 -42
  222. data/spec/vcr_cassettes/IdealPostcodes_request_raises_limit_reached_error_if_a_limit_has_been_breached.yml +0 -42
  223. data/spec/vcr_cassettes/IdealPostcodes_request_raises_token_exhausted_error_if_key_balance_is_depleted.yml +0 -42
@@ -0,0 +1,866 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated from the OpenAPI spec. Do not edit.
4
+
5
+ module IdealPostcodes
6
+ # One method per API operation, named from its `operationId`. Client includes it.
7
+ #
8
+ # Path parameters are positional; query parameters and body properties are
9
+ # keyword arguments. A keyword left nil is not sent.
10
+ module Operations
11
+ # Lookup Postcode.
12
+ #
13
+ # Returns the complete list of addresses for a postcode. Postcode searches are space and case
14
+ # insensitive.
15
+ #
16
+ # @param postcode [String] Postcode to retrieve
17
+ # @param filter [String, Array<String>] Restrict Result Fields
18
+ # @param page [Integer] Page
19
+ # @param tags [String, Array<String>] Tags
20
+ # @param remove_organisation [String] Remove Organisation
21
+ # @param dataset [Array<String>] Filter by Dataset
22
+ # @param context [String] Context
23
+ # @return [Responses::PostcodeResponse]
24
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/postcodes
25
+ def postcodes(
26
+ postcode,
27
+ filter: nil,
28
+ page: nil,
29
+ tags: nil,
30
+ remove_organisation: nil,
31
+ dataset: nil,
32
+ context: nil
33
+ )
34
+ request(
35
+ "GET",
36
+ "/postcodes/{postcode}",
37
+ :api_key,
38
+ path: { "postcode" => postcode },
39
+ query: {
40
+ "filter" => filter,
41
+ "page" => page,
42
+ "tags" => tags,
43
+ "remove_organisation" => remove_organisation,
44
+ "dataset" => dataset,
45
+ "context" => context
46
+ },
47
+ response: Responses::PostcodeResponse
48
+ )
49
+ end
50
+
51
+ # Availability.
52
+ #
53
+ # Returns public information on an API Key: whether it can be used right now (`available`), the
54
+ # search contexts the key is licensed for (`contexts`) and the context that best matches the
55
+ # caller's IP address (`context`).
56
+ #
57
+ # @param key [String] API Key
58
+ # @return [Responses::ApiKeyResponse]
59
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/key-availability
60
+ def key_availability(key)
61
+ request(
62
+ "GET",
63
+ "/keys/{key}",
64
+ :none,
65
+ path: { "key" => key },
66
+ response: Responses::ApiKeyResponse
67
+ )
68
+ end
69
+
70
+ # Details.
71
+ #
72
+ # Returns private data on a key: remaining lookups, licensed datasets, usage limits,
73
+ # notification settings and the search contexts the key can serve.
74
+ #
75
+ # Needs the Management Key.
76
+ #
77
+ # @param key [String] API Key
78
+ # @return [Responses::ApiKeyDetailsResponse]
79
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/key-details
80
+ def key_details(key)
81
+ request(
82
+ "GET",
83
+ "/keys/{key}/details",
84
+ :management_key,
85
+ path: { "key" => key },
86
+ response: Responses::ApiKeyDetailsResponse
87
+ )
88
+ end
89
+
90
+ # Update Details.
91
+ #
92
+ # Updates a key's settings and returns its private details. Only the fields you send change. A
93
+ # key on an unlimited plan ignores changes to `datasets`, `daily_limit` and `monthly_limit`.
94
+ # Datasets set by your plan cannot be changed here: sending one with a different value returns a
95
+ # 400.
96
+ #
97
+ # Needs the Management Key.
98
+ #
99
+ # @param key [String] API Key
100
+ # @param name [String] A name for the key
101
+ # @param daily_limit [Hash]
102
+ # @param monthly_limit [Hash]
103
+ # @param individual_limit [Hash]
104
+ # @param allowed_urls [Array<String>] A list of allowed URLs. An empty list disables the check.
105
+ # Up to 10 allowed.
106
+ # @param redact_days [Integer] Number of days to preserve personal data stored in your key usage
107
+ # history. Set to 0 to prevent personal data storage
108
+ # @param notifications [Hash]
109
+ # @param ip_forwarding [Boolean] Accept IP addresses forwarded in the `IDPC-Source-IP` header
110
+ # @param datasets [Hash] Datasets you can switch on or off for this key. Datasets set by your
111
+ # plan (`paf`, `mr`, `nyb`, `ecad`, `ecaf`) cannot be changed here: sending one with a
112
+ # different value returns a 400.
113
+ # @return [Responses::ApiKeyDetailsResponse]
114
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/update-key-details
115
+ def update_key_details(
116
+ key,
117
+ name: nil,
118
+ daily_limit: nil,
119
+ monthly_limit: nil,
120
+ individual_limit: nil,
121
+ allowed_urls: nil,
122
+ redact_days: nil,
123
+ notifications: nil,
124
+ ip_forwarding: nil,
125
+ datasets: nil
126
+ )
127
+ request(
128
+ "PUT",
129
+ "/keys/{key}/details",
130
+ :management_key,
131
+ path: { "key" => key },
132
+ body: {
133
+ "name" => name,
134
+ "daily_limit" => daily_limit,
135
+ "monthly_limit" => monthly_limit,
136
+ "individual_limit" => individual_limit,
137
+ "allowed_urls" => allowed_urls,
138
+ "redact_days" => redact_days,
139
+ "notifications" => notifications,
140
+ "ip_forwarding" => ip_forwarding,
141
+ "datasets" => datasets
142
+ },
143
+ response: Responses::ApiKeyDetailsResponse
144
+ )
145
+ end
146
+
147
+ # Usage Stats.
148
+ #
149
+ # Reports the number of lookups a key consumed over a date range, as a total and a daily
150
+ # breakdown.
151
+ #
152
+ # Needs the Management Key.
153
+ #
154
+ # @param key [String] API Key
155
+ # @param start [Integer] Start Timestamp
156
+ # @param end [Integer] End Timestamp
157
+ # @param tags [String, Array<String>] Tags
158
+ # @param licensee [String] Licensee Key
159
+ # @return [Responses::ApiKeyUsageResponse]
160
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/key-usage
161
+ def key_usage(key, start: nil, end: nil, tags: nil, licensee: nil)
162
+ request(
163
+ "GET",
164
+ "/keys/{key}/usage",
165
+ :management_key,
166
+ path: { "key" => key },
167
+ query: {
168
+ "start" => start,
169
+ "end" => binding.local_variable_get(:end),
170
+ "tags" => tags,
171
+ "licensee" => licensee
172
+ },
173
+ response: Responses::ApiKeyUsageResponse
174
+ )
175
+ end
176
+
177
+ # Logs (CSV).
178
+ #
179
+ # Returns a CSV of the paid lookups made on a key, with the information recorded against each
180
+ # one.
181
+ #
182
+ # Needs the Management Key.
183
+ #
184
+ # @param key [String] API Key
185
+ # @param start [Integer] Start Timestamp
186
+ # @param end [Integer] End Timestamp
187
+ # @param licensee [String] Licensee Key
188
+ # @return [String]
189
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/key-logs
190
+ def key_logs(key, start: nil, end: nil, licensee: nil)
191
+ request(
192
+ "GET",
193
+ "/keys/{key}/lookups",
194
+ :management_key,
195
+ path: { "key" => key },
196
+ query: {
197
+ "start" => start,
198
+ "end" => binding.local_variable_get(:end),
199
+ "licensee" => licensee
200
+ }
201
+ )
202
+ end
203
+
204
+ # Cleanse Address.
205
+ #
206
+ # Returns the closest matching address for a freeform address input, with Match Level indicators
207
+ # describing how closely each element of the suggested address matches the input. The more
208
+ # impaired the input address, the harder it is to cleanse.
209
+ #
210
+ # @param query [String] Freeform address input to cleanse
211
+ # @param tags [String, Array<String>] Tags
212
+ # @param remove_organisation [String] Remove Organisation
213
+ # @param context [String] Identify the country of the address to cleanse. Defaults to UK (GBR)
214
+ # @param postcode [String] Optionally specify the postal code for the address.
215
+ # @param post_town [String] Optionally specify the city or town of the address.
216
+ # @param county [String] Optionally specify the county of the address.
217
+ # @return [Responses::CleanseResponse]
218
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/address-cleanse
219
+ def address_cleanse(
220
+ query:,
221
+ tags: nil,
222
+ remove_organisation: nil,
223
+ context: nil,
224
+ postcode: nil,
225
+ post_town: nil,
226
+ county: nil
227
+ )
228
+ request(
229
+ "POST",
230
+ "/cleanse/addresses",
231
+ :api_key,
232
+ query: {
233
+ "tags" => tags,
234
+ "remove_organisation" => remove_organisation,
235
+ "context" => context
236
+ },
237
+ body: {
238
+ "query" => query,
239
+ "postcode" => postcode,
240
+ "post_town" => post_town,
241
+ "county" => county
242
+ },
243
+ response: Responses::CleanseResponse
244
+ )
245
+ end
246
+
247
+ # Find Address.
248
+ #
249
+ # Returns address suggestions for a partial address, ordered by relevance. Use it to power
250
+ # real-time address autofill.
251
+ #
252
+ # @param query [String] Address Query
253
+ # @param dataset [Array<String>] Filter by Dataset
254
+ # @param context [String] Context
255
+ # @param limit [Integer] Limit
256
+ # @param bias_lonlat [String] Bias by Geolocation
257
+ # @param bias_ip [String] Bias by Geolocation of IP
258
+ # @param box [String, Array<String>] Filter by Bounding Box
259
+ # @param postcode_outward [String] Filter by Outward Code
260
+ # @param postcode [String] Filter by postcode Restrict result set to matching postcodes only.
261
+ # Can be combined with query to perform a postcode and building number or name search.
262
+ # @param postcode_area [String] Filter by Postcode Area
263
+ # @param postcode_sector [String] Filter by Postcode Sector
264
+ # @param post_town [String] Filter by Town or City
265
+ # @param uprn [Integer] Filter by UPRN
266
+ # @param country [String] Filter by country
267
+ # @param postcode_type [String] Filter by Postcode Type
268
+ # @param su_organisation_indicator [String] Filter by Organisation Indicator
269
+ # @param bias_postcode_outward [String] Bias by Outward Code Boosts addresses with a matching
270
+ # outward code. The outward code is the first half of a postcode. For instance, the outward
271
+ # code of `SW1A 2AA` is `SW1A`.
272
+ # @param bias_postcode [String] Bias by postcode Boost addresses which match postcode. Can be
273
+ # combined with query to perform a postcode and building number or name search.
274
+ # @param bias_postcode_area [String] Bias by Postcode Area
275
+ # @param bias_postcode_sector [String] Bias by Postcode Sector
276
+ # @param bias_post_town [String] Bias by Town or City
277
+ # @param bias_thoroughfare [String] Bias by Street
278
+ # @param bias_country [String] Bias by Country
279
+ # @param postal_code [String] Filter by postal code
280
+ # @param postal_code_2 [String] Filter by postal code prefix
281
+ # @param postal_code_3 [String] Filter by short postal code
282
+ # @param city [String] Filter by city
283
+ # @param state [String] Filter by state
284
+ # @param state_code [String] Filter by state code
285
+ # @param bias_postal_code [String] Bias by postal code
286
+ # @param bias_postal_code_2 [String] Bias by postal code prefix
287
+ # @param bias_postal_code_3 [String] Bias by short postal code
288
+ # @param bias_city [String] Bias by city
289
+ # @param bias_state [String] Bias by state
290
+ # @param bias_state_code [String] Bias by state code
291
+ # @param is_pobox [String] Filter by PO Box
292
+ # @param is_business [String] Filter by business address
293
+ # @return [Responses::AutocompleteResponse]
294
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/find-address
295
+ def find_address(
296
+ query: nil,
297
+ dataset: nil,
298
+ context: nil,
299
+ limit: nil,
300
+ bias_lonlat: nil,
301
+ bias_ip: nil,
302
+ box: nil,
303
+ postcode_outward: nil,
304
+ postcode: nil,
305
+ postcode_area: nil,
306
+ postcode_sector: nil,
307
+ post_town: nil,
308
+ uprn: nil,
309
+ country: nil,
310
+ postcode_type: nil,
311
+ su_organisation_indicator: nil,
312
+ bias_postcode_outward: nil,
313
+ bias_postcode: nil,
314
+ bias_postcode_area: nil,
315
+ bias_postcode_sector: nil,
316
+ bias_post_town: nil,
317
+ bias_thoroughfare: nil,
318
+ bias_country: nil,
319
+ postal_code: nil,
320
+ postal_code_2: nil,
321
+ postal_code_3: nil,
322
+ city: nil,
323
+ state: nil,
324
+ state_code: nil,
325
+ bias_postal_code: nil,
326
+ bias_postal_code_2: nil,
327
+ bias_postal_code_3: nil,
328
+ bias_city: nil,
329
+ bias_state: nil,
330
+ bias_state_code: nil,
331
+ is_pobox: nil,
332
+ is_business: nil
333
+ )
334
+ request(
335
+ "GET",
336
+ "/autocomplete/addresses",
337
+ :api_key,
338
+ query: {
339
+ "query" => query,
340
+ "dataset" => dataset,
341
+ "context" => context,
342
+ "limit" => limit,
343
+ "bias_lonlat" => bias_lonlat,
344
+ "bias_ip" => bias_ip,
345
+ "box" => box,
346
+ "postcode_outward" => postcode_outward,
347
+ "postcode" => postcode,
348
+ "postcode_area" => postcode_area,
349
+ "postcode_sector" => postcode_sector,
350
+ "post_town" => post_town,
351
+ "uprn" => uprn,
352
+ "country" => country,
353
+ "postcode_type" => postcode_type,
354
+ "su_organisation_indicator" => su_organisation_indicator,
355
+ "bias_postcode_outward" => bias_postcode_outward,
356
+ "bias_postcode" => bias_postcode,
357
+ "bias_postcode_area" => bias_postcode_area,
358
+ "bias_postcode_sector" => bias_postcode_sector,
359
+ "bias_post_town" => bias_post_town,
360
+ "bias_thoroughfare" => bias_thoroughfare,
361
+ "bias_country" => bias_country,
362
+ "postal_code" => postal_code,
363
+ "postal_code_2" => postal_code_2,
364
+ "postal_code_3" => postal_code_3,
365
+ "city" => city,
366
+ "state" => state,
367
+ "state_code" => state_code,
368
+ "bias_postal_code" => bias_postal_code,
369
+ "bias_postal_code_2" => bias_postal_code_2,
370
+ "bias_postal_code_3" => bias_postal_code_3,
371
+ "bias_city" => bias_city,
372
+ "bias_state" => bias_state,
373
+ "bias_state_code" => bias_state_code,
374
+ "is_pobox" => is_pobox,
375
+ "is_business" => is_business
376
+ },
377
+ response: Responses::AutocompleteResponse
378
+ )
379
+ end
380
+
381
+ # Resolve Address.
382
+ #
383
+ # Returns the complete address for an autocomplete suggestion, identified by its address ID.
384
+ #
385
+ # @param address [String] ID of address suggestion
386
+ # @param tags [String, Array<String>] Tags
387
+ # @param remove_organisation [String] Remove Organisation
388
+ # @return [Responses::GbrResolveAddressResponse]
389
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/resolve-address
390
+ def resolve_address(address, tags: nil, remove_organisation: nil)
391
+ request(
392
+ "GET",
393
+ "/autocomplete/addresses/{address}/gbr",
394
+ :api_key,
395
+ path: { "address" => address },
396
+ query: { "tags" => tags, "remove_organisation" => remove_organisation },
397
+ response: Responses::GbrResolveAddressResponse
398
+ )
399
+ end
400
+
401
+ # Extract Addresses.
402
+ #
403
+ # Returns a list of UK addresses matching the query, ordered by relevance score. `limit`
404
+ # defaults to 10 and caps at 100. `page` defaults to 0.
405
+ #
406
+ # @param query [String] Specifies the address to query.
407
+ # @param limit [Integer] Limit
408
+ # @param page [Integer] Page
409
+ # @param filter [String, Array<String>] Restrict Result Fields
410
+ # @param lon [Float] Longitude
411
+ # @param lat [Float] Latitude
412
+ # @param postcode_outward [String] Filter by Outward Code
413
+ # @param postcode [String] Filter by postcode Restrict result set to matching postcodes only.
414
+ # Can be combined with query to perform a postcode and building number or name search.
415
+ # @param postcode_area [String] Filter by Postcode Area
416
+ # @param postcode_sector [String] Filter by Postcode Sector
417
+ # @param post_town [String] Filter by Town or City
418
+ # @param uprn [Integer] Filter by UPRN
419
+ # @param country [String] Filter by country
420
+ # @param postcode_type [String] Filter by Postcode Type
421
+ # @param su_organisation_indicator [String] Filter by Organisation Indicator
422
+ # @param box [String, Array<String>] Filter by Bounding Box
423
+ # @param bias_postcode_outward [String] Bias by Outward Code Boosts addresses with a matching
424
+ # outward code. The outward code is the first half of a postcode. For instance, the outward
425
+ # code of `SW1A 2AA` is `SW1A`.
426
+ # @param bias_postcode [String] Bias by postcode Boost addresses which match postcode. Can be
427
+ # combined with query to perform a postcode and building number or name search.
428
+ # @param bias_postcode_area [String] Bias by Postcode Area
429
+ # @param bias_postcode_sector [String] Bias by Postcode Sector
430
+ # @param bias_post_town [String] Bias by Town or City
431
+ # @param bias_thoroughfare [String] Bias by Street
432
+ # @param bias_country [String] Bias by Country
433
+ # @param bias_lonlat [String] Bias by Geolocation
434
+ # @param tags [String, Array<String>] Tags
435
+ # @param remove_organisation [String] Remove Organisation
436
+ # @param dataset [Array<String>] Filter by Dataset
437
+ # @return [Responses::AddressResponse]
438
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/addresses
439
+ def addresses(
440
+ query: nil,
441
+ limit: nil,
442
+ page: nil,
443
+ filter: nil,
444
+ lon: nil,
445
+ lat: nil,
446
+ postcode_outward: nil,
447
+ postcode: nil,
448
+ postcode_area: nil,
449
+ postcode_sector: nil,
450
+ post_town: nil,
451
+ uprn: nil,
452
+ country: nil,
453
+ postcode_type: nil,
454
+ su_organisation_indicator: nil,
455
+ box: nil,
456
+ bias_postcode_outward: nil,
457
+ bias_postcode: nil,
458
+ bias_postcode_area: nil,
459
+ bias_postcode_sector: nil,
460
+ bias_post_town: nil,
461
+ bias_thoroughfare: nil,
462
+ bias_country: nil,
463
+ bias_lonlat: nil,
464
+ tags: nil,
465
+ remove_organisation: nil,
466
+ dataset: nil
467
+ )
468
+ request(
469
+ "GET",
470
+ "/addresses",
471
+ :api_key,
472
+ query: {
473
+ "query" => query,
474
+ "limit" => limit,
475
+ "page" => page,
476
+ "filter" => filter,
477
+ "lon" => lon,
478
+ "lat" => lat,
479
+ "postcode_outward" => postcode_outward,
480
+ "postcode" => postcode,
481
+ "postcode_area" => postcode_area,
482
+ "postcode_sector" => postcode_sector,
483
+ "post_town" => post_town,
484
+ "uprn" => uprn,
485
+ "country" => country,
486
+ "postcode_type" => postcode_type,
487
+ "su_organisation_indicator" => su_organisation_indicator,
488
+ "box" => box,
489
+ "bias_postcode_outward" => bias_postcode_outward,
490
+ "bias_postcode" => bias_postcode,
491
+ "bias_postcode_area" => bias_postcode_area,
492
+ "bias_postcode_sector" => bias_postcode_sector,
493
+ "bias_post_town" => bias_post_town,
494
+ "bias_thoroughfare" => bias_thoroughfare,
495
+ "bias_country" => bias_country,
496
+ "bias_lonlat" => bias_lonlat,
497
+ "tags" => tags,
498
+ "remove_organisation" => remove_organisation,
499
+ "dataset" => dataset
500
+ },
501
+ response: Responses::AddressResponse
502
+ )
503
+ end
504
+
505
+ # Find Place.
506
+ #
507
+ # Returns place suggestions for a query, ranked by relevance. Places cover countries,
508
+ # administrative areas, capitals and other administrative seats.
509
+ #
510
+ # @param query [String] Specifies the place to query. Can be shortened to `q=`
511
+ # @param country_iso [String, Array<String>] Filter by Country
512
+ # @param bias_country_iso [String, Array<String>] Bias by Country Bias by country ISO code. Uses
513
+ # 3 letter country code (ISO 3166-1) standard. Bias by multiple countries with a comma
514
+ # separated list. E.g. `GBR,IRL`
515
+ # @param bias_lonlat [String] Bias by Geolocation
516
+ # @param bias_ip [String] Bias by Geolocation of IP
517
+ # @return [Responses::PlaceResponse]
518
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/find-place
519
+ def find_place(
520
+ query: nil,
521
+ country_iso: nil,
522
+ bias_country_iso: nil,
523
+ bias_lonlat: nil,
524
+ bias_ip: nil
525
+ )
526
+ request(
527
+ "GET",
528
+ "/places",
529
+ :api_key,
530
+ query: {
531
+ "query" => query,
532
+ "country_iso" => country_iso,
533
+ "bias_country_iso" => bias_country_iso,
534
+ "bias_lonlat" => bias_lonlat,
535
+ "bias_ip" => bias_ip
536
+ },
537
+ response: Responses::PlaceResponse
538
+ )
539
+ end
540
+
541
+ # Resolve Place.
542
+ #
543
+ # Returns the full place for a place ID taken from a `/places` suggestion.
544
+ #
545
+ # @param place [String] ID of place suggestion
546
+ # @param tags [String, Array<String>] Tags
547
+ # @return [Responses::ResolvePlaceResponse]
548
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/resolve-place
549
+ def resolve_place(place, tags: nil)
550
+ request(
551
+ "GET",
552
+ "/places/{place}",
553
+ :api_key,
554
+ path: { "place" => place },
555
+ query: { "tags" => tags },
556
+ response: Responses::ResolvePlaceResponse
557
+ )
558
+ end
559
+
560
+ # List.
561
+ #
562
+ # Returns a key's licensees, oldest first, up to 100 per request. The list omits cancelled
563
+ # licensees. The key must be enabled for sublicensing.
564
+ #
565
+ # Needs the Management Key.
566
+ #
567
+ # @param key [String] API Key
568
+ # @param starting_after [String] ID of the licensee after which to list results. Pass the `id`
569
+ # of the last licensee on the previous page.
570
+ # @param limit [Integer] Limit
571
+ # @param query [String] Filter results by licensee name. Can be shortened to `q=`
572
+ # @return [Responses::LicenseesResponse]
573
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/list-licensees
574
+ def list_licensees(key, starting_after: nil, limit: nil, query: nil)
575
+ request(
576
+ "GET",
577
+ "/keys/{key}/licensees",
578
+ :management_key,
579
+ path: { "key" => key },
580
+ query: { "starting_after" => starting_after, "limit" => limit, "query" => query },
581
+ response: Responses::LicenseesResponse
582
+ )
583
+ end
584
+
585
+ # Create.
586
+ #
587
+ # Creates a licensee on a key and returns it with its generated `sl_` key. The key must be
588
+ # enabled for sublicensing.
589
+ #
590
+ # Needs the Management Key.
591
+ #
592
+ # @param key [String] API Key
593
+ # @param name [String] Licensee individual or organisation name
594
+ # @param address [String] Licensee's first, second and third line address as well as post town
595
+ # concatenated by commas
596
+ # @param postcode [String] Licensee's postcode
597
+ # @param whitelist [Array<String>] A list of allowed URLs. An empty list disables the check.
598
+ # @param daily [Hash]
599
+ # @return [Responses::LicenseeResponse]
600
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/create-licensee
601
+ def create_licensee(key, name: nil, address: nil, postcode: nil, whitelist: nil, daily: nil)
602
+ request(
603
+ "POST",
604
+ "/keys/{key}/licensees",
605
+ :management_key,
606
+ path: { "key" => key },
607
+ body: {
608
+ "name" => name,
609
+ "address" => address,
610
+ "postcode" => postcode,
611
+ "whitelist" => whitelist,
612
+ "daily" => daily
613
+ },
614
+ response: Responses::LicenseeResponse
615
+ )
616
+ end
617
+
618
+ # Retrieve.
619
+ #
620
+ # Returns a licensee by its `sl_` key. A cancelled or unknown licensee returns `404`.
621
+ #
622
+ # Needs the Management Key.
623
+ #
624
+ # @param key [String] API Key
625
+ # @param licensee [String] Licensee Key
626
+ # @return [Responses::LicenseeResponse]
627
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/retrieve-licensee
628
+ def retrieve_licensee(key, licensee)
629
+ request(
630
+ "GET",
631
+ "/keys/{key}/licensees/{licensee}",
632
+ :management_key,
633
+ path: { "key" => key, "licensee" => licensee },
634
+ response: Responses::LicenseeResponse
635
+ )
636
+ end
637
+
638
+ # Cancel.
639
+ #
640
+ # Cancels a licensee. Its key stops working and it drops out of the licensee list. Contact us to
641
+ # reverse it.
642
+ #
643
+ # Needs the Management Key.
644
+ #
645
+ # @param key [String] API Key
646
+ # @param licensee [String] Licensee Key
647
+ # @return [Responses::DeleteLicenseeResponse]
648
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/delete-licensee
649
+ def delete_licensee(key, licensee)
650
+ request(
651
+ "DELETE",
652
+ "/keys/{key}/licensees/{licensee}",
653
+ :management_key,
654
+ path: { "key" => key, "licensee" => licensee },
655
+ response: Responses::DeleteLicenseeResponse
656
+ )
657
+ end
658
+
659
+ # Update.
660
+ #
661
+ # Updates a licensee's address, postcode, allowed URLs and daily limit. Returns the updated
662
+ # licensee. The name is fixed at creation.
663
+ #
664
+ # Needs the Management Key.
665
+ #
666
+ # @param key [String] API Key
667
+ # @param licensee [String] Licensee Key
668
+ # @param name [String] Licensee individual or organisation name
669
+ # @param address [String] Licensee's first, second and third line address as well as post town
670
+ # concatenated by commas
671
+ # @param postcode [String] Licensee's postcode
672
+ # @param whitelist [Array<String>] A list of allowed URLs. An empty list disables the check.
673
+ # @param daily [Hash]
674
+ # @return [Responses::LicenseeResponse]
675
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/update-licensee
676
+ def update_licensee(
677
+ key,
678
+ licensee,
679
+ name: nil,
680
+ address: nil,
681
+ postcode: nil,
682
+ whitelist: nil,
683
+ daily: nil
684
+ )
685
+ request(
686
+ "POST",
687
+ "/keys/{key}/licensees/{licensee}",
688
+ :management_key,
689
+ path: { "key" => key, "licensee" => licensee },
690
+ body: {
691
+ "name" => name,
692
+ "address" => address,
693
+ "postcode" => postcode,
694
+ "whitelist" => whitelist,
695
+ "daily" => daily
696
+ },
697
+ response: Responses::LicenseeResponse
698
+ )
699
+ end
700
+
701
+ # Regenerate Key.
702
+ #
703
+ # Regenerates a licensee's key and returns the licensee with the new key. The previous key stops
704
+ # working immediately, so update any integration that uses it.
705
+ #
706
+ # Needs the Management Key.
707
+ #
708
+ # @param key [String] API Key
709
+ # @param licensee [String] Licensee Key
710
+ # @return [Responses::LicenseeResponse]
711
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/regenerate-licensee-key
712
+ def regenerate_licensee_key(key, licensee)
713
+ request(
714
+ "POST",
715
+ "/keys/{key}/licensees/{licensee}/regenerate-key",
716
+ :management_key,
717
+ path: { "key" => key, "licensee" => licensee },
718
+ response: Responses::LicenseeResponse
719
+ )
720
+ end
721
+
722
+ # List.
723
+ #
724
+ # Returns every configuration stored against a key, oldest first.
725
+ #
726
+ # Needs the Management Key.
727
+ #
728
+ # @param key [String] API Key
729
+ # @return [Responses::ConfigsResponse]
730
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/list-configs
731
+ def list_configs(key)
732
+ request(
733
+ "GET",
734
+ "/keys/{key}/configs",
735
+ :management_key,
736
+ path: { "key" => key },
737
+ response: Responses::ConfigsResponse
738
+ )
739
+ end
740
+
741
+ # Create.
742
+ #
743
+ # Creates a named configuration on a key and returns it.
744
+ #
745
+ # Needs the Management Key.
746
+ #
747
+ # @param key [String] API Key
748
+ # @param name [String] A unique name to identify the configuration payload
749
+ # @param payload [String] A serialised payload of up to `65536` characters
750
+ # @return [Responses::ConfigResponse]
751
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/create-config
752
+ def create_config(key, name:, payload:)
753
+ request(
754
+ "POST",
755
+ "/keys/{key}/configs",
756
+ :management_key,
757
+ path: { "key" => key },
758
+ body: { "name" => name, "payload" => payload },
759
+ response: Responses::ConfigResponse
760
+ )
761
+ end
762
+
763
+ # Retrieve.
764
+ #
765
+ # Returns a configuration by name. This request needs no `user_token`, so a browser integration
766
+ # can read its own configuration at runtime.
767
+ #
768
+ # @param key [String] API Key
769
+ # @param config [String] Configuration Name
770
+ # @return [Responses::ConfigResponse]
771
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/retrieve-config
772
+ def retrieve_config(key, config)
773
+ request(
774
+ "GET",
775
+ "/keys/{key}/configs/{config}",
776
+ :none,
777
+ path: { "key" => key, "config" => config },
778
+ response: Responses::ConfigResponse
779
+ )
780
+ end
781
+
782
+ # Delete.
783
+ #
784
+ # Permanently deletes a configuration object.
785
+ #
786
+ # Needs the Management Key.
787
+ #
788
+ # @param key [String] API Key
789
+ # @param config [String] Configuration Name
790
+ # @return [Responses::DeleteConfigResponse]
791
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/delete-config
792
+ def delete_config(key, config)
793
+ request(
794
+ "DELETE",
795
+ "/keys/{key}/configs/{config}",
796
+ :management_key,
797
+ path: { "key" => key, "config" => config },
798
+ response: Responses::DeleteConfigResponse
799
+ )
800
+ end
801
+
802
+ # Update.
803
+ #
804
+ # Replaces a configuration's payload and returns the updated configuration. The name is fixed at
805
+ # creation.
806
+ #
807
+ # Needs the Management Key.
808
+ #
809
+ # @param key [String] API Key
810
+ # @param config [String] Configuration Name
811
+ # @param payload [String] A serialised payload of up to `65536` characters
812
+ # @return [Responses::ConfigResponse]
813
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/update-config
814
+ def update_config(key, config, payload: nil)
815
+ request(
816
+ "POST",
817
+ "/keys/{key}/configs/{config}",
818
+ :management_key,
819
+ path: { "key" => key, "config" => config },
820
+ body: { "payload" => payload },
821
+ response: Responses::ConfigResponse
822
+ )
823
+ end
824
+
825
+ # Email Validation.
826
+ #
827
+ # Validates an email address and reports whether it is deliverable.
828
+ #
829
+ # @param query [String] Specifies the email address to validate
830
+ # @param tags [String, Array<String>] Tags
831
+ # @return [Responses::EmailResponse]
832
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/email-validation
833
+ def email_validation(query:, tags: nil)
834
+ request(
835
+ "GET",
836
+ "/emails",
837
+ :api_key,
838
+ query: { "query" => query, "tags" => tags },
839
+ response: Responses::EmailResponse
840
+ )
841
+ end
842
+
843
+ # Phone Number Validation.
844
+ #
845
+ # Validates a phone number and returns its country, its national and international formats, and
846
+ # the network it was originally assigned to.
847
+ #
848
+ # @param query [String] Specifies the phone number to validate. Phone number must include a
849
+ # country code in an acceptable format. For instance, UK phone numbers should be prefixed with
850
+ # `+44`, `44` or `0044`.
851
+ # @param current_carrier [String] When set to `true`, the API retrieves and populates the
852
+ # current network of the phone number.
853
+ # @param tags [String, Array<String>] Tags
854
+ # @return [Responses::PhoneNumberResponse]
855
+ # @see https://docs.ideal-postcodes.co.uk/docs/sdks/ruby/endpoints/phone-number-validation
856
+ def phone_number_validation(query:, current_carrier: nil, tags: nil)
857
+ request(
858
+ "GET",
859
+ "/phone_numbers",
860
+ :api_key,
861
+ query: { "query" => query, "current_carrier" => current_carrier, "tags" => tags },
862
+ response: Responses::PhoneNumberResponse
863
+ )
864
+ end
865
+ end
866
+ end