Skip to main content
Skip to main content

ClaimService

Constructors

constructor

**new ClaimService**(«destructured»)

Parameters

__namedParametersInjectedDependenciesRequired

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
addressRepository_Repository<Address>Required
claimItemService_ClaimItemServiceRequired
claimRepository_Repository<ClaimOrder>Required
eventBus_EventBusServiceRequired
fulfillmentProviderService_FulfillmentProviderServiceRequired
fulfillmentService_FulfillmentServiceRequired
lineItemRepository_Repository<LineItem> & &#123; findByReturn: Method findByReturn &#125;Required
lineItemService_LineItemServiceRequired
manager_EntityManagerRequired
paymentProviderService_PaymentProviderServiceRequired
productVariantInventoryService_ProductVariantInventoryServiceRequired
regionService_RegionServiceRequired
returnService_ReturnServiceRequired
shippingMethodRepository_Repository<ShippingMethod>Required
shippingOptionService_ShippingOptionServiceRequired
taxProviderService_TaxProviderServiceRequired
totalsService_TotalsServiceRequired
transactionManager_undefined | EntityManagerRequired
EventsobjectRequired
Events.CANCELEDstringRequired

Default: "claim.canceled"

Events.CREATEDstringRequired

Default: "claim.created"

Events.FULFILLMENT_CREATEDstringRequired

Default: "claim.fulfillment_created"

Events.REFUND_PROCESSEDstringRequired

Default: "claim.refund_processed"

Events.SHIPMENT_CREATEDstringRequired

Default: "claim.shipment_created"

Events.UPDATEDstringRequired

Default: "claim.updated"

Accessors

activeManager_

Protected get**activeManager_**(): EntityManager

Returns

EntityManager

EntityManagerEntityManagerRequired

Methods

atomicPhase_

Protected **atomicPhase_**<TypeParameter TResult, TypeParameter TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise&#60;TResult&#62;

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.

TResultobjectRequired
TErrorobjectRequired

Parameters

work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>
the isolation level to be used for the work.
maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>
Potential error handler

Returns

Promise<TResult>

PromisePromise<TResult>Required
the result of the transactional work

cancel

**cancel**(id): Promise&#60;[ClaimOrder](/references/services/classes/ClaimOrder)&#62;

Parameters

idstringRequired

Returns

Promise<ClaimOrder>

PromisePromise<ClaimOrder>Required

cancelFulfillment

**cancelFulfillment**(fulfillmentId): Promise&#60;[ClaimOrder](/references/services/classes/ClaimOrder)&#62;

Parameters

fulfillmentIdstringRequired

Returns

Promise<ClaimOrder>

PromisePromise<ClaimOrder>Required

create

**create**(data): Promise&#60;[ClaimOrder](/references/services/classes/ClaimOrder)&#62;

Creates a Claim on an Order. Claims consists of items that are claimed and optionally items to be sent as replacement for the claimed items. The shipping address that the new items will be shipped to

Parameters

dataCreateClaimInputRequired
the object containing all data required to create a claim

Returns

Promise<ClaimOrder>

PromisePromise<ClaimOrder>Required
created claim

createFulfillment

**createFulfillment**(id, config?): Promise&#60;[ClaimOrder](/references/services/classes/ClaimOrder)&#62;

Parameters

idstringRequired
the object containing all data required to create a claim
configobjectRequired
config object
config.location_idstring
config.metadataRecord<string, unknown>
config metadata
config.no_notificationboolean
config no notification

Returns

Promise<ClaimOrder>

PromisePromise<ClaimOrder>Required
created claim

createShipment

**createShipment**(id, fulfillmentId, trackingLinks?, config?): Promise&#60;[ClaimOrder](/references/services/classes/ClaimOrder)&#62;

Parameters

idstringRequired
fulfillmentIdstringRequired
trackingLinks&#123; tracking_number: string &#125;[]Required

Default: []

configobjectRequired
config.metadataobjectRequired

Default: {}

config.no_notificationundefinedRequired

Default: undefined

Returns

Promise<ClaimOrder>

PromisePromise<ClaimOrder>Required

getRefundTotalForClaimLinesOnOrder

Protected **getRefundTotalForClaimLinesOnOrder**(order, claimItems): Promise&#60;number&#62;

Finds claim line items on an order and calculates the refund amount. There are three places too look:

  • Order items
  • Swap items
  • Claim items (from previous claims) Note, it will attempt to return early from each of these places to avoid having to iterate over all items every time.

Parameters

orderOrderRequired
the order to find claim lines on
claimItemsCreateClaimItemInput[]Required
the claim items to match against

Returns

Promise<number>

PromisePromise<number>Required
the refund amount

list

**list**(selector, config?): Promise&#60;[ClaimOrder](/references/services/classes/ClaimOrder)[]&#62;

Parameters

selectoranyRequired
the query object for find
configFindConfig<ClaimOrder>Required
the config object containing query settings

Returns

Promise<ClaimOrder[]>

PromisePromise<ClaimOrder[]>Required
the result of the find operation

processRefund

**processRefund**(id): Promise&#60;[ClaimOrder](/references/services/classes/ClaimOrder)&#62;

Parameters

idstringRequired

Returns

Promise<ClaimOrder>

PromisePromise<ClaimOrder>Required

retrieve

**retrieve**(claimId, config?): Promise&#60;[ClaimOrder](/references/services/classes/ClaimOrder)&#62;

Gets an order by id.

Parameters

claimIdstringRequired
id of the claim order to retrieve
configFindConfig<ClaimOrder>Required
the config object containing query settings

Default: {}

Returns

Promise<ClaimOrder>

PromisePromise<ClaimOrder>Required
the order document

shouldRetryTransaction_

Protected **shouldRetryTransaction_**(err): boolean

Parameters

errRecord<string, unknown> | &#123; code: string &#125;Required

Returns

boolean

booleanboolean

update

**update**(id, data): Promise&#60;[ClaimOrder](/references/services/classes/ClaimOrder)&#62;

Parameters

idstringRequired
dataUpdateClaimInputRequired

Returns

Promise<ClaimOrder>

PromisePromise<ClaimOrder>Required

validateCreateClaimInput

Protected **validateCreateClaimInput**(data): Promise&#60;void&#62;

Parameters

dataCreateClaimInputRequired

Returns

Promise<void>

PromisePromise<void>Required

withTransaction

**withTransaction**(transactionManager?): [ClaimService](/references/services/classes/ClaimService)

Parameters

transactionManagerEntityManager

Returns

ClaimService

defaultClaimServiceRequired
Was this section helpful?