Skip to main content
Skip to main content
You're viewing the documentation for v1, which isn't the latest Medusa version.Latest documentation

GiftCardService

Provides layer to manipulate gift cards.

constructor​

Parameters​

__namedParametersInjectedDependenciesRequired

Properties​

manager_EntityManagerRequired
transactionManager_undefined | EntityManagerRequired
__container__anyRequired
giftCardRepository_Repository<GiftCard> & objectRequired
giftCardTransactionRepo_Repository<GiftCardTransaction>Required
regionService_RegionServiceRequired
eventBus_EventBusServiceRequired
EventsobjectRequired
Events.CREATEDstringRequired

Default: "gift_card.created"

__configModule__Record<string, unknown>
__moduleDeclaration__Record<string, unknown>

Accessors​

activeManager_​

Returns​

EntityManagerEntityManagerRequired

Methods​

withTransaction​

Parameters​

transactionManagerEntityManager

Returns​

thisthisRequired

shouldRetryTransaction_​

Parameters​

errRecord<string, unknown> | objectRequired

Returns​

booleanbooleanRequired

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​

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​

PromisePromise<TResult>Required
the result of the transactional work

generateCode​

Generates a 16 character gift card code

Returns​

stringstringRequired
the generated gift card code

listAndCount​

Parameters​

selectorQuerySelector<GiftCard>Required
the query object for find

Default: {}

configFindConfig<GiftCard>Required
the configuration used to find the objects. contains relations, skip, and take.

Returns​

PromisePromise<[GiftCard[], number]>Required
the result of the find operation

list​

Parameters​

selectorQuerySelector<GiftCard>Required
the query object for find

Default: {}

configFindConfig<GiftCard>Required
the configuration used to find the objects. contains relations, skip, and take.

Returns​

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

createTransaction​

Parameters​

dataCreateGiftCardTransactionInputRequired

Returns​

PromisePromise<string>Required

create​

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

Parameters​

giftCardCreateGiftCardInputRequired
the gift card data to create

Returns​

PromisePromise<GiftCard>Required
the result of the create operation

resolveTaxRate​

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​

giftCardTaxRatenull | numberRequired
regionRegionRequired

Returns​

null | numbernull | numberRequired
the tax rate for the gift card

retrieve_​

Parameters​

selectorSelector<GiftCard>Required
configFindConfig<GiftCard>Required

Default: {}

Returns​

PromisePromise<GiftCard>Required

retrieve​

Gets a gift card by id.

Parameters​

giftCardIdstringRequired
id of gift card to retrieve
configFindConfig<GiftCard>Required
optional values to include with gift card query

Default: {}

Returns​

PromisePromise<GiftCard>Required
the gift card

retrieveByCode​

Parameters​

codestringRequired
configFindConfig<GiftCard>Required

Default: {}

Returns​

PromisePromise<GiftCard>Required

update​

Updates a giftCard.

Parameters​

giftCardIdstringRequired
giftCard id of giftCard to update
updateUpdateGiftCardInputRequired
the data to update the giftCard with

Returns​

PromisePromise<GiftCard>Required
the result of the update operation

delete​

Deletes a gift card idempotently

Parameters​

giftCardIdstringRequired
id of gift card to delete

Returns​

PromisePromise<void | GiftCard>Required
the result of the delete operation
Was this section helpful?