Skip to main content

Class: GiftCardService

Provides layer to manipulate gift cards.

Hierarchy

  • TransactionBaseServiceCopy to Clipboard

    GiftCardServiceCopy to Clipboard

Constructors

constructor

new GiftCardService(__namedParametersCopy to Clipboard)

Parameters

NameType
__namedParametersCopy to ClipboardInjectedDependenciesCopy to Clipboard

Overrides

TransactionBaseService.constructor

Defined in

medusa/src/services/gift-card.ts:39

Properties

__configModule__

ProtectedCopy to Clipboard OptionalCopy to Clipboard ReadonlyCopy to Clipboard __configModule__: RecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard>

Inherited from

TransactionBaseService.__configModule__

Defined in

medusa/src/interfaces/transaction-base-service.ts:14


__container__

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard __container__: anyCopy to Clipboard

Inherited from

TransactionBaseService.__container__

Defined in

medusa/src/interfaces/transaction-base-service.ts:13


__moduleDeclaration__

ProtectedCopy to Clipboard OptionalCopy to Clipboard ReadonlyCopy to Clipboard __moduleDeclaration__: RecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard>

Inherited from

TransactionBaseService.__moduleDeclaration__

Defined in

medusa/src/interfaces/transaction-base-service.ts:15


eventBus_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard eventBus_: EventBusServiceCopy to Clipboard

Defined in

medusa/src/services/gift-card.ts:33


giftCardRepository_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard giftCardRepository_: RepositoryCopy to Clipboard<GiftCardCopy to Clipboard> & { listGiftCardsAndCountCopy to Clipboard: (queryCopy to Clipboard: ExtendedFindConfigCopy to Clipboard<GiftCardCopy to Clipboard>, q?Copy to Clipboard: stringCopy to Clipboard) => PromiseCopy to Clipboard<[GiftCardCopy to Clipboard[], numberCopy to Clipboard]> }

Defined in

medusa/src/services/gift-card.ts:29


giftCardTransactionRepo_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard giftCardTransactionRepo_: RepositoryCopy to Clipboard<GiftCardTransactionCopy to Clipboard>

Defined in

medusa/src/services/gift-card.ts:31


manager_

ProtectedCopy to Clipboard manager_: EntityManagerCopy to Clipboard

Inherited from

TransactionBaseService.manager_

Defined in

medusa/src/interfaces/transaction-base-service.ts:5


regionService_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard regionService_: RegionServiceCopy to Clipboard

Defined in

medusa/src/services/gift-card.ts:32


transactionManager_

ProtectedCopy to Clipboard transactionManager_: undefinedCopy to Clipboard | EntityManagerCopy to Clipboard

Inherited from

TransactionBaseService.transactionManager_

Defined in

medusa/src/interfaces/transaction-base-service.ts:6


Events

StaticCopy to Clipboard Events: ObjectCopy to Clipboard

Type declaration

NameType
CREATEDCopy to ClipboardstringCopy to Clipboard

Defined in

medusa/src/services/gift-card.ts:35

Accessors

activeManager_

ProtectedCopy to Clipboard getCopy to Clipboard activeManager_(): EntityManagerCopy to Clipboard

Returns

EntityManagerCopy to Clipboard

Inherited from

TransactionBaseService.activeManager_

Defined in

medusa/src/interfaces/transaction-base-service.ts:8

Methods

atomicPhase_

ProtectedCopy to Clipboard atomicPhase_<TResultCopy to Clipboard, TErrorCopy to Clipboard>(workCopy to Clipboard, isolationOrErrorHandler?Copy to Clipboard, maybeErrorHandlerOrDontFail?Copy to Clipboard): PromiseCopy to Clipboard<TResultCopy to Clipboard>

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

Name
TResultCopy to Clipboard
TErrorCopy to Clipboard

Parameters

