GiftCardService
internal.internal.GiftCardService
Provides layer to manipulate gift cards.
Properties
__configModule__Record<string, unknown>__container__anyRequired__moduleDeclaration__Record<string, unknown>giftCardRepository_Repository<GiftCard> & { listGiftCardsAndCount: Method listGiftCardsAndCount }Requiredmanager_EntityManagerRequiredtransactionManager_undefined | EntityManagerRequiredEventsobjectRequiredEvents.CREATEDstringRequiredAccessors
activeManager_
Protected get activeManager_(): EntityManager
Returns
EntityManager
EntityManagerEntityManagerRequiredInherited from
TransactionBaseService.activeManager_
Methods
atomicPhase_
Protected atomicPhase_<TResult, 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.
TResultobjectRequiredTErrorobjectRequiredParameters
work(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>Returns
Promise<TResult>
PromisePromise<TResult>RequiredInherited from
TransactionBaseService.atomicPhase_
create
create(giftCard): Promise<GiftCard>
Creates a gift card with provided data given that the data is validated.
Parameters
Returns
Promise<GiftCard>
the result of the create operation
createTransaction
createTransaction(data): Promise<string>
Parameters
Returns
Promise<string>
PromisePromise<string>Required
PromisePromise<string>Requireddelete
delete(giftCardId): Promise<void | GiftCard>
Deletes a gift card idempotently
Parameters
giftCardIdstringRequiredReturns
Promise<void | GiftCard>
the result of the delete operation
list
list(selector?, config?): Promise<GiftCard[]>
Parameters
selectorQuerySelector<GiftCard>configFindConfig<GiftCard>Returns
Promise<GiftCard[]>
the result of the find operation
listAndCount
listAndCount(selector?, config?): Promise<[GiftCard[], number]>
Parameters
selectorQuerySelector<GiftCard>configFindConfig<GiftCard>Returns
Promise<[GiftCard[], number]>
the result of the find operation
retrieve
retrieve(giftCardId, config?): Promise<GiftCard>
Gets a gift card by id.
Parameters
giftCardIdstringRequiredconfigFindConfig<GiftCard>Returns
Promise<GiftCard>
the gift card
retrieveByCode
retrieveByCode(code, config?): Promise<GiftCard>
Parameters
codestringRequiredconfigFindConfig<GiftCard>Returns
Promise<GiftCard>
retrieve_
Protected retrieve_(selector, config?): Promise<GiftCard>
Parameters
configFindConfig<GiftCard>Returns
Promise<GiftCard>
shouldRetryTransaction_
Protected shouldRetryTransaction_(err): boolean
Parameters
errRecord<string, unknown> | { code: string }RequiredReturns
boolean
booleanbooleanInherited from
TransactionBaseService.shouldRetryTransaction_
update
update(giftCardId, update): Promise<GiftCard>
Updates a giftCard.
Parameters
giftCardIdstringRequiredReturns
Promise<GiftCard>
the result of the update operation
withTransaction
withTransaction(transactionManager?): GiftCardService
Parameters
transactionManagerEntityManagerReturns
Inherited from
TransactionBaseService.withTransaction
generateCode
Static generateCode(): string
Generates a 16 character gift card code
Returns
string
stringstringresolveTaxRate
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
giftCardTaxRatenull | numberRequiredReturns
null | number
``null`` \| numbernull | number