Skip to content

Commit 4965c73

Browse files
committed
fix(Internal): Export internal address lookup methods
1 parent e7bfd0e commit 4965c73

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

lib/helpers.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -197,21 +197,10 @@ export const lookupPostcode = (
197197
export const lookupAddress = (
198198
options: LookupAddressOptions
199199
): 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)
212201

213202
return addresses
214-
.list(client, queryOptions)
203+
.list(options.client, queryOptions)
215204
.then((response) => response.body.result.hits);
216205
};
217206

@@ -222,7 +211,7 @@ export const lookupAddress = (
222211
* - Result filtering
223212
* - Tagging
224213
*/
225-
const toAddressIdQuery = (options: LookupIdOptions): Request => {
214+
export const toAddressIdQuery = (options: LookupIdOptions): Request => {
226215
const header: StringMap = {};
227216
const query: StringMap = {};
228217
const { client } = options;
@@ -238,6 +227,23 @@ const toAddressIdQuery = (options: LookupIdOptions): Request => {
238227
return request;
239228
};
240229

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+
};
241247
/**
242248
* Lookup UDPRN
243249
*

0 commit comments

Comments
 (0)