Skip to content

fix(js-sdk): add missing admin order archive and complete methods #12944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cuddly-rice-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/js-sdk": patch
---

fix(js-sdk): add missing admin order archive and complete methods
67 changes: 65 additions & 2 deletions packages/core/js-sdk/src/admin/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,37 @@ export class Order {
)
}

/**
* This method archives an order. It sends a request to the
* [Archive Order](https://docs.medusajs.com/api/admin#orders_postordersidarchive)
* API route.
*
* @param id - The order's ID.
* @param queryParams - Configure the fields to retrieve in the order.
* @param headers - Headers to pass in the request
* @returns The order's details.
*
* @example
* sdk.admin.order.archive("order_123")
* .then(({ order }) => {
* console.log(order)
* })
*/
async archive(
id: string,
queryParams?: SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminOrderResponse>(
`/admin/orders/${id}/archive`,
{
method: "POST",
query: queryParams,
headers,
}
)
}

/**
* This method cancels an order. It sends a request to the
* [Cancel Order](https://docs.medusajs.com/api/admin#orders_postordersidcancel)
Expand All @@ -219,6 +250,38 @@ export class Order {
)
}

/**
* This method completes an order. It sends a request to the
* [Complete Order](https://docs.medusajs.com/api/admin#orders_postordersidcomplete)
* API route.
*
* @param id - The order's ID.
* @param headers - Headers to pass in the request.
* @returns The order's details.
*
* @example
* sdk.admin.order.complete("order_123")
* .then(({ order }) => {
* console.log(order)
* })
*/
async complete(
id: string,
body: HttpTypes.AdditionalData,
queryParams?: SelectParams,
headers?: ClientHeaders
) {
return await this.client.fetch<HttpTypes.AdminOrderResponse>(
`/admin/orders/${id}/complete`,
{
method: "POST",
body,
query: queryParams,
headers,
}
)
}

/**
* This method requests an order transfer. It sends a request to the
* [Request Order Transfer](https://docs.medusajs.com/api/admin#orders_postordersidrequesttransfer)
Expand Down Expand Up @@ -504,13 +567,13 @@ export class Order {
/**
* This method creates a credit line for an order. It sends a request to the
* [Create Credit Line](https://docs.medusajs.com/api/admin#orders_postordersidcredit-lines) API route.
*
*
* @param orderId - The order's ID.
* @param body - The credit line's details.
* @param query - Configure the fields to retrieve in the order.
* @param headers - Headers to pass in the request
* @returns The order's details.
*
*
* @example
* sdk.admin.order.createCreditLine(
* "order_123",
Expand Down
Loading