export type AddressUpdateRequest = {line1: string, line2?: string | undefined, line3?: string | undefined, postTown: string, postCode: string, countryCode: string, udprn?: string | undefined, umprn?: string | undefined, from: string}; export type CreateApiApiV2AddressesArgs = {body: AddressUpdateRequest}; export type CreateApiApiV2AddressesOptions = {baseUrl: string, BearerAndSignature?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update the account holder's current address * * POST /api/v2/addresses */ export const createApiApiV2Addresses = async (args: CreateApiApiV2AddressesArgs, options: CreateApiApiV2AddressesOptions) => { const {baseUrl, fetch: fetchFn = fetch, BearerAndSignature} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (BearerAndSignature !== undefined) headers.set('authorization', `bearerAndSignature ${BearerAndSignature}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/addresses${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };