---
displayed_sidebar: servicesSidebar
---

import ParameterTypes from "@site/src/components/ParameterTypes"

# ClaimService

## Constructors

#### constructor

`**new ClaimService**(«destructured»)`

##### Parameters

<ParameterTypes parameters={[
  {
    "name": "__namedParameters",
    "type": "[InjectedDependencies](../types/InjectedDependencies-4.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

## Properties

<ParameterTypes parameters={[
  {
    "name": "__configModule__",
    "type": "`Record<string, unknown>`",
    "description": "",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "__container__",
    "type": "`any`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "__moduleDeclaration__",
    "type": "`Record<string, unknown>`",
    "description": "",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "addressRepository_",
    "type": "Repository&#60;[Address](Address.mdx)&#62;",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "claimItemService_",
    "type": "[ClaimItemService](ClaimItemService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "claimRepository_",
    "type": "Repository&#60;[ClaimOrder](ClaimOrder.mdx)&#62;",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "eventBus_",
    "type": "[EventBusService](EventBusService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "fulfillmentProviderService_",
    "type": "[FulfillmentProviderService](FulfillmentProviderService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "fulfillmentService_",
    "type": "[FulfillmentService](FulfillmentService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "lineItemRepository_",
    "type": "Repository&#60;[LineItem](LineItem.mdx)&#62; & ``{ findByReturn: Method findByReturn  }``",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "lineItemService_",
    "type": "[LineItemService](LineItemService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "manager_",
    "type": "EntityManager",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "paymentProviderService_",
    "type": "[PaymentProviderService](PaymentProviderService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "productVariantInventoryService_",
    "type": "[ProductVariantInventoryService](ProductVariantInventoryService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "regionService_",
    "type": "[RegionService](RegionService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "returnService_",
    "type": "[ReturnService](ReturnService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "shippingMethodRepository_",
    "type": "Repository&#60;[ShippingMethod](ShippingMethod.mdx)&#62;",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "shippingOptionService_",
    "type": "[ShippingOptionService](ShippingOptionService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "taxProviderService_",
    "type": "[TaxProviderService](TaxProviderService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "totalsService_",
    "type": "[TotalsService](TotalsService.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "transactionManager_",
    "type": "`undefined` \\| EntityManager",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "Events",
    "type": "`object`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "Events.CANCELED",
    "type": "`string`",
    "description": "",
    "optional": false,
    "defaultValue": "\"claim.canceled\"",
    "expandable": false,
    "children": []
  },
  {
    "name": "Events.CREATED",
    "type": "`string`",
    "description": "",
    "optional": false,
    "defaultValue": "\"claim.created\"",
    "expandable": false,
    "children": []
  },
  {
    "name": "Events.FULFILLMENT_CREATED",
    "type": "`string`",
    "description": "",
    "optional": false,
    "defaultValue": "\"claim.fulfillment_created\"",
    "expandable": false,
    "children": []
  },
  {
    "name": "Events.REFUND_PROCESSED",
    "type": "`string`",
    "description": "",
    "optional": false,
    "defaultValue": "\"claim.refund_processed\"",
    "expandable": false,
    "children": []
  },
  {
    "name": "Events.SHIPMENT_CREATED",
    "type": "`string`",
    "description": "",
    "optional": false,
    "defaultValue": "\"claim.shipment_created\"",
    "expandable": false,
    "children": []
  },
  {
    "name": "Events.UPDATED",
    "type": "`string`",
    "description": "",
    "optional": false,
    "defaultValue": "\"claim.updated\"",
    "expandable": false,
    "children": []
  }
]} />

## Accessors

#### activeManager\_

 `Protected` **activeManager\_**: [object Object]

## 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.

##### Type Parameters

<ParameterTypes parameters={[
  {
    "name": "TResult",
    "type": "`object`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "TError",
    "type": "`object`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

##### Parameters

<ParameterTypes parameters={[
  {
    "name": "work",
    "type": "(`transactionManager`: EntityManager) => Promise&#60;TResult&#62;",
    "description": "the transactional work to be done",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "isolationOrErrorHandler",
    "type": "`IsolationLevel` \\| (`error`: `TError`) => Promise&#60;void \\| TResult&#62;",
    "description": "the isolation level to be used for the work.",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "maybeErrorHandlerOrDontFail",
    "type": "(`error`: `TError`) => Promise&#60;void \\| TResult&#62;",
    "description": "Potential error handler",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

##### Returns

Promise&#60;TResult&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;TResult&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the result of the transactional work",
    "expandable": false,
    "children": []
  }
]} />

___

#### cancel

`**cancel**(id): Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;`

##### Parameters

<ParameterTypes parameters={[
  {
    "name": "id",
    "type": "`string`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

##### Returns

Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

#### cancelFulfillment

`**cancelFulfillment**(fulfillmentId): Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;`

##### Parameters

<ParameterTypes parameters={[
  {
    "name": "fulfillmentId",
    "type": "`string`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

##### Returns

Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

#### create

`**create**(data): Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#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

<ParameterTypes parameters={[
  {
    "name": "data",
    "type": "[CreateClaimInput](../types/CreateClaimInput.mdx)",
    "description": "the object containing all data required to create a claim",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

##### Returns

Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "created claim",
    "expandable": false,
    "children": []
  }
]} />

___

#### createFulfillment

`**createFulfillment**(id, config?): Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;`

##### Parameters

<ParameterTypes parameters={[
  {
    "name": "id",
    "type": "`string`",
    "description": "the object containing all data required to create a claim",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "config",
    "type": "`object`",
    "description": "config object",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "config.location_id",
    "type": "`string`",
    "description": "",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "config.metadata",
    "type": "`Record<string, unknown>`",
    "description": "config metadata",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "config.no_notification",
    "type": "`boolean`",
    "description": "config no notification",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

##### Returns

Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "created claim",
    "expandable": false,
    "children": []
  }
]} />

___

#### createShipment

`**createShipment**(id, fulfillmentId, trackingLinks?, config?): Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;`

##### Parameters

<ParameterTypes parameters={[
  {
    "name": "id",
    "type": "`string`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "fulfillmentId",
    "type": "`string`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "trackingLinks",
    "type": "``{ tracking_number: string  }``[]",
    "description": "",
    "optional": false,
    "defaultValue": "[]",
    "expandable": false,
    "children": []
  },
  {
    "name": "config",
    "type": "`object`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "config.metadata",
    "type": "`object`",
    "description": "",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  },
  {
    "name": "config.no_notification",
    "type": "`undefined`",
    "description": "",
    "optional": false,
    "defaultValue": "undefined",
    "expandable": false,
    "children": []
  }
]} />

##### Returns

Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

#### 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

<ParameterTypes parameters={[
  {
    "name": "order",
    "type": "[Order](Order.mdx)",
    "description": "the order to find claim lines on",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "claimItems",
    "type": "[CreateClaimItemInput](../types/CreateClaimItemInput.mdx)[]",
    "description": "the claim items to match against",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

##### Returns

Promise&#60;number&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;number&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the refund amount",
    "expandable": false,
    "children": []
  }
]} />

___

#### list

`**list**(selector, config?): Promise&#60;[ClaimOrder](ClaimOrder.mdx)[]&#62;`

##### Parameters

<ParameterTypes parameters={[
  {
    "name": "selector",
    "type": "`any`",
    "description": "the query object for find",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "config",
    "type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[ClaimOrder](ClaimOrder.mdx)&#62;",
    "description": "the config object containing query settings",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

##### Returns

Promise&#60;[ClaimOrder](ClaimOrder.mdx)[]&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[ClaimOrder](ClaimOrder.mdx)[]&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the result of the find operation",
    "expandable": false,
    "children": []
  }
]} />

___

#### processRefund

`**processRefund**(id): Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;`

##### Parameters

<ParameterTypes parameters={[
  {
    "name": "id",
    "type": "`string`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

##### Returns

Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

#### retrieve

`**retrieve**(claimId, config?): Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;`

Gets an order by id.

##### Parameters

<ParameterTypes parameters={[
  {
    "name": "claimId",
    "type": "`string`",
    "description": "id of the claim order to retrieve",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "config",
    "type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[ClaimOrder](ClaimOrder.mdx)&#62;",
    "description": "the config object containing query settings",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  }
]} />

##### Returns

Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "the order document",
    "expandable": false,
    "children": []
  }
]} />

___

#### shouldRetryTransaction\_

`Protected **shouldRetryTransaction_**(err): boolean`

##### Parameters

<ParameterTypes parameters={[
  {
    "name": "err",
    "type": "`Record<string, unknown>` \\| ``{ code: string  }``",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

##### Returns

`boolean`

<ParameterTypes parameters={[
  {
    "name": "boolean",
    "type": "`boolean`",
    "optional": true,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

#### update

`**update**(id, data): Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;`

##### Parameters

<ParameterTypes parameters={[
  {
    "name": "id",
    "type": "`string`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "data",
    "type": "[UpdateClaimInput](../types/UpdateClaimInput.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

##### Returns

Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;[ClaimOrder](ClaimOrder.mdx)&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

#### validateCreateClaimInput

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

##### Parameters

<ParameterTypes parameters={[
  {
    "name": "data",
    "type": "[CreateClaimInput](../types/CreateClaimInput.mdx)",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

##### Returns

Promise&#60;void&#62;

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;void&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

___

#### withTransaction

`**withTransaction**(transactionManager?): [ClaimService](ClaimService.mdx)`

##### Parameters

<ParameterTypes parameters={[
  {
    "name": "transactionManager",
    "type": "EntityManager",
    "description": "",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

##### Returns

[ClaimService](ClaimService.mdx)

<ParameterTypes parameters={[
  {
    "name": "default",
    "type": "[ClaimService](ClaimService.mdx)",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />
