--- displayed_sidebar: servicesSidebar --- import TypeList from "@site/src/components/TypeList" # SwapService Handles swaps ## constructor ### Parameters ___ ## Properties `","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"__moduleDeclaration__","type":"`Record`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="SwapService"/> ___ ## Accessors ### activeManager\_ #### Returns ___ ## Methods ### withTransaction #### Parameters #### Returns ### shouldRetryTransaction\_ #### Parameters ` \\| `object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="shouldRetryTransaction_"/> #### Returns ### atomicPhase\_ 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 #### Parameters Promise<TResult>","description":"the transactional work to be done","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"isolationOrErrorHandler","type":"`IsolationLevel` \\| (`error`: TError) => Promise<void \\| TResult>","description":"the isolation level to be used for the work.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"maybeErrorHandlerOrDontFail","type":"(`error`: TError) => Promise<void \\| TResult>","description":"Potential error handler","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="atomicPhase_"/> #### Returns ### transformQueryForCart Transform find config object for retrieval. #### Parameters #### Returns ### retrieve Retrieves a swap with the given id. #### Parameters #### Returns ### retrieveByCartId Retrieves a swap based on its associated cart id #### Parameters #### Returns ### list List swaps. #### Parameters #### Returns ### listAndCount List swaps. #### Parameters #### Returns ### create Creates a swap from an order, with given return items, additional items and an optional return shipping method. #### Parameters #### Returns ### processDifference Process difference for the requested swap. #### Parameters #### Returns ### update Update the swap record. #### Parameters #### Returns ### createCart Creates a cart from the given swap. The cart can be used to pay for differences associated with the swap. The swap represented by the swapId must belong to the order. Fails if there is already a cart on the swap. #### Parameters #### Returns ### registerCartCompletion Register a cart completion #### Parameters #### Returns ### cancel Cancels a given swap if possible. A swap can only be canceled if all related returns, fulfillments, and payments have been canceled. If a swap is associated with a refund, it cannot be canceled. #### Parameters #### Returns ### createFulfillment Fulfills the additional items associated with the swap. Will call the fulfillment providers associated with the shipping methods. #### Parameters #### Returns ### cancelFulfillment Cancels a fulfillment (if related to a swap) #### Parameters #### Returns ### createShipment Marks a fulfillment as shipped and attaches tracking numbers. #### Parameters #### Returns ### deleteMetadata Dedicated method to delete metadata for a swap. #### Parameters #### Returns ### registerReceived Registers the swap return items as received so that they cannot be used as a part of other swaps/returns. #### Parameters #### Returns ### areReturnItemsValid #### Parameters #### Returns