GetCustomerAddresses
Implements GetCustomerAddresses Unified Method.
Source
import { getNormalizers } from "@alokai/connect/integration-kit";
import type { UserAddress } from "@vsf-enterprise/bigcommerce-api";
import { assertAuthorized, defineApi } from "@vsf-enterprise/unified-api-bigcommerce";
export const getCustomerAddresses = defineApi.getCustomerAddresses(async (context) => {
await assertAuthorized(context);
const { api } = await context.getApiClient();
const addresses = await api.getCustomerAddress({});
const { normalizeCustomerAddress } = getNormalizers(context);
return {
addresses: addresses.data.map((address: UserAddress) => normalizeCustomerAddress(address)),
};
});