Skip to main content

IOrderReturnRequestModuleService Reference

This section of the documentation provides a reference to the IOrderReturnRequestModuleService interface’s methods. This is the interface developers use to use the functionalities provided by the Order Return Request Module.
You should only use the methods in this reference when implementing complex customizations. For common cases, check out available workflows instead.
The main service interface for the Order Return Request Module.

Methods

Order Return Request Methods

Order Return Request Line Item Methods


createOrderReturnRequests

This section provides a reference to the createOrderReturnRequests method. This belongs to the Order Return Request Module.

createOrderReturnRequests(data, sharedContext?): Promise<OrderReturnRequestDTO[]>

This method creates order return requests.

Example

const returnRequests = await orderReturnRequestModuleService.createOrderReturnRequests([
  {
    order_id: "ord_123",
    customer_id: "cus_123",
    customer_note: "Product arrived damaged",
    shipping_option_id: "so_123",
    line_items: [
      { line_item_id: "ordli_123", quantity: 1, reason_id: "reason_123" },
    ],
  },
])

Parameters

data
CreateOrderReturnRequestDTO[]
required
The order return requests to be created.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<OrderReturnRequestDTO[]>
The created order return requests.

createOrderReturnRequests(data, sharedContext?): Promise<OrderReturnRequestDTO>

This method creates an order return request.

Example

const returnRequest = await orderReturnRequestModuleService.createOrderReturnRequests({
  order_id: "ord_123",
  customer_id: "cus_123",
  customer_note: "Product arrived damaged",
  shipping_option_id: "so_123",
  line_items: [
    { line_item_id: "ordli_123", quantity: 1, reason_id: "reason_123" },
  ],
})

Parameters

data
CreateOrderReturnRequestDTO
required
The order return request to be created.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<OrderReturnRequestDTO>
The created order return request.

updateOrderReturnRequests

This section provides a reference to the updateOrderReturnRequests method. This belongs to the Order Return Request Module.

updateOrderReturnRequests(id, data, sharedContext?): Promise<OrderReturnRequestDTO>

This method updates an existing order return request.

Example

Vendor reviewing a return request:
const returnRequest = await orderReturnRequestModuleService.updateOrderReturnRequests("oretreq_123", {
  vendor_reviewer_id: "mem_123",
  vendor_reviewer_note: "Approved for return",
  vendor_review_date: new Date(),
  status: "refunded",
})
Admin reviewing an escalated return request:
const returnRequest = await orderReturnRequestModuleService.updateOrderReturnRequests("oretreq_123", {
  admin_reviewer_id: "user_123",
  admin_reviewer_note: "Customer is right, approve the return",
  admin_review_date: new Date(),
  status: "refunded",
})

Parameters

id
string
required
The ID of the order return request.
data
UpdateOrderReturnRequestDTO
required
The attributes to update in the order return request.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<OrderReturnRequestDTO>
The updated order return request.

deleteOrderReturnRequests

This section provides a reference to the deleteOrderReturnRequests method. This belongs to the Order Return Request Module.

deleteOrderReturnRequests(ids, sharedContext?): Promise<void>

This method deletes order return requests by their IDs.

Example

await orderReturnRequestModuleService.deleteOrderReturnRequests(["oretreq_123", "oretreq_321"])

Parameters

ids
string[]
required
The IDs of the order return requests.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void>
Resolves when the order return requests are deleted successfully.

deleteOrderReturnRequests(id, sharedContext?): Promise<void>

This method deletes an order return request by its ID.

Example

await orderReturnRequestModuleService.deleteOrderReturnRequests("oretreq_123")

Parameters

id
string
required
The ID of the order return request.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void>
Resolves when the order return request is deleted successfully.

retrieveOrderReturnRequest

This section provides a reference to the retrieveOrderReturnRequest method. This belongs to the Order Return Request Module. This method retrieves an order return request by its ID.

Example

const returnRequest = await orderReturnRequestModuleService.retrieveOrderReturnRequest("oretreq_123")
To retrieve with line items:
const returnRequest = await orderReturnRequestModuleService.retrieveOrderReturnRequest(
  "oretreq_123",
  {
    relations: ["line_items"],
  }
)

Parameters

id
string
required
The ID of the order return request.
config
FindConfig<OrderReturnRequestDTO>
The configurations determining how the order return request is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<OrderReturnRequestDTO>
The retrieved order return request.

