GiftCardService
Provides layer to manipulate gift cards.
constructor
Parameters
__namedParametersInjectedDependenciesRequiredProperties
__container__anyRequiredmanager_EntityManagerRequiredtransactionManager_undefined | EntityManagerRequiredEventsobjectRequiredEvents.CREATEDstringRequiredDefault: "gift_card.created"
__configModule__Record<string, unknown>__moduleDeclaration__Record<string, unknown>Accessors
activeManager_
Returns
EntityManagerEntityManagerRequiredMethods
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
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
create
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
createTransaction
Parameters
dataCreateGiftCardTransactionInputRequiredReturns
PromisePromise<string>Requireddelete
Deletes a gift card idempotently
Parameters
giftCardIdstringRequiredid of gift card to delete
Returns
the result of the delete 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
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
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
retrieve_
Parameters
Default: {}
Returns
shouldRetryTransaction_
Parameters
errRecord<string, unknown> | objectRequiredReturns
booleanbooleanRequiredupdate
Updates a giftCard.
Parameters
giftCardIdstringRequiredgiftCard id of giftCard to update
updateUpdateGiftCardInputRequiredthe data to update the giftCard with
Returns
the result of the update operation
withTransaction
Parameters
transactionManagerEntityManagerReturns
thisthisRequiredgenerateCode
Generates a 16 character gift card code
Returns
stringstringRequiredthe generated gift card code
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
Was this section helpful?