GetOrderDetails
Implements GetOrderDetails
Unified Method.
Source
import { assignToNormalizerContext, getNormalizers } from "@vsf-enterprise/unified-api-sfcc/udl";
import { assertAuthorized, defineApi } from "@vsf-enterprise/unified-api-sfcc";
declare module "@vsf-enterprise/unified-api-sfcc" {
interface GetOrderDetailsExtendedArgs {}
}
export const getOrderDetails = defineApi.getOrderDetails(async (context, args) => {
await assertAuthorized(context);
const { id } = args;
const { normalizeOrder } = getNormalizers(context);
const order = await context.api.getCustomerOrder({
id,
});
const productsDetails = await context.api.getProducts({
ids: order.productItems!.map((item) => item.productId).filter(Boolean),
});
assignToNormalizerContext(context, { productsDetails });
return normalizeOrder(order);
});