listOrderReturnRequests

This section provides a reference to the listOrderReturnRequests method. This belongs to the Order Return Request Module. This method retrieves a paginated list of order return requests based on optional filters and configuration.

Example

To retrieve pending return requests:
const returnRequests = await orderReturnRequestModuleService.listOrderReturnRequests({
  status: "pending",
})
To retrieve return requests for a specific customer:
const returnRequests = await orderReturnRequestModuleService.listOrderReturnRequests({
  customer_id: "cus_123",
})
By default, only the first 15 records are retrieved. You can control pagination:
const returnRequests = await orderReturnRequestModuleService.listOrderReturnRequests(
  {
    status: "pending",
  },
  {
    take: 20,
    skip: 2,
    relations: ["line_items"],
  }
)

Parameters

filters
FilterableOrderReturnRequestProps
The filters to apply on the retrieved order return requests.
config
FindConfig<OrderReturnRequestDTO>
The configurations determining how the order return request is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<OrderReturnRequestDTO[]>
The list of order return requests.

listAndCountOrderReturnRequests

This section provides a reference to the listAndCountOrderReturnRequests method. This belongs to the Order Return Request Module. This method retrieves a paginated list of order return requests along with the total count of available order return requests satisfying the provided filters.

Example

const [returnRequests, count] = await orderReturnRequestModuleService.listAndCountOrderReturnRequests({
  status: "pending",
})

Parameters

filters
FilterableOrderReturnRequestProps
The filters to apply on the retrieved order return requests.
config
FindConfig<OrderReturnRequestDTO>
The configurations determining how the order return request is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<[OrderReturnRequestDTO[], number]>
The list of order return requests along with their total count.

softDeleteOrderReturnRequests

This section provides a reference to the softDeleteOrderReturnRequests method. This belongs to the Order Return Request Module. This method soft deletes order return requests by their IDs.

Example

await orderReturnRequestModuleService.softDeleteOrderReturnRequests([
  "oretreq_123",
  "oretreq_321",
])

Parameters

orderReturnRequestIds
string[]
required
The IDs of the order return requests.
config
SoftDeleteReturn<TReturnableLinkableKeys>
An object that is used to specify an entity’s related entities that should be soft-deleted when the main entity is soft-deleted.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void | Record<string, string[]>>
An object that includes the IDs of related records that were also soft deleted. If there are no related records, the promise resolves to void.

restoreOrderReturnRequests

This section provides a reference to the restoreOrderReturnRequests method. This belongs to the Order Return Request Module. This method restores soft deleted order return requests by their IDs.

Example

await orderReturnRequestModuleService.restoreOrderReturnRequests(["oretreq_123", "oretreq_321"])

Parameters

orderReturnRequestIds
string[]
required
The IDs of the order return requests.
config
RestoreReturn<TReturnableLinkableKeys>
Configurations determining which relations to restore along with each of the order return request.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void | Record<string, string[]>>
An object that includes the IDs of related records that were restored. If there are no related records restored, the promise resolves to void.

createOrderReturnRequestLineItems

This section provides a reference to the createOrderReturnRequestLineItems method. This belongs to the Order Return Request Module.

createOrderReturnRequestLineItems(data, sharedContext?): Promise<OrderReturnRequestLineItemDTO[]>

This method creates order return request line items.

Example

const lineItems = await orderReturnRequestModuleService.createOrderReturnRequestLineItems([
  {
    return_request_id: "oretreq_123",
    line_item_id: "ordli_123",
    quantity: 2,
    reason_id: "reason_123",
  },
])

Parameters

data
CreateOrderReturnRequestLineItemDTO[]
required
The order return request line items to be created.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<OrderReturnRequestLineItemDTO[]>
The created order return request line items.

updateOrderReturnRequestLineItems

This section provides a reference to the updateOrderReturnRequestLineItems method. This belongs to the Order Return Request Module.

updateOrderReturnRequestLineItems(id, data, sharedContext?): Promise<OrderReturnRequestLineItemDTO>

This method updates an existing order return request line item.

Example

const lineItem = await orderReturnRequestModuleService.updateOrderReturnRequestLineItems("oretreqli_123", {
  quantity: 1,
})

Parameters

id
string
required
The ID of the order return request line item.
data
UpdateOrderReturnRequestLineItemDTO
required
The attributes to update in the order return request line item.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<OrderReturnRequestLineItemDTO>
The updated order return request line item.

