GiftCardService
Provides layer to manipulate gift cards.
constructor
Parameters
__namedParametersInjectedDependenciesRequiredProperties
manager_EntityManagerRequiredtransactionManager_undefined | EntityManagerRequired__container__anyRequiredEventsobjectRequiredEvents.CREATEDstringRequiredDefault: "gift_card.created"
__configModule__Record<string, unknown>__moduleDeclaration__Record<string, unknown>Accessors
activeManager_
Returns
EntityManagerEntityManagerRequiredMethods
withTransaction
Parameters
transactionManagerEntityManagerReturns
thisthisRequiredshouldRetryTransaction_
Parameters
errRecord<string, unknown> | objectRequiredReturns
booleanbooleanRequiredatomicPhase_
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
TResultobjectRequiredTErrorobjectRequiredParameters
work(transactionManager: EntityManager) => Promise<TResult>Requiredthe 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>Requiredthe result of the transactional work
generateCode
Generates a 16 character gift card code
Returns
stringstringRequiredthe generated gift card code
listAndCount
Parameters
the query object for find
Default: {}
the configuration used to find the objects. contains relations, skip, and take.
Returns
the result of the find operation
list
Parameters
the query object for find
Default: {}
the configuration used to find the objects. contains relations, skip, and take.
Returns
the result of the find operation
createTransaction
Parameters
dataCreateGiftCardTransactionInputRequiredReturns
PromisePromise<string>Requiredcreate
Creates a gift card with provided data given that the data is validated.
Parameters
giftCardCreateGiftCardInputRequiredthe gift card data to create
Returns
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 | numberRequiredReturns
null | numbernull | numberRequiredthe tax rate for the gift card
retrieve_
Parameters
Default: {}
Returns
retrieve
Gets a gift card by id.
Parameters
giftCardIdstringRequiredid of gift card to retrieve
optional values to include with gift card query
Default: {}
Returns
the gift card
retrieveByCode
Parameters
codestringRequiredDefault: {}
Returns
update
Updates a giftCard.
Parameters
giftCardIdstringRequiredgiftCard id of giftCard to update
updateUpdateGiftCardInputRequiredthe data to update the giftCard with
Returns
the result of the update operation
delete
Deletes a gift card idempotently
Parameters
giftCardIdstringRequiredid of gift card to delete
Returns
the result of the delete operation
Was this section helpful?