NameTypeDescription
workCopy to Clipboard(transactionManagerCopy to Clipboard: EntityManagerCopy to Clipboard) => PromiseCopy to Clipboard<TResultCopy to Clipboard>the transactional work to be done
isolationOrErrorHandler?Copy to ClipboardIsolationLevelCopy to Clipboard | (errorCopy to Clipboard: TErrorCopy to Clipboard) => PromiseCopy to Clipboard<voidCopy to Clipboard | TResultCopy to Clipboard>the isolation level to be used for the work.
maybeErrorHandlerOrDontFail?Copy to Clipboard(errorCopy to Clipboard: TErrorCopy to Clipboard) => PromiseCopy to Clipboard<voidCopy to Clipboard | TResultCopy to Clipboard>Potential error handler

Returns

PromiseCopy to Clipboard<TResultCopy to Clipboard>

the result of the transactional work

Inherited from

TransactionBaseService.atomicPhase_

Defined in

medusa/src/interfaces/transaction-base-service.ts:56


create

create(giftCardCopy to Clipboard): PromiseCopy to Clipboard<GiftCardCopy to Clipboard>

Creates a gift card with provided data given that the data is validated.

Parameters

NameTypeDescription
giftCardCopy to ClipboardCreateGiftCardInputCopy to Clipboardthe gift card data to create

Returns

PromiseCopy to Clipboard<GiftCardCopy to Clipboard>

the result of the create operation

Defined in

medusa/src/services/gift-card.ts:122


createTransaction

createTransaction(dataCopy to Clipboard): PromiseCopy to Clipboard<stringCopy to Clipboard>

Parameters

NameType
dataCopy to ClipboardCreateGiftCardTransactionInputCopy to Clipboard

Returns

PromiseCopy to Clipboard<stringCopy to Clipboard>

Defined in

medusa/src/services/gift-card.ts:106


delete

delete(giftCardIdCopy to Clipboard): PromiseCopy to Clipboard<voidCopy to Clipboard | GiftCardCopy to Clipboard>

Deletes a gift card idempotently

Parameters

NameTypeDescription
giftCardIdCopy to ClipboardstringCopy to Clipboardid of gift card to delete

Returns

PromiseCopy to Clipboard<voidCopy to Clipboard | GiftCardCopy to Clipboard>

the result of the delete operation

Defined in

medusa/src/services/gift-card.ts:295


list

list(selector?Copy to Clipboard, config?Copy to Clipboard): PromiseCopy to Clipboard<GiftCardCopy to Clipboard[]>

Parameters

NameTypeDescription
selectorCopy to ClipboardQuerySelectorCopy to Clipboard<GiftCardCopy to Clipboard>the query object for find
configCopy to ClipboardFindConfigCopy to Clipboard<GiftCardCopy to Clipboard>the configuration used to find the objects. contains relations, skip, and take.

Returns

PromiseCopy to Clipboard<GiftCardCopy to Clipboard[]>

the result of the find operation

Defined in

medusa/src/services/gift-card.ts:98


listAndCount

listAndCount(selector?Copy to Clipboard, config?Copy to Clipboard): PromiseCopy to Clipboard<[GiftCardCopy to Clipboard[], numberCopy to Clipboard]>

Parameters

NameTypeDescription
selectorCopy to ClipboardQuerySelectorCopy to Clipboard<GiftCardCopy to Clipboard>the query object for find
configCopy to ClipboardFindConfigCopy to Clipboard<GiftCardCopy to Clipboard>the configuration used to find the objects. contains relations, skip, and take.

Returns

PromiseCopy to Clipboard<[GiftCardCopy to Clipboard[], numberCopy to Clipboard]>

the result of the find operation

Defined in

medusa/src/services/gift-card.ts:74


retrieve

retrieve(giftCardIdCopy to Clipboard, config?Copy to Clipboard): PromiseCopy to Clipboard<GiftCardCopy to Clipboard>

Gets a gift card by id.

Parameters