deleteOrderReturnRequestLineItems

This section provides a reference to the deleteOrderReturnRequestLineItems method. This belongs to the Order Return Request Module.

deleteOrderReturnRequestLineItems(ids, sharedContext?): Promise<void>

This method deletes order return request line items by their IDs.

Example

await orderReturnRequestModuleService.deleteOrderReturnRequestLineItems(["oretreqli_123", "oretreqli_321"])

Parameters

ids
string[]
required
The IDs of the order return request line items.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void>
Resolves when the order return request line items are deleted successfully.

retrieveOrderReturnRequestLineItem

This section provides a reference to the retrieveOrderReturnRequestLineItem method. This belongs to the Order Return Request Module. This method retrieves an order return request line item by its ID.

Example

const lineItem = await orderReturnRequestModuleService.retrieveOrderReturnRequestLineItem("oretreqli_123")
To retrieve with the return request:
const lineItem = await orderReturnRequestModuleService.retrieveOrderReturnRequestLineItem(
  "oretreqli_123",
  {
    relations: ["return_request"],
  }
)

Parameters

id
string
required
The ID of the order return request line item.
config
FindConfig<OrderReturnRequestLineItemDTO>
The configurations determining how the order return request line item is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<OrderReturnRequestLineItemDTO>
The retrieved order return request line item.

listOrderReturnRequestLineItems

This section provides a reference to the listOrderReturnRequestLineItems method. This belongs to the Order Return Request Module. This method retrieves a paginated list of order return request line items based on optional filters and configuration.

Example

To retrieve line items for a specific return request:
const lineItems = await orderReturnRequestModuleService.listOrderReturnRequestLineItems({
  return_request_id: "oretreq_123",
})
To retrieve line items for specific order line items:
const lineItems = await orderReturnRequestModuleService.listOrderReturnRequestLineItems({
  line_item_id: ["ordli_123", "ordli_456"],
})

Parameters

filters
FilterableOrderReturnRequestLineItemProps
The filters to apply on the retrieved order return request line items.
config
FindConfig<OrderReturnRequestLineItemDTO>
The configurations determining how the order return request line item is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<OrderReturnRequestLineItemDTO[]>
The list of order return request line items.

listAndCountOrderReturnRequestLineItems

This section provides a reference to the listAndCountOrderReturnRequestLineItems method. This belongs to the Order Return Request Module. This method retrieves a paginated list of order return request line items along with the total count of available order return request line items satisfying the provided filters.

Example

const [lineItems, count] = await orderReturnRequestModuleService.listAndCountOrderReturnRequestLineItems({
  return_request_id: "oretreq_123",
})

Parameters

filters
FilterableOrderReturnRequestLineItemProps
The filters to apply on the retrieved order return request line items.
config
FindConfig<OrderReturnRequestLineItemDTO>
The configurations determining how the order return request line item is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<[OrderReturnRequestLineItemDTO[], number]>
The list of order return request line items along with their total count.

softDeleteOrderReturnRequestLineItems

This section provides a reference to the softDeleteOrderReturnRequestLineItems method. This belongs to the Order Return Request Module. This method soft deletes order return request line items by their IDs.

Example

await orderReturnRequestModuleService.softDeleteOrderReturnRequestLineItems([
  "oretreqli_123",
  "oretreqli_321",
])

Parameters

orderReturnRequestLineItemIds
string[]
required
The IDs of the order return request line items.
config
SoftDeleteReturn<TReturnableLinkableKeys>
An object that is used to specify an entity’s related entities that should be soft-deleted when the main entity is soft-deleted.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void | Record<string, string[]>>
An object that includes the IDs of related records that were also soft deleted. If there are no related records, the promise resolves to void.

restoreOrderReturnRequestLineItems

This section provides a reference to the restoreOrderReturnRequestLineItems method. This belongs to the Order Return Request Module. This method restores soft deleted order return request line items by their IDs.

Example

await orderReturnRequestModuleService.restoreOrderReturnRequestLineItems(["oretreqli_123", "oretreqli_321"])

Parameters

orderReturnRequestLineItemIds
string[]
required
The IDs of the order return request line items.
config
RestoreReturn<TReturnableLinkableKeys>
Configurations determining which relations to restore along with each of the order return request line item.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void | Record<string, string[]>>
An object that includes the IDs of related records that were restored. If there are no related records restored, the promise resolves to void.