From ccad0c68e501b9ba55178d59889368568e8c99ea Mon Sep 17 00:00:00 2001 From: Jamal Soueidan Date: Fri, 15 Dec 2023 16:21:57 +0300 Subject: [PATCH] fix(openapi): remove payload from required properties in customer order get response fix(get.spec.ts): add null checks to order properties fix(get.ts): change NotFoundError to return null instead of throwing an error --- openapi/paths/customer/order/get/response.yaml | 1 - src/functions/customer/services/order/get.spec.ts | 6 +++--- src/functions/customer/services/order/get.ts | 9 +-------- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/openapi/paths/customer/order/get/response.yaml b/openapi/paths/customer/order/get/response.yaml index cf57f2b7..0e1936d6 100644 --- a/openapi/paths/customer/order/get/response.yaml +++ b/openapi/paths/customer/order/get/response.yaml @@ -7,4 +7,3 @@ properties: $ref: get.yaml required: - success - - payload diff --git a/src/functions/customer/services/order/get.spec.ts b/src/functions/customer/services/order/get.spec.ts index 5548bf06..233214d5 100644 --- a/src/functions/customer/services/order/get.spec.ts +++ b/src/functions/customer/services/order/get.spec.ts @@ -24,8 +24,8 @@ describe("CustomerOrderServiceGet", () => { orderId, }); - expect(order.line_items.length).toBe(2); - expect(order.fulfillments.length).toBe(2); - expect(order.refunds.length).toBe(1); + expect(order?.line_items.length).toBe(2); + expect(order?.fulfillments.length).toBe(2); + expect(order?.refunds.length).toBe(1); }); }); diff --git a/src/functions/customer/services/order/get.ts b/src/functions/customer/services/order/get.ts index 9700edb5..9291488d 100644 --- a/src/functions/customer/services/order/get.ts +++ b/src/functions/customer/services/order/get.ts @@ -1,5 +1,4 @@ import { OrderModel } from "~/functions/order/order.models"; -import { NotFoundError } from "~/library/handler"; import { OrderAggregate, OrderLineItemsAggreate, @@ -133,13 +132,7 @@ export const CustomerOrderServiceGet = async ({ ]); if (orders.length === 0) { - throw new NotFoundError([ - { - code: "custom", - message: "ORDER_NOT_FOUND", - path: ["lineItemId"], - }, - ]); + return null; } return orders[0];