GetOrderDetails
Implements GetOrderDetails
Unified Method.
Source
import { getNormalizers } from "@vsf-enterprise/unified-api-magento/udl";
import { assertAuthorized, defineApi, query } from "@vsf-enterprise/unified-api-magento";
import type { CustomerOrder } from "@vsf-enterprise/unified-api-magento/ecommerceTypes";
export const getOrderDetails = defineApi.getOrderDetails(async (context, args) => {
await assertAuthorized(context);
const { id } = args;
const { normalizeOrder } = getNormalizers(context);
const data = await query(
context.api.customerOrders({
filter: {
number: { eq: id },
},
pageSize: 1,
currentPage: 1,
}),
);
const order = data.customer?.orders?.items?.[0] ?? {};
return normalizeOrder(order as CustomerOrder);
});