ReturnService
internal.internal.ReturnService
Properties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequiredAccessors
activeManager_
Protected
get
activeManager_(): EntityManager
Returns
EntityManager
EntityManager
EntityManagerRequiredInherited from
TransactionBaseService.activeManager_
Methods
atomicPhase_
Protected
atomicPhase_<TResult
, TError
>(work
, isolationOrErrorHandler?
, maybeErrorHandlerOrDontFail?
): Promise
<TResult
>
Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created.
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
<TResult
>
Promise
Promise<TResult>RequiredInherited from
TransactionBaseService.atomicPhase_
cancel
cancel(returnId
): Promise
<Return
>
Cancels a return if possible. Returns can be canceled if it has not been received.
Parameters
returnId
stringRequiredReturns
Promise
<Return
>
the updated Return
create
create(data
): Promise
<Return
>
Creates a return request for an order, with given items, and a shipping method. If no refund amount is provided the refund amount is calculated from the return lines and the shipping cost.
Parameters
Returns
Promise
<Return
>
the created return
fulfill
fulfill(returnId
): Promise
<Return
>
Parameters
returnId
stringRequiredReturns
Promise
<Return
>
getFulfillmentItems
Protected
getFulfillmentItems(order
, items
, transformer
): Promise
<LineItem
& { note?
: string
; reason_id?
: string
}[]>
Retrieves the order line items, given an array of items
Parameters
Returns
Promise
<LineItem
& { note?
: string
; reason_id?
: string
}[]>
the line items generated by the transformer.
list
list(selector
, config?
): Promise
<Return
[]>
Parameters
config
FindConfig<Return>Returns
Promise
<Return
[]>
the result of the find operation
listAndCount
listAndCount(selector
, config?
): Promise
<[Return
[], number
]>
Parameters
config
FindConfig<Return>Returns
Promise
<[Return
[], number
]>
the result of the find operation
receive
receive(returnId
, receivedItems
, refundAmount?
, allowMismatch?
, context?
): Promise
<Return
>
Registers a previously requested return as received. This will create a refund to the customer. If the returned items don't match the requested items the return status will be updated to requires_action. This behaviour is useful in situations where a custom refund amount is requested, but the returned items are not matching the requested items. Setting the allowMismatch argument to true, will process the return, ignoring any mismatches.
Parameters
returnId
stringRequiredrefundAmount
numberallowMismatch
booleancontext
objectcontext.locationId
stringReturns
Promise
<Return
>
the result of the update operation
retrieve
retrieve(returnId
, config?
): Promise
<Return
>
Retrieves a return by its id.
Parameters
returnId
stringRequiredconfig
FindConfig<Return>Returns
Promise
<Return
>
the return
retrieveBySwap
retrieveBySwap(swapId
, relations?
): Promise
<Return
>
Parameters
swapId
stringRequiredrelations
string[]Returns
Promise
<Return
>
shouldRetryTransaction_
Protected
shouldRetryTransaction_(err
): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleanInherited from
TransactionBaseService.shouldRetryTransaction_
update
update(returnId
, update
): Promise
<Return
>
Parameters
returnId
stringRequiredReturns
Promise
<Return
>
validateReturnLineItem
Protected
validateReturnLineItem(item?
, quantity?
, additional?
): DeepPartial
<LineItem
>
Checks that a given quantity of a line item can be returned. Fails if the item is undefined or if the returnable quantity of the item is lower, than the quantity that is requested to be returned.
Parameters
item
LineItemquantity
numberadditional
objectadditional.note
stringadditional.reason_id
stringReturns
DeepPartial
<LineItem
>
a line item where the quantity is set to the requested
return quantity.
validateReturnStatuses
Protected
validateReturnStatuses(order
): void
Checks that an order has the statuses necessary to complete a return. fulfillment_status cannot be not_fulfilled or returned. payment_status must be captured.
Parameters
Returns
void
void
voidThrows
when statuses are not sufficient for returns.
withTransaction
withTransaction(transactionManager?
): ReturnService
Parameters
transactionManager
EntityManager