UpdateCustomer
Implements UpdateCustomer
Unified Method.
Source
import { defineApi, assertAuthorized } from "@vsf-enterprise/unified-api-sfcc";
import { getNormalizers } from "@vsf-enterprise/unified-api-sfcc/udl";
import { KnownKeys } from "@vsf-enterprise/unified-api-sfcc";
import { UpdateCustomerParams } from "@vsf-enterprise/sfcc-types";
declare module "@vsf-enterprise/unified-api-sfcc" {
interface UpdateCustomerExtendedArgs {
/**
* The additional customer object fields to be updated. Excluding `firstName`, `lastName` and `email`.
* {@link https://developer.salesforce.com/docs/commerce/commerce-api/references/shopper-customers?meta=updateCustomer SFCC method reference}
*/
customer?: Partial<Omit<KnownKeys<UpdateCustomerParams>, "firstName" | "lastName" | "email">>;
}
}
export const updateCustomer = defineApi.updateCustomer(async (context, args) => {
await assertAuthorized(context);
const { email, firstName, lastName } = args;
const { normalizeCustomer } = getNormalizers(context);
const updatedCustomer = await context.api.updateCustomer({
email,
firstName,
lastName,
});
return { customer: normalizeCustomer(updatedCustomer) };
});