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 | EntityManagerRequiredEvents
objectRequiredEvents.CREATED
stringRequiredAccessors
activeManager_
Protected
get
activeManager_(): EntityManager
Returns
EntityManager
EntityManager
EntityManagerRequiredInherited 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.
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>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
>
Promise
Promise<string>Required
Promise
Promise<string>Requireddelete
delete(giftCardId
): Promise
<void
| GiftCard
>
Deletes a gift card idempotently
Parameters
giftCardId
stringRequiredReturns
Promise
<void
| GiftCard
>
the result of the delete operation
list
list(selector?
, config?
): Promise
<GiftCard
[]>
Parameters
selector
QuerySelector<GiftCard>config
FindConfig<GiftCard>Returns
Promise
<GiftCard
[]>
the result of the find operation
listAndCount
listAndCount(selector?
, config?
): Promise
<[GiftCard
[], number
]>
Parameters
selector
QuerySelector<GiftCard>config
FindConfig<GiftCard>Returns
Promise
<[GiftCard
[], number
]>
the result of the find operation
retrieve
retrieve(giftCardId
, config?
): Promise
<GiftCard
>
Gets a gift card by id.
Parameters
giftCardId
stringRequiredconfig
FindConfig<GiftCard>Returns
Promise
<GiftCard
>
the gift card
retrieveByCode
retrieveByCode(code
, config?
): Promise
<GiftCard
>
Parameters
code
stringRequiredconfig
FindConfig<GiftCard>Returns
Promise
<GiftCard
>
retrieve_
Protected
retrieve_(selector
, config?
): Promise
<GiftCard
>
Parameters
config
FindConfig<GiftCard>Returns
Promise
<GiftCard
>
shouldRetryTransaction_
Protected
shouldRetryTransaction_(err
): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleanInherited from
TransactionBaseService.shouldRetryTransaction_
update
update(giftCardId
, update
): Promise
<GiftCard
>
Updates a giftCard.
Parameters
giftCardId
stringRequiredReturns
Promise
<GiftCard
>
the result of the update operation
withTransaction
withTransaction(transactionManager?
): GiftCardService
Parameters
transactionManager
EntityManagerReturns
Inherited from
TransactionBaseService.withTransaction
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