GiftCardService
Provides layer to manipulate gift cards.
constructor
Parameters
__namedParameters
InjectedDependenciesRequiredProperties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequiredEvents
objectRequiredEvents.CREATED
stringRequiredDefault: "gift_card.created"
Accessors
activeManager_
Returns
EntityManager
EntityManagerRequiredMethods
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
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
create
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
createTransaction
Parameters
data
CreateGiftCardTransactionInputRequiredReturns
Promise
Promise<string>Requireddelete
Deletes a gift card idempotently
Parameters
giftCardId
stringRequiredid 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
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
retrieve_
Parameters
Default: {}
Returns
shouldRetryTransaction_
Parameters
err
Record<string, unknown> | objectRequiredReturns
boolean
booleanupdate
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
withTransaction
Parameters
transactionManager
EntityManagerReturns
GiftCardService
objectRequiredProvides layer to manipulate gift cards.
generateCode
Generates a 16 character gift card code
Returns
string
stringthe 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
giftCardTaxRate
null | numberRequiredReturns
null \| number
null | numberthe tax rate for the gift card
Was this section helpful?