GiftCardService
Provides layer to manipulate gift cards.
Constructors
constructor
**new GiftCardService**(«destructured»)
Parameters
Properties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>giftCardRepository_
Repository<GiftCard> & { listGiftCardsAndCount: Method listGiftCardsAndCount }Requiredmanager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequiredEvents
objectRequiredEvents.CREATED
stringRequiredDefault: "gift_card.created"
Accessors
activeManager_
Protected get**activeManager_**(): EntityManager
Returns
EntityManager
EntityManager
EntityManagerRequiredMethods
atomicPhase_
Protected **atomicPhase_**<TypeParameter TResult, TypeParameter TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise<TResult>
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.
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise<TResult>
Promise
Promise<TResult>Requiredcreate
**create**(giftCard): Promise<[GiftCard](/references/services/classes/GiftCard)>
Creates a gift card with provided data given that the data is validated.
Parameters
Returns
Promise<GiftCard>
createTransaction
**createTransaction**(data): Promise<string>
Parameters
Returns
Promise<string>
Promise
Promise<string>Requireddelete
**delete**(giftCardId): Promise<void \| [GiftCard](/references/services/classes/GiftCard)>
Deletes a gift card idempotently
Parameters
giftCardId
stringRequiredReturns
Promise<void | GiftCard>
list
**list**(selector?, config?): Promise<[GiftCard](/references/services/classes/GiftCard)[]>
Parameters
Default: {}
Returns
Promise<GiftCard[]>
listAndCount
**listAndCount**(selector?, config?): Promise<[[GiftCard](/references/services/classes/GiftCard)[], number]>
Parameters
Default: {}
Returns
Promise<[GiftCard[], number]>
retrieve
**retrieve**(giftCardId, config?): Promise<[GiftCard](/references/services/classes/GiftCard)>
Gets a gift card by id.
Parameters
giftCardId
stringRequiredDefault: {}
Returns
Promise<GiftCard>
retrieveByCode
**retrieveByCode**(code, config?): Promise<[GiftCard](/references/services/classes/GiftCard)>
Parameters
code
stringRequiredDefault: {}
Returns
Promise<GiftCard>
retrieve_
Protected **retrieve_**(selector, config?): Promise<[GiftCard](/references/services/classes/GiftCard)>
Parameters
Default: {}
Returns
Promise<GiftCard>
shouldRetryTransaction_
Protected **shouldRetryTransaction_**(err): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleanupdate
**update**(giftCardId, update): Promise<[GiftCard](/references/services/classes/GiftCard)>
Updates a giftCard.
Parameters
giftCardId
stringRequiredReturns
Promise<GiftCard>
withTransaction
**withTransaction**(transactionManager?): [GiftCardService](/references/services/classes/GiftCardService)
Parameters
transactionManager
EntityManagerReturns
generateCode
Static **generateCode**(): string
Generates a 16 character gift card code
Returns
string
string
stringresolveTaxRate
Static Protected **resolveTaxRate**(giftCardTaxRate, region):
null \| number
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` \| number
null | number