GiftCardService
Provides layer to manipulate gift cards.
constructor
Parameters
__namedParameters
InjectedDependenciesRequiredProperties
manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequired__container__
anyRequiredEvents
objectRequiredEvents.CREATED
stringRequiredDefault: "gift_card.created"
__configModule__
Record<string, unknown>__moduleDeclaration__
Record<string, unknown>Accessors
activeManager_
Returns
EntityManager
EntityManagerRequiredMethods
withTransaction
Parameters
transactionManager
EntityManagerReturns
this
thisRequiredshouldRetryTransaction_
Parameters
err
Record<string, unknown> | objectRequiredReturns
boolean
booleanRequiredatomicPhase_
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
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>Requiredthe transactional work to be done
isolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>the isolation level to be used for the work.
maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Potential error handler
Returns
Promise
Promise<TResult>Requiredthe result of the transactional work
generateCode
Generates a 16 character gift card code
Returns
string
stringRequiredthe 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
data
CreateGiftCardTransactionInputRequiredReturns
Promise
Promise<string>Requiredcreate
Creates a gift card with provided data given that the data is validated.
Parameters
giftCard
CreateGiftCardInputRequiredthe 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
giftCardTaxRate
null | numberRequiredReturns
null | number
null | numberRequiredthe tax rate for the gift card
retrieve_
Parameters
Default: {}
Returns
retrieve
Gets a gift card by id.
Parameters
giftCardId
stringRequiredid of gift card to retrieve
optional values to include with gift card query
Default: {}
Returns
the gift card
retrieveByCode
Parameters
code
stringRequiredDefault: {}
Returns
update
Updates a giftCard.
Parameters
giftCardId
stringRequiredgiftCard id of giftCard to update
update
UpdateGiftCardInputRequiredthe data to update the giftCard with
Returns
the result of the update operation
delete
Deletes a gift card idempotently
Parameters
giftCardId
stringRequiredid of gift card to delete
Returns
the result of the delete operation
Was this section helpful?