@@ -197,21 +197,10 @@ export const lookupPostcode = (
197
197
export const lookupAddress = (
198
198
options : LookupAddressOptions
199
199
) : Promise < UkAddress [ ] > => {
200
- const header : StringMap = { } ;
201
- const query : StringMap = { query : options . query } ;
202
- const { client } = options ;
203
-
204
- appendAuthorization ( { client, header, options } ) ;
205
- appendIp ( { header, options } ) ;
206
- appendFilter ( { query, options } ) ;
207
- appendTags ( { client, query, options } ) ;
208
- appendPage ( { query, options } ) ;
209
-
210
- const queryOptions : Request = { header, query } ;
211
- if ( options . timeout !== undefined ) queryOptions . timeout = options . timeout ;
200
+ const queryOptions = toAddressLookupQuery ( options )
212
201
213
202
return addresses
214
- . list ( client , queryOptions )
203
+ . list ( options . client , queryOptions )
215
204
. then ( ( response ) => response . body . result . hits ) ;
216
205
} ;
217
206
@@ -222,7 +211,7 @@ export const lookupAddress = (
222
211
* - Result filtering
223
212
* - Tagging
224
213
*/
225
- const toAddressIdQuery = ( options : LookupIdOptions ) : Request => {
214
+ export const toAddressIdQuery = ( options : LookupIdOptions ) : Request => {
226
215
const header : StringMap = { } ;
227
216
const query : StringMap = { } ;
228
217
const { client } = options ;
@@ -238,6 +227,23 @@ const toAddressIdQuery = (options: LookupIdOptions): Request => {
238
227
return request ;
239
228
} ;
240
229
230
+
231
+ export const toAddressLookupQuery = ( options : LookupAddressOptions ) : Request => {
232
+ const header : StringMap = { } ;
233
+ const query : StringMap = { query : options . query }
234
+ const { client } = options ;
235
+
236
+ appendAuthorization ( { client, header, options } ) ;
237
+ appendIp ( { header, options } ) ;
238
+ appendFilter ( { query, options } ) ;
239
+ appendTags ( { client, query, options } ) ;
240
+ appendPage ( { query, options } ) ;
241
+
242
+ const queryOptions : Request = { header, query } ;
243
+ if ( options . timeout !== undefined ) queryOptions . timeout = options . timeout ;
244
+
245
+ return queryOptions ;
246
+ } ;
241
247
/**
242
248
* Lookup UDPRN
243
249
*
0 commit comments