chore(js-sdk,types): add tsdocs for admin JS SDK methods [4/n] (#9745)
Add TSDocs to admin JS SDK from notification to payment [4/n]
This commit is contained in:
@@ -14,6 +14,39 @@ export class Notification {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a notification's details. It sends a request to the
|
||||
* [Get Notification](https://docs.medusajs.com/api/admin#notifications_getnotificationsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The notification's ID.
|
||||
* @param query - Configure the fields to retrieve in the notification.
|
||||
* @param headers - Headers to pass in the request
|
||||
* @returns The notification's details.
|
||||
*
|
||||
* @example
|
||||
* To retrieve a notification by its ID:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.notification.retrieve("notif_123")
|
||||
* .then(({ notification }) => {
|
||||
* console.log(notification)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To specify the fields and relations to retrieve:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.notification.retrieve("notif_123", {
|
||||
* fields: "id,to"
|
||||
* })
|
||||
* .then(({ notification }) => {
|
||||
* console.log(notification)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* 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?: HttpTypes.AdminNotificationParams,
|
||||
@@ -29,6 +62,53 @@ export class Notification {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a paginated list of notifications. It sends a request to the
|
||||
* [List Notifications](https://docs.medusajs.com/api/admin#notifications_getnotifications)
|
||||
* API route.
|
||||
*
|
||||
* @param query - Filters and pagination configurations.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The paginated list of notifications.
|
||||
*
|
||||
* @example
|
||||
* To retrieve the list of notifications:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.notification.list()
|
||||
* .then(({ notifications, count, limit, offset }) => {
|
||||
* console.log(notifications)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* 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.notification.list({
|
||||
* limit: 10,
|
||||
* offset: 10
|
||||
* })
|
||||
* .then(({ notifications, count, limit, offset }) => {
|
||||
* console.log(notifications)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
* in each notification:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.notification.list({
|
||||
* fields: "id,to"
|
||||
* })
|
||||
* .then(({ notifications, count, limit, offset }) => {
|
||||
* console.log(notifications)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
|
||||
*/
|
||||
async list(
|
||||
query?: HttpTypes.AdminNotificationListParams,
|
||||
headers?: ClientHeaders
|
||||
|
||||
@@ -14,12 +14,30 @@ export class OrderEdit {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates an order edit request. It sends a HTTP request to the
|
||||
* [Create Order Edit](https://docs.medusajs.com/api/admin#order-edits_postorderedits)
|
||||
* API route.
|
||||
*
|
||||
* @param body - The order edit's details.
|
||||
* @param query - Configure the fields to retrieve in the order edit.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The order edit's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.orderEdit.initiateRequest({
|
||||
* order_id: "order_123"
|
||||
* })
|
||||
* .then(({ order_change }) => {
|
||||
* console.log(order_change)
|
||||
* })
|
||||
*/
|
||||
async initiateRequest(
|
||||
body: HttpTypes.AdminInitiateOrderEditRequest,
|
||||
query?: HttpTypes.SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminOrderEditPreviewResponse>(
|
||||
return await this.client.fetch<HttpTypes.AdminOrderEditResponse>(
|
||||
`/admin/order-edits`,
|
||||
{
|
||||
method: "POST",
|
||||
@@ -30,6 +48,22 @@ export class OrderEdit {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method changes an order edit to requested. It sends a request to the
|
||||
* [Request Order Edit](https://docs.medusajs.com/api/admin#order-edits_postordereditsidrequest)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The order edit's ID.
|
||||
* @param query - Configure the fields to retrieve in the order preview.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The order preview's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.orderEdit.request("ordch_123")
|
||||
* .then(({ order_preview }) => {
|
||||
* console.log(order_preview)
|
||||
* })
|
||||
*/
|
||||
async request(
|
||||
id: string,
|
||||
query?: HttpTypes.SelectParams,
|
||||
@@ -45,6 +79,22 @@ export class OrderEdit {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method confirms an order edit and applies it on the order. It sends a request
|
||||
* to the [Confirm Order Edit](https://docs.medusajs.com/api/admin#order-edits_postordereditsidconfirm)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The order edit's ID.
|
||||
* @param query - Configure the fields to retrieve in the order preview.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The order preview's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.orderEdit.confirm("ordch_123")
|
||||
* .then(({ order_preview }) => {
|
||||
* console.log(order_preview)
|
||||
* })
|
||||
*/
|
||||
async confirm(
|
||||
id: string,
|
||||
query?: HttpTypes.SelectParams,
|
||||
@@ -60,6 +110,22 @@ export class OrderEdit {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method cancels a requested order edit. It sends a request to the
|
||||
* [Cancel Order Edit](https://docs.medusajs.com/api/admin#order-edits_deleteordereditsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The order edit's ID.
|
||||
* @param query - Query parameters
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The deletion's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.orderEdit.cancelRequest("ordch_123")
|
||||
* .then(({ deleted }) => {
|
||||
* console.log(deleted)
|
||||
* })
|
||||
*/
|
||||
async cancelRequest(
|
||||
id: string,
|
||||
query?: HttpTypes.SelectParams,
|
||||
@@ -75,6 +141,31 @@ export class OrderEdit {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds items to an order edit. These items will have the action `ITEM_ADD`.
|
||||
*
|
||||
* The method sends a request to the [Add Items](https://docs.medusajs.com/api/admin#order-edits_postordereditsiditems)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The order edit's ID.
|
||||
* @param body - The items to add.
|
||||
* @param query - Configure the fields to retrieve in the order preview.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The order preview's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.orderEdit.addItems("ordch_123", {
|
||||
* items: [
|
||||
* {
|
||||
* variant_id: "variant_123",
|
||||
* quantity: 1
|
||||
* }
|
||||
* ]
|
||||
* })
|
||||
* .then(({ order_preview }) => {
|
||||
* console.log(order_preview)
|
||||
* })
|
||||
*/
|
||||
async addItems(
|
||||
id: string,
|
||||
body: HttpTypes.AdminAddOrderEditItems,
|
||||
@@ -92,6 +183,30 @@ export class OrderEdit {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates the quantity and other details of an item in an order. It sends a request to the
|
||||
* [Update Item Quantity](https://docs.medusajs.com/api/admin#order-edits_postordereditsiditemsitemitem_id)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The order edit's ID.
|
||||
* @param itemId - The item's ID in the order.
|
||||
* @param body - The data to edit in the item.
|
||||
* @param query - Configure the fields to retrieve in the order preview.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The order preview's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.orderEdit.updateOriginalItem(
|
||||
* "ordch_123",
|
||||
* "orli_123",
|
||||
* {
|
||||
* quantity: 1
|
||||
* }
|
||||
* )
|
||||
* .then(({ order_preview }) => {
|
||||
* console.log(order_preview)
|
||||
* })
|
||||
*/
|
||||
async updateOriginalItem(
|
||||
id: string,
|
||||
itemId: string,
|
||||
@@ -110,6 +225,35 @@ export class OrderEdit {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method updates an added item in the order edit by the ID of the item's `ITEM_ADD` action.
|
||||
*
|
||||
* Every item has an `actions` property, whose value is an array of actions.
|
||||
* You can check the action's name using its `action` property, and use the value of the `id` property.
|
||||
*
|
||||
* It sends a request
|
||||
* to the [Update Item](https://docs.medusajs.com/api/admin#order-edits_postordereditsiditemsaction_id)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The order edit's ID.
|
||||
* @param actionId - The id of the new item's `ITEM_ADD` action.
|
||||
* @param body - The data to update.
|
||||
* @param query - Configure the fields to retrieve in the order preview.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The order preview's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.orderEdit.updateAddedItem(
|
||||
* "ordch_123",
|
||||
* "orli_123",
|
||||
* {
|
||||
* quantity: 1
|
||||
* }
|
||||
* )
|
||||
* .then(({ order_preview }) => {
|
||||
* console.log(order_preview)
|
||||
* })
|
||||
*/
|
||||
async updateAddedItem(
|
||||
id: string,
|
||||
actionId: string,
|
||||
@@ -128,6 +272,27 @@ export class OrderEdit {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method removes an added item in the order edit by the ID of the item's `ITEM_ADD` action.
|
||||
*
|
||||
* Every item has an `actions` property, whose value is an array of actions.
|
||||
* You can check the action's name using its `action` property, and use the value of the `id` property.
|
||||
*
|
||||
* @param id - The order edit's ID.
|
||||
* @param actionId - The id of the new item's `ITEM_ADD` action.
|
||||
* @param query - Configure the fields to retrieve in the order preview.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The order preview's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.orderEdit.removeAddedItem(
|
||||
* "ordch_123",
|
||||
* "orli_123",
|
||||
* )
|
||||
* .then(({ order_preview }) => {
|
||||
* console.log(order_preview)
|
||||
* })
|
||||
*/
|
||||
async removeAddedItem(
|
||||
id: string,
|
||||
actionId: string,
|
||||
|
||||
@@ -21,8 +21,41 @@ export class Order {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* 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"
|
||||
* })
|
||||
* .then(({ 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) {
|
||||
return await this.client.fetch<{ order: HttpTypes.AdminOrder }>(
|
||||
return await this.client.fetch<HttpTypes.AdminOrderResponse>(
|
||||
`/admin/orders/${id}`,
|
||||
{
|
||||
query,
|
||||
@@ -31,6 +64,21 @@ export class Order {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 }) => {
|
||||
* console.log(order)
|
||||
* })
|
||||
*/
|
||||
async retrievePreview(
|
||||
id: string,
|
||||
query?: HttpTypes.AdminOrderFilters,
|
||||
@@ -45,20 +93,81 @@ export class Order {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,
|
||||
* offset: 10
|
||||
* })
|
||||
* .then(({ orders, count, limit, offset }) => {
|
||||
* 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"
|
||||
* })
|
||||
* .then(({ orders, count, limit, offset }) => {
|
||||
* 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?: FindParams & HttpTypes.AdminOrderFilters,
|
||||
queryParams?: HttpTypes.AdminOrderFilters,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<
|
||||
PaginatedResponse<{ orders: HttpTypes.AdminOrder[] }>
|
||||
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 }) => {
|
||||
* console.log(order)
|
||||
* })
|
||||
*/
|
||||
async cancel(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<{ order: HttpTypes.AdminOrder }>(
|
||||
return await this.client.fetch<HttpTypes.AdminOrderResponse>(
|
||||
`/admin/orders/${id}/cancel`,
|
||||
{
|
||||
method: "POST",
|
||||
@@ -67,13 +176,37 @@ export class Order {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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: [
|
||||
* {
|
||||
* id: "orli_123",
|
||||
* quantity: 1
|
||||
* }
|
||||
* ]
|
||||
* })
|
||||
* .then(({ order }) => {
|
||||
* console.log(order)
|
||||
* })
|
||||
*/
|
||||
async createFulfillment(
|
||||
id: string,
|
||||
body: HttpTypes.AdminCreateOrderFulfillment,
|
||||
query?: SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<{ order: HttpTypes.AdminOrder }>(
|
||||
return await this.client.fetch<HttpTypes.AdminOrderResponse>(
|
||||
`/admin/orders/${id}/fulfillments`,
|
||||
{
|
||||
method: "POST",
|
||||
@@ -84,13 +217,36 @@ 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",
|
||||
* "ful_123",
|
||||
* {
|
||||
* no_notification: false
|
||||
* }
|
||||
* )
|
||||
* .then(({ order }) => {
|
||||
* console.log(order)
|
||||
* })
|
||||
*/
|
||||
async cancelFulfillment(
|
||||
id: string,
|
||||
fulfillmentId: string,
|
||||
body: HttpTypes.AdminCancelOrderFulfillment,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<{ order: HttpTypes.AdminOrder }>(
|
||||
return await this.client.fetch<HttpTypes.AdminOrderResponse>(
|
||||
`/admin/orders/${id}/fulfillments/${fulfillmentId}/cancel`,
|
||||
{
|
||||
method: "POST",
|
||||
@@ -100,6 +256,35 @@ 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",
|
||||
* "ful_123",
|
||||
* {
|
||||
* items: [
|
||||
* {
|
||||
* id: "fulit_123",
|
||||
* quantity: 1
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* )
|
||||
* .then(({ order }) => {
|
||||
* console.log(order)
|
||||
* })
|
||||
*/
|
||||
async createShipment(
|
||||
id: string,
|
||||
fulfillmentId: string,
|
||||
@@ -107,7 +292,7 @@ export class Order {
|
||||
query?: SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<{ order: HttpTypes.AdminOrder }>(
|
||||
return await this.client.fetch<HttpTypes.AdminOrderResponse>(
|
||||
`/admin/orders/${id}/fulfillments/${fulfillmentId}/shipments`,
|
||||
{
|
||||
method: "POST",
|
||||
@@ -118,6 +303,28 @@ 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",
|
||||
* "ful_123",
|
||||
* {}
|
||||
* )
|
||||
* .then(({ order }) => {
|
||||
* console.log(order)
|
||||
* })
|
||||
*/
|
||||
async markAsDelivered(
|
||||
id: string,
|
||||
fulfillmentId: string,
|
||||
@@ -125,7 +332,7 @@ export class Order {
|
||||
query?: SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<{ order: HttpTypes.AdminOrder }>(
|
||||
return await this.client.fetch<HttpTypes.AdminOrderResponse>(
|
||||
`/admin/orders/${id}/fulfillments/${fulfillmentId}/mark-as-delivered`,
|
||||
{
|
||||
method: "POST",
|
||||
@@ -136,6 +343,23 @@ 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 }) => {
|
||||
* console.log(order_changes)
|
||||
* })
|
||||
*/
|
||||
async listChanges(
|
||||
id: string,
|
||||
queryParams?: FindParams & HttpTypes.AdminOrderChangesFilters,
|
||||
@@ -149,13 +373,29 @@ 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 }) => {
|
||||
* console.log(order_items)
|
||||
* })
|
||||
*/
|
||||
async listLineItems(
|
||||
id: string,
|
||||
queryParams?: FindParams & HttpTypes.AdminOrderItemsFilters,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<
|
||||
PaginatedResponse<HttpTypes.AdminOrderLineItemsListResponse>
|
||||
HttpTypes.AdminOrderLineItemsListResponse
|
||||
>(`/admin/orders/${id}/line-items`, {
|
||||
query: queryParams,
|
||||
headers,
|
||||
|
||||
@@ -14,6 +14,24 @@ export class PaymentCollection {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a payment collection. It sends a request to the
|
||||
* [Create Payment Collection](https://docs.medusajs.com/api/admin#payment-collections_postpaymentcollections)
|
||||
* API route.
|
||||
*
|
||||
* @param body - The details of the payment collection to create.
|
||||
* @param query - Configure the fields to retrieve in the payment collection.
|
||||
* @param headers - Headers to pass in the request
|
||||
* @returns The payment collection's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.paymentCollection.create({
|
||||
* order_id: "order_123"
|
||||
* })
|
||||
* .then(({ payment_collection }) => {
|
||||
* console.log(payment_collection)
|
||||
* })
|
||||
*/
|
||||
async create(
|
||||
body: HttpTypes.AdminCreatePaymentCollection,
|
||||
query?: SelectParams,
|
||||
@@ -30,6 +48,21 @@ export class PaymentCollection {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method deletes a payment collection. It sends a request to the
|
||||
* [Delete Payment Collection](https://docs.medusajs.com/api/admin#payment-collections_deletepaymentcollectionsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The payment collection's ID.
|
||||
* @param headers - Headers to pass in the request
|
||||
* @returns The deletion's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.paymentCollection.delete("paycol_123")
|
||||
* .then(({ deleted }) => {
|
||||
* console.log(deleted)
|
||||
* })
|
||||
*/
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminDeletePaymentCollectionResponse>(
|
||||
`/admin/payment-collections/${id}`,
|
||||
@@ -40,6 +73,28 @@ export class PaymentCollection {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method marks a payment collection as paid. It sends a request to the
|
||||
* [Mark as Paid](https://docs.medusajs.com/api/admin#payment-collections_postpaymentcollectionsidmarkaspaid)
|
||||
* API route.
|
||||
*
|
||||
* The API route creates and authorizes a payment session, then capture its payment,
|
||||
* using the manual payment provider.
|
||||
*
|
||||
* @param id - The payment collection to mark as paid.
|
||||
* @param body - The details to mark the payment collection as paid.
|
||||
* @param query - Configure the fields to retrieve in the payment collection.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The payment collection's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.paymentCollection.markAsPaid("paycol_123", {
|
||||
* order_id: "order_123"
|
||||
* })
|
||||
* .then(({ payment_collection }) => {
|
||||
* console.log(payment_collection)
|
||||
* })
|
||||
*/
|
||||
async markAsPaid(
|
||||
id: string,
|
||||
body: HttpTypes.AdminMarkPaymentCollectionAsPaid,
|
||||
|
||||
@@ -14,6 +14,52 @@ export class Payment {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a paginated list of payments. It sends a request to the
|
||||
* [List Payments](https://docs.medusajs.com/api/admin#payments_getpayments) API route.
|
||||
*
|
||||
* @param query - Filters and pagination configurations.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The paginated list of payments.
|
||||
*
|
||||
* @example
|
||||
* To retrieve the list of payments:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.payment.list()
|
||||
* .then(({ payments, count, limit, offset }) => {
|
||||
* console.log(payments)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* 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.payment.list({
|
||||
* limit: 10,
|
||||
* offset: 10
|
||||
* })
|
||||
* .then(({ payments, count, limit, offset }) => {
|
||||
* console.log(payments)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
* in each payment:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.payment.list({
|
||||
* fields: "id,*payment_collection"
|
||||
* })
|
||||
* .then(({ payments, count, limit, offset }) => {
|
||||
* console.log(payments)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
|
||||
*/
|
||||
async list(query?: HttpTypes.AdminPaymentFilters, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminPaymentsResponse>(
|
||||
`/admin/payments`,
|
||||
@@ -24,6 +70,52 @@ export class Payment {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a paginated list of payment providers. It sends a request to the
|
||||
* [List Payment Providers](https://docs.medusajs.com/api/admin#payments_getpaymentspaymentproviders) API route.
|
||||
*
|
||||
* @param query - Filters and pagination configurations.
|
||||
* @param headers - Headers to pass in the request.
|
||||
* @returns The paginated list of payment providers.
|
||||
*
|
||||
* @example
|
||||
* To retrieve the list of payment providers:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.payment.listPaymentProviders()
|
||||
* .then(({ payment_providers, count, limit, offset }) => {
|
||||
* console.log(payment_providers)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* 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.payment.listPaymentProviders({
|
||||
* limit: 10,
|
||||
* offset: 10
|
||||
* })
|
||||
* .then(({ payment_providers, count, limit, offset }) => {
|
||||
* console.log(payment_providers)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Using the `fields` query parameter, you can specify the fields and relations to retrieve
|
||||
* in each payment provider:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.payment.listPaymentProviders({
|
||||
* fields: "id,is_enabled"
|
||||
* })
|
||||
* .then(({ payment_providers, count, limit, offset }) => {
|
||||
* console.log(payment_providers)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* Learn more about the `fields` property in the [API reference](https://docs.medusajs.com/api/store#select-fields-and-relations).
|
||||
*/
|
||||
async listPaymentProviders(
|
||||
query?: HttpTypes.AdminGetPaymentProvidersParams,
|
||||
headers?: ClientHeaders
|
||||
@@ -37,9 +129,42 @@ export class Payment {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method retrieves a payment's details. It sends a request to the
|
||||
* [Get Payment](https://docs.medusajs.com/api/admin#payments_getpaymentsid)
|
||||
* API route.
|
||||
*
|
||||
* @param id - The payment's ID.
|
||||
* @param query - Configure the fields to retrieve in the payment.
|
||||
* @param headers - Headers to pass in the request
|
||||
* @returns The payment's details.
|
||||
*
|
||||
* @example
|
||||
* To retrieve a payment by its ID:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.payment.retrieve("pay_123")
|
||||
* .then(({ payment }) => {
|
||||
* console.log(payment)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* To specify the fields and relations to retrieve:
|
||||
*
|
||||
* ```ts
|
||||
* sdk.admin.payment.retrieve("pay_123", {
|
||||
* fields: "id,*payment_collection"
|
||||
* })
|
||||
* .then(({ payment }) => {
|
||||
* console.log(payment)
|
||||
* })
|
||||
* ```
|
||||
*
|
||||
* 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?: HttpTypes.AdminPaymentFilters,
|
||||
query?: SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminPaymentResponse>(
|
||||
@@ -51,6 +176,24 @@ export class Payment {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method captures a payment. It sends a request to the
|
||||
* [Capture Payment](https://docs.medusajs.com/api/admin#payments_postpaymentsidcapture) API route.
|
||||
*
|
||||
* The API route uses the `capturePayment` method of the payment provider associated with the payment's collection.
|
||||
*
|
||||
* @param id - The payment's ID.
|
||||
* @param body - The capture's details.
|
||||
* @param query - Configure the fields to retrieve in the payment.
|
||||
* @param headers - Headers to pass in the request
|
||||
* @returns The payment's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.payment.capture("paycol_123", {})
|
||||
* .then(({ payment }) => {
|
||||
* console.log(payment)
|
||||
* })
|
||||
*/
|
||||
async capture(
|
||||
id: string,
|
||||
body: HttpTypes.AdminCapturePayment,
|
||||
@@ -68,6 +211,24 @@ export class Payment {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* This method refunds a payment. It sends a request to the
|
||||
* [Refund Payment](https://docs.medusajs.com/api/admin#payments_postpaymentsidrefund) API route.
|
||||
*
|
||||
* The API route uses the `refundPayment` method of the payment provider associated with the payment's collection.
|
||||
*
|
||||
* @param id - The payment's ID.
|
||||
* @param body - The refund's details.
|
||||
* @param query - Configure the fields to retrieve in the payment.
|
||||
* @param headers - Headers to pass in the request
|
||||
* @returns The payment's details.
|
||||
*
|
||||
* @example
|
||||
* sdk.admin.payment.refund("paycol_123", {})
|
||||
* .then(({ payment }) => {
|
||||
* console.log(payment)
|
||||
* })
|
||||
*/
|
||||
async refund(
|
||||
id: string,
|
||||
body: HttpTypes.AdminRefundPayment,
|
||||
|
||||
Reference in New Issue
Block a user