Skip to content

Commit

Permalink
feat: return empty array to a deprecated endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
vsseixaso committed Sep 3, 2024
1 parent 4d2c52a commit 21238a8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
9 changes: 8 additions & 1 deletion node/clients/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,15 @@ export class Checkout extends JanusClient {
})
}

// Deprecated: This endpoint is deprecated and any request will return an empty array
public orders = () =>
this.get(this.routes.orders, { metric: 'checkout-orders' })
this.get(this.routes.orders, { metric: 'checkout-orders' }).catch((err) => {
if (err.response && err.response.status === 405) {
return []
}

throw err
})

public simulation = (simulation: SimulationPayload) =>
this.post<SimulationOrderForm>(
Expand Down
14 changes: 14 additions & 0 deletions node/resolvers/checkout/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,20 @@ export const queries: Record<string, Resolver> = {
return checkout.orders()
},

// orders: async (_, __, { clients: { checkout } }) => {
// try {
// const result = await checkout.orders()

// return result
// } catch (err) {
// if (err.response && err.response.status === 405) {
// return []
// }

// throw err
// }
// },

shipping: (_, args: any, { clients: { checkout } }) => {
return checkout.simulation(args)
},
Expand Down

0 comments on commit 21238a8

Please sign in to comment.