GiftCardService
Provides layer to manipulate gift cards.
Hierarchy
TransactionBaseService↳
GiftCardService
Constructors
constructor
new GiftCardService(«destructured»)
Parameters
| Name |
|---|
«destructured» |
Overrides
TransactionBaseService.constructor
Defined in
medusa/src/services/gift-card.ts:39
Properties
__configModule__
Protected Optional Readonly __configModule__: Record<string, unknown>
Inherited from
TransactionBaseService.__configModule__
Defined in
medusa/src/interfaces/transaction-base-service.ts:14
__container__
Protected Readonly __container__: any
Inherited from
TransactionBaseService.__container__
Defined in
medusa/src/interfaces/transaction-base-service.ts:13
__moduleDeclaration__
Protected Optional Readonly __moduleDeclaration__: Record<string, unknown>
Inherited from
TransactionBaseService.__moduleDeclaration__
Defined in
medusa/src/interfaces/transaction-base-service.ts:15
eventBus_
Protected Readonly eventBus_: EventBusService
Defined in
medusa/src/services/gift-card.ts:33
giftCardRepository_
Protected Readonly giftCardRepository_: Repository<GiftCard> & { listGiftCardsAndCount: Method listGiftCardsAndCount }
Defined in
medusa/src/services/gift-card.ts:29
giftCardTransactionRepo_
Protected Readonly giftCardTransactionRepo_: Repository<GiftCardTransaction>
Defined in
medusa/src/services/gift-card.ts:31
manager_
Protected manager_: EntityManager
Inherited from
TransactionBaseService.manager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:5
regionService_
Protected Readonly regionService_: RegionService
Defined in
medusa/src/services/gift-card.ts:32
transactionManager_
Protected transactionManager_: undefined | EntityManager
Inherited from
TransactionBaseService.transactionManager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:6
Events
Static Events: Object
Type declaration
| Name | Type |
|---|---|
CREATED | string |
Defined in
medusa/src/services/gift-card.ts:35
Accessors
activeManager_
Protected get activeManager_(): EntityManager
Returns
EntityManager
-EntityManager:
Inherited from
TransactionBaseService.activeManager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:8
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.
| Name |
|---|
TResult |
TError |
Parameters
| Name | Description |
|---|---|
work | (transactionManager: EntityManager) => Promise<TResult> |
isolationOrErrorHandler? | IsolationLevel | (error: TError) => Promise<void | TResult> |
maybeErrorHandlerOrDontFail? | (error: TError) => Promise<void | TResult> |
Returns
Promise<TResult>
-Promise: the result of the transactional work
Inherited from
TransactionBaseService.atomicPhase_
Defined in
medusa/src/interfaces/transaction-base-service.ts:56
create
create(giftCard): Promise<GiftCard>
Creates a gift card with provided data given that the data is validated.
Parameters
| Name | Description |
|---|---|
giftCard | CreateGiftCardInput |
Returns
Promise<GiftCard>
-Promise: the result of the create operation
-GiftCard:
Defined in
medusa/src/services/gift-card.ts:122
createTransaction
createTransaction(data): Promise<string>
Parameters
| Name |
|---|
data |
Returns
Promise<string>
-Promise:
-string: (optional)
Defined in
medusa/src/services/gift-card.ts:106
delete
delete(giftCardId): Promise<void | GiftCard>
Deletes a gift card idempotently
Parameters
| Name | Description |
|---|---|
giftCardId | string |
Returns
Promise<void | GiftCard>
-Promise: the result of the delete operation
-void \| GiftCard: (optional)
Defined in
medusa/src/services/gift-card.ts:295
list
list(selector?, config?): Promise<GiftCard[]>
Parameters
| Name | Description |
|---|---|
selector | QuerySelector<GiftCard> |
config | FindConfig<GiftCard> |
Returns
Promise<GiftCard[]>
-Promise: the result of the find operation
-GiftCard[]:
-GiftCard:
Defined in
medusa/src/services/gift-card.ts:98
listAndCount
listAndCount(selector?, config?): Promise<[GiftCard[], number]>
Parameters
| Name | Description |
|---|---|
selector | QuerySelector<GiftCard> |
config | FindConfig<GiftCard> |
Returns
Promise<[GiftCard[], number]>
-Promise: the result of the find operation
-GiftCard[]:
-number: (optional)
Defined in
medusa/src/services/gift-card.ts:74
retrieve
retrieve(giftCardId, config?): Promise<GiftCard>
Gets a gift card by id.
Parameters
| Name | Description |
|---|---|
giftCardId | string |
config | FindConfig<GiftCard> |
Returns
Promise<GiftCard>
-Promise: the gift card
-GiftCard:
Defined in
medusa/src/services/gift-card.ts:215
retrieveByCode
retrieveByCode(code, config?): Promise<GiftCard>
Parameters
| Name |
|---|
code |
config |
Returns
Promise<GiftCard>
-Promise:
-GiftCard:
Defined in
medusa/src/services/gift-card.ts:229
retrieve_
Protected retrieve_(selector, config?): Promise<GiftCard>
Parameters
| Name |
|---|
selector |
config |
Returns
Promise<GiftCard>
-Promise:
-GiftCard:
Defined in
medusa/src/services/gift-card.ts:182
shouldRetryTransaction_
Protected shouldRetryTransaction_(err): boolean
Parameters
| Name |
|---|
err |
Returns
boolean
-boolean: (optional)
Inherited from
TransactionBaseService.shouldRetryTransaction_
Defined in
medusa/src/interfaces/transaction-base-service.ts:37
update
update(giftCardId, update): Promise<GiftCard>
Updates a giftCard.
Parameters
| Name | Description |
|---|---|
giftCardId | string |
update | UpdateGiftCardInput |
Returns
Promise<GiftCard>
-Promise: the result of the update operation
-GiftCard:
Defined in
medusa/src/services/gift-card.ts:249
withTransaction
withTransaction(transactionManager?): GiftCardService
Parameters
| Name |
|---|
transactionManager? |
Returns
-GiftCardService:
Inherited from
TransactionBaseService.withTransaction
Defined in
medusa/src/interfaces/transaction-base-service.ts:20
generateCode
Static generateCode(): string
Generates a 16 character gift card code
Returns
string
-string: (optional) the generated gift card code
Defined in
medusa/src/services/gift-card.ts:58
resolveTaxRate
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
| Name |
|---|
giftCardTaxRate |
region |
Returns
null | number
-`null | number`: (optional) the tax rate for the gift card