Skip to main content
Skip to main content

GiftCardService

Provides layer to manipulate gift cards.

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
eventBus_EventBusServiceRequired
giftCardRepository_Repository<GiftCard> & &#123; listGiftCardsAndCount: Method listGiftCardsAndCount &#125;Required
giftCardTransactionRepo_Repository<GiftCardTransaction>Required
manager_EntityManagerRequired
regionService_RegionServiceRequired
transactionManager_undefined | EntityManagerRequired
EventsobjectRequired
Events.CREATEDstringRequired

Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

Methods

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.

Parameters

work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>
the isolation level to be used for the work.
maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>
Potential error handler

Returns

PromisePromise<TResult>Required
the result of the transactional work

create

Creates a gift card with provided data given that the data is validated.

Parameters

giftCardCreateGiftCardInputRequired
the gift card data to create

Returns

PromisePromise<GiftCard>Required
the result of the create operation

createTransaction

Parameters

Returns

PromisePromise<string>Required

delete

Deletes a gift card idempotently

Parameters

giftCardIdstringRequired
id of gift card to delete

Returns

PromisePromise<void | GiftCard>Required
the result of the delete operation

list

Parameters

the query object for find
the configuration used to find the objects. contains relations, skip, and take.

Returns

PromisePromise<GiftCard[]>Required
the result of the find operation

listAndCount

Parameters

the query object for find
the configuration used to find the objects. contains relations, skip, and take.

Returns

PromisePromise<[GiftCard[], number]>Required
the result of the find operation

retrieve

Gets a gift card by id.

Parameters

giftCardIdstringRequired
id of gift card to retrieve
optional values to include with gift card query

Returns

PromisePromise<GiftCard>Required
the gift card

retrieveByCode

Parameters

codestringRequired

Returns

PromisePromise<GiftCard>Required

retrieve_

Parameters

selectorSelector<GiftCard>Required

Returns

PromisePromise<GiftCard>Required

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | &#123; code: string &#125;Required

Returns

booleanboolean

update

Updates a giftCard.

Parameters

giftCardIdstringRequired
giftCard id of giftCard to update
updateUpdateGiftCardInputRequired
the data to update the giftCard with

Returns

PromisePromise<GiftCard>Required
the result of the update operation

withTransaction

Parameters

transactionManagerEntityManager

Returns

GiftCardServiceGiftCardServiceRequired

generateCode

Generates a 16 character gift card code

Returns

stringstring
the 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

giftCardTaxRatenull | numberRequired
regionRegionRequired
A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.

Returns

`null` \| numbernull | number
the tax rate for the gift card
Was this section helpful?