Skip to content

Commit

Permalink
fix(openapi): remove payload from required properties in customer ord…
Browse files Browse the repository at this point in the history
…er 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
  • Loading branch information
jamalsoueidan committed Dec 15, 2023
1 parent 49f9d7a commit ccad0c6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
1 change: 0 additions & 1 deletion openapi/paths/customer/order/get/response.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ properties:
$ref: get.yaml
required:
- success
- payload
6 changes: 3 additions & 3 deletions src/functions/customer/services/order/get.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
9 changes: 1 addition & 8 deletions src/functions/customer/services/order/get.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { OrderModel } from "~/functions/order/order.models";
import { NotFoundError } from "~/library/handler";
import {
OrderAggregate,
OrderLineItemsAggreate,
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit ccad0c6

Please sign in to comment.