feat(dashboard): transfer order admin (#10189)
**What** - request order transfer from order details page - timeline events --- CLOSES CMRC-706 CLOSES CMRC-707
This commit is contained in:
@@ -22,27 +22,27 @@ export class Order {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves an order by its ID. It sends a request to the
|
||||
* This method retrieves an order by its ID. It sends a request to the
|
||||
* [Get Order](https://docs.medusajs.com/api/admin#orders_getordersid)
|
||||
* API route.
|
||||
*
|
||||
*
|
||||
* @param id - The order's ID.
|
||||
* @param query - Configure the fields to retrieve in the order.
|
||||
* @param headers - Headers to pass in the request
|
||||
* @returns The order's details.
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* To retrieve an order by its ID:
|
||||
*
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.order.retrieve("order_123")
|
||||
* .then(({ order }) => {
|
||||
* console.log(order)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
*
|
||||
* To specify the fields and relations to retrieve:
|
||||
*
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.order.retrieve("order_123", {
|
||||
* fields: "id,*items"
|
||||
@@ -51,7 +51,7 @@ export class Order {
|
||||
* console.log(order)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
|
||||
*/
|
||||
async retrieve(id: string, query?: SelectParams, headers?: ClientHeaders) {
|
||||
@@ -65,14 +65,14 @@ export class Order {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves the preview of an order based on its last associated change. It sends a request to the
|
||||
* This method retrieves the preview of an order based on its last associated change. It sends a request to the
|
||||
* [Get Order Preview](https://docs.medusajs.com/api/admin#orders_getordersidpreview) API route.
|
||||
*
|
||||
*
|
||||
* @param id - The order's ID.
|
||||
* @param query - Query parameters.
|
||||
* @param headers - Headers to pass in the request
|
||||
* @returns The order preview's details.
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.order.retrievePreview("order_123")
|
||||
* .then(({ order }) => {
|
||||
@@ -94,27 +94,27 @@ export class Order {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a paginated list of orders. It sends a request to the
|
||||
* This method retrieves a paginated list of orders. It sends a request to the
|
||||
* [List Orders](https://docs.medusajs.com/api/admin#orders_getorders) API route.
|
||||
*
|
||||
*
|
||||
* @param queryParams - Filters and pagination configurations.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The paginated list of orders.
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* To retrieve the list of orders:
|
||||
*
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.order.list()
|
||||
* .then(({ orders, count, limit, offset }) => {
|
||||
* console.log(orders)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
*
|
||||
* To configure the pagination, pass the `limit` and `offset` query parameters.
|
||||
*
|
||||
*
|
||||
* For example, to retrieve only 10 items and skip 10 items:
|
||||
*
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.order.list({
|
||||
* limit: 10,
|
||||
@@ -124,10 +124,10 @@ export class Order {
|
||||
* console.log(orders)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
*
|
||||
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
* in each order:
|
||||
*
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.order.list({
|
||||
* fields: "id,*items"
|
||||
@@ -136,30 +136,31 @@ export class Order {
|
||||
* console.log(orders)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
|
||||
*/
|
||||
async list(
|
||||
queryParams?: HttpTypes.AdminOrderFilters,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<
|
||||
HttpTypes.AdminOrderListResponse
|
||||
>(`/admin/orders`, {
|
||||
query: queryParams,
|
||||
headers,
|
||||
})
|
||||
return await this.client.fetch<HttpTypes.AdminOrderListResponse>(
|
||||
`/admin/orders`,
|
||||
{
|
||||
query: queryParams,
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method cancels an order. It sends a request to the
|
||||
* [Cancel Order](https://docs.medusajs.com/api/admin#orders_postordersidcancel)
|
||||
* 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.cancel("order_123")
|
||||
* .then(({ order }) => {
|
||||
@@ -176,17 +177,51 @@ export class Order {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method requests an order transfer. It sends a request to the
|
||||
* [Request Order Transfer](https://docs.medusajs.com/api/admin#orders_postordersidrequesttransfer)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The order's ID.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @param body - The transfer's details - the id of the next owner.
|
||||
* @returns The order's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.order.requestTransfer("order_123", {
|
||||
* customer_id: "cus_123",
|
||||
* internal_note: "Internal note",
|
||||
* })
|
||||
* .then(({ order }) => {
|
||||
* console.log(order)
|
||||
* })
|
||||
*/
|
||||
async requestTransfer(
|
||||
id: string,
|
||||
body: HttpTypes.AdminRequestOrderTransfer,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminOrderResponse>(
|
||||
`/admin/orders/${id}/transfer`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a fulfillment for an order. It sends a request to the
|
||||
* [Create Fulfillment](https://docs.medusajs.com/api/admin#orders_postordersidfulfillments)
|
||||
* API route.
|
||||
*
|
||||
*
|
||||
* @param id - The order's ID.
|
||||
* @param body - The fulfillment'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.createFulfillment("order_123", {
|
||||
* items: [
|
||||
@@ -221,13 +256,13 @@ export class Order {
|
||||
* This method cancels an order's fulfillment. It sends a request to the
|
||||
* [Cancel Fulfillment](https://docs.medusajs.com/api/admin#orders_postordersidfulfillmentsfulfillment_idcancel)
|
||||
* API route.
|
||||
*
|
||||
*
|
||||
* @param id - The order's ID.
|
||||
* @param fulfillmentId - The ID of the fulfillment to cancel.
|
||||
* @param body - The cancelation's details.
|
||||
* @param headers - Headers to pass in the request
|
||||
* @returns The order's details.
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.order.cancelFulfillment(
|
||||
* "order_123",
|
||||
@@ -260,14 +295,14 @@ export class Order {
|
||||
* This method creates a shipment for an order's fulfillment. It sends a request to the
|
||||
* [Create Shipment](https://docs.medusajs.com/api/admin#orders_postordersidfulfillmentsfulfillment_idshipments)
|
||||
* API route.
|
||||
*
|
||||
*
|
||||
* @param id - The order's ID.
|
||||
* @param fulfillmentId - The ID of the fulfillment.
|
||||
* @param body - The shipment'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.createShipment(
|
||||
* "order_123",
|
||||
@@ -307,14 +342,14 @@ export class Order {
|
||||
* This method marks an order's fulfillment as delivered. It sends a request to the
|
||||
* [Mark Delivered ](https://docs.medusajs.com/api/admin#orders_postordersidfulfillmentsfulfillment_idmarkasdelivered)
|
||||
* API route.
|
||||
*
|
||||
*
|
||||
* @param id - The order's ID.
|
||||
* @param fulfillmentId - The fulfillment's ID.
|
||||
* @param body - The delivery 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.markAsDelivered(
|
||||
* "order_123",
|
||||
@@ -345,15 +380,15 @@ export class Order {
|
||||
|
||||
/**
|
||||
* This method retrieves a list of changes made on an order, including returns, exchanges, etc...
|
||||
*
|
||||
*
|
||||
* This method sends a request to the [List Changes](https://docs.medusajs.com/api/admin#orders_getordersidchanges)
|
||||
* API route.
|
||||
*
|
||||
*
|
||||
* @param id - The order's ID.
|
||||
* @param queryParams - Configure the fields to retrieve in each order change.
|
||||
* @param headers - Headers to pass in the request
|
||||
* @returns The list of order changes.
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.order.listChanges("order_123")
|
||||
* .then(({ order_changes }) => {
|
||||
@@ -377,12 +412,12 @@ export class Order {
|
||||
* This method retrieves the order's line items. It sends a request to the
|
||||
* [List Line Items](https://docs.medusajs.com/api/admin#orders_getordersidlineitems)
|
||||
* API routes.
|
||||
*
|
||||
*
|
||||
* @param id - The order's ID.
|
||||
* @param queryParams - Configure the fields to retrieve in each line item.
|
||||
* @param headers - Headers to pass in the request
|
||||
* @returns The list of line items.
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.order.listLineItems("order_123")
|
||||
* .then(({ order_items }) => {
|
||||
@@ -394,11 +429,12 @@ export class Order {
|
||||
queryParams?: FindParams & HttpTypes.AdminOrderItemsFilters,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<
|
||||
HttpTypes.AdminOrderLineItemsListResponse
|
||||
>(`/admin/orders/${id}/line-items`, {
|
||||
query: queryParams,
|
||||
headers,
|
||||
})
|
||||
return await this.client.fetch<HttpTypes.AdminOrderLineItemsListResponse>(
|
||||
`/admin/orders/${id}/line-items`,
|
||||
{
|
||||
query: queryParams,
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user