NameTypeDescription
giftCardIdCopy to ClipboardstringCopy to Clipboardid of gift card to retrieve
configCopy to ClipboardFindConfigCopy to Clipboard<GiftCardCopy to Clipboard>optional values to include with gift card query

Returns

PromiseCopy to Clipboard<GiftCardCopy to Clipboard>

the gift card

Defined in

medusa/src/services/gift-card.ts:215


retrieveByCode

retrieveByCode(codeCopy to Clipboard, config?Copy to Clipboard): PromiseCopy to Clipboard<GiftCardCopy to Clipboard>

Parameters

NameType
codeCopy to ClipboardstringCopy to Clipboard
configCopy to ClipboardFindConfigCopy to Clipboard<GiftCardCopy to Clipboard>

Returns

PromiseCopy to Clipboard<GiftCardCopy to Clipboard>

Defined in

medusa/src/services/gift-card.ts:229


retrieve_

ProtectedCopy to Clipboard retrieve_(selectorCopy to Clipboard, config?Copy to Clipboard): PromiseCopy to Clipboard<GiftCardCopy to Clipboard>

Parameters

NameType
selectorCopy to ClipboardSelectorCopy to Clipboard<GiftCardCopy to Clipboard>
configCopy to ClipboardFindConfigCopy to Clipboard<GiftCardCopy to Clipboard>

Returns

PromiseCopy to Clipboard<GiftCardCopy to Clipboard>

Defined in

medusa/src/services/gift-card.ts:182


shouldRetryTransaction_

ProtectedCopy to Clipboard shouldRetryTransaction_(errCopy to Clipboard): booleanCopy to Clipboard

Parameters

NameType
errCopy to ClipboardRecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard> | { codeCopy to Clipboard: stringCopy to Clipboard }

Returns

booleanCopy to Clipboard

Inherited from

TransactionBaseService.shouldRetryTransaction_

Defined in

medusa/src/interfaces/transaction-base-service.ts:37


update

update(giftCardIdCopy to Clipboard, updateCopy to Clipboard): PromiseCopy to Clipboard<GiftCardCopy to Clipboard>

Updates a giftCard.

Parameters

NameTypeDescription
giftCardIdCopy to ClipboardstringCopy to ClipboardgiftCard id of giftCard to update
updateCopy to ClipboardUpdateGiftCardInputCopy to Clipboardthe data to update the giftCard with

Returns

PromiseCopy to Clipboard<GiftCardCopy to Clipboard>

the result of the update operation

Defined in

medusa/src/services/gift-card.ts:249


withTransaction

withTransaction(transactionManager?Copy to Clipboard): GiftCardServiceCopy to Clipboard

Parameters

NameType
transactionManager?Copy to ClipboardEntityManagerCopy to Clipboard

Returns

GiftCardServiceCopy to Clipboard

Inherited from

TransactionBaseService.withTransaction

Defined in

medusa/src/interfaces/transaction-base-service.ts:20


generateCode

StaticCopy to Clipboard generateCode(): stringCopy to Clipboard

Generates a 16 character gift card code

Returns

stringCopy to Clipboard

the generated gift card code

Defined in

medusa/src/services/gift-card.ts:58


resolveTaxRate

StaticCopy to Clipboard ProtectedCopy to Clipboard resolveTaxRate(giftCardTaxRateCopy to Clipboard, regionCopy to Clipboard): nullCopy to Clipboard | numberCopy to Clipboard

The tax_rate of the giftcard can depend on whether regions tax gift cards, an input provided by the user or the tax rate. Based on these conditions, tax_rate changes.

Parameters

NameType
giftCardTaxRateCopy to ClipboardnullCopy to Clipboard | numberCopy to Clipboard
regionCopy to ClipboardRegionCopy to Clipboard

Returns

nullCopy to Clipboard | numberCopy to Clipboard

the tax rate for the gift card

Defined in

medusa/src/services/gift-card.ts:161

Was this page helpful?