CreateCustomerAddress
Implements CreateCustomerAddress
Unified Method.
Source
import { assertAuthorized, defineApi } from "@vsf-enterprise/unified-api-sapcc";
import { getNormalizers } from "@vsf-enterprise/unified-api-sapcc/udl";
import { Address } from "@vsf-enterprise/sapcc-types";
declare module "@vsf-enterprise/unified-api-sapcc" {
interface CreateCustomerAddressExtendedArgs {
/**
* Response configuration. List of fields returned in the response body.
*/
fields?: "BASIC" | "DEFAULT" | "FULL" | string | string[];
/**
* The additional address fields to be included in created address.
* */
address?: Partial<
Omit<
Address,
| "title"
| "firstName"
| "lastName"
| "postalCode"
| "country"
| "town"
| "line1"
| "line2"
| "phone"
| "district"
>
>;
}
}
import type { Address, RequiredAddressProps } from "@vsf-enterprise/sapcc-types";
export const createCustomerAddress = defineApi.createCustomerAddress(async (context, args) => {
assertAuthorized(context);
const { address } = args;
const { unnormalizeAddress, normalizeCustomerAddress } = getNormalizers(context);
const { data: createdAddress } = await context.api.createAddress({
address: unnormalizeAddress(address) as Address & RequiredAddressProps,
});
return {
address: normalizeCustomerAddress(createdAddress),
};
});