Files
medusa-store/www/apps/docs/content/references/js-client/classes/internal-8.internal.GiftCardService.md
github-actions[bot] daea35fe73 chore(docs): Generated JS Client Reference (#5334)
Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com>
2023-10-10 17:47:07 +00:00

12 KiB

displayed_sidebar
displayed_sidebar
jsClientSidebar

Class: GiftCardService

internal.internal.GiftCardService

Provides layer to manipulate gift cards.

Hierarchy

Properties

__configModule__

Protected Optional Readonly __configModule__: Record<string, unknown>

Inherited from

TransactionBaseService.configModule

Defined in

packages/medusa/dist/interfaces/transaction-base-service.d.ts:5


__container__

Protected Readonly __container__: any

Inherited from

TransactionBaseService.container

Defined in

packages/medusa/dist/interfaces/transaction-base-service.d.ts:4


__moduleDeclaration__

Protected Optional Readonly __moduleDeclaration__: Record<string, unknown>

Inherited from

TransactionBaseService.moduleDeclaration

Defined in

packages/medusa/dist/interfaces/transaction-base-service.d.ts:6


eventBus_

Protected Readonly eventBus_: EventBusService

Defined in

packages/medusa/dist/services/gift-card.d.ts:24


giftCardRepository_

Protected Readonly giftCardRepository_: Repository<GiftCard> & { listGiftCardsAndCount: (query: ExtendedFindConfig<GiftCard>, q?: string) => Promise<[GiftCard[], number]> }

Defined in

packages/medusa/dist/services/gift-card.d.ts:21


giftCardTransactionRepo_

Protected Readonly giftCardTransactionRepo_: Repository<GiftCardTransaction>

Defined in

packages/medusa/dist/services/gift-card.d.ts:22


manager_

Protected manager_: EntityManager

Inherited from

TransactionBaseService.manager_

Defined in

packages/medusa/dist/interfaces/transaction-base-service.d.ts:7


regionService_

Protected Readonly regionService_: RegionService

Defined in

packages/medusa/dist/services/gift-card.d.ts:23


transactionManager_

Protected transactionManager_: undefined | EntityManager

Inherited from

TransactionBaseService.transactionManager_

Defined in

packages/medusa/dist/interfaces/transaction-base-service.d.ts:8


Events

Static Events: Object

Type declaration

Name Type
CREATED string

Defined in

packages/medusa/dist/services/gift-card.d.ts:25

Accessors

activeManager_

Protected get activeManager_(): EntityManager

Returns

EntityManager

Inherited from

TransactionBaseService.activeManager_

Defined in

packages/medusa/dist/interfaces/transaction-base-service.d.ts:9

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.

Type parameters

Name
TResult
TError

Parameters

Name Type Description
work (transactionManager: EntityManager) => Promise<TResult> the transactional work to be done
isolationOrErrorHandler? IsolationLevel | (error: TError) => Promise<void | TResult> the isolation level to be used for the work.
maybeErrorHandlerOrDontFail? (error: TError) => Promise<void | TResult> Potential error handler

Returns

Promise<TResult>

the result of the transactional work

Inherited from

TransactionBaseService.atomicPhase_

Defined in

packages/medusa/dist/interfaces/transaction-base-service.d.ts:24


create

create(giftCard): Promise<GiftCard>

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

Parameters

Name Type Description
giftCard CreateGiftCardInput the gift card data to create

Returns

Promise<GiftCard>

the result of the create operation

Defined in

packages/medusa/dist/services/gift-card.d.ts:52


createTransaction

createTransaction(data): Promise<string>

Parameters

Name Type
data CreateGiftCardTransactionInput

Returns

Promise<string>

Defined in

packages/medusa/dist/services/gift-card.d.ts:46


delete

delete(giftCardId): Promise<void | GiftCard>

Deletes a gift card idempotently

Parameters

Name Type Description
giftCardId string id of gift card to delete

Returns

Promise<void | GiftCard>

the result of the delete operation

Defined in

packages/medusa/dist/services/gift-card.d.ts:80


list

list(selector?, config?): Promise<GiftCard[]>

Parameters

Name Type Description
selector? QuerySelector<GiftCard> the query object for find
config? FindConfig<GiftCard> the configuration used to find the objects. contains relations, skip, and take.

Returns

Promise<GiftCard[]>

the result of the find operation

Defined in

packages/medusa/dist/services/gift-card.d.ts:45


listAndCount

listAndCount(selector?, config?): Promise<[GiftCard[], number]>

Parameters

Name Type Description
selector? QuerySelector<GiftCard> the query object for find
config? FindConfig<GiftCard> the configuration used to find the objects. contains relations, skip, and take.

Returns

Promise<[GiftCard[], number]>

the result of the find operation

Defined in

packages/medusa/dist/services/gift-card.d.ts:39


retrieve

retrieve(giftCardId, config?): Promise<GiftCard>

Gets a gift card by id.

Parameters

Name Type Description
giftCardId string id of gift card to retrieve
config? FindConfig<GiftCard> optional values to include with gift card query

Returns

Promise<GiftCard>

the gift card

Defined in

packages/medusa/dist/services/gift-card.d.ts:66


retrieveByCode

retrieveByCode(code, config?): Promise<GiftCard>

Parameters

Name Type
code string
config? FindConfig<GiftCard>

Returns

Promise<GiftCard>

Defined in

packages/medusa/dist/services/gift-card.d.ts:67


retrieve_

Protected retrieve_(selector, config?): Promise<GiftCard>

Parameters

Name Type
selector Selector<GiftCard>
config? FindConfig<GiftCard>

Returns

Promise<GiftCard>

Defined in

packages/medusa/dist/services/gift-card.d.ts:59


shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

Name Type
err Record<string, unknown> | { code: string }

Returns

boolean

Inherited from

TransactionBaseService.shouldRetryTransaction_

Defined in

packages/medusa/dist/interfaces/transaction-base-service.d.ts:12


update

update(giftCardId, update): Promise<GiftCard>

Updates a giftCard.

Parameters

Name Type Description
giftCardId string giftCard id of giftCard to update
update UpdateGiftCardInput the data to update the giftCard with

Returns

Promise<GiftCard>

the result of the update operation

Defined in

packages/medusa/dist/services/gift-card.d.ts:74


withTransaction

withTransaction(transactionManager?): GiftCardService

Parameters

Name Type
transactionManager? EntityManager

Returns

GiftCardService

Inherited from

TransactionBaseService.withTransaction

Defined in

packages/medusa/dist/interfaces/transaction-base-service.d.ts:11


generateCode

Static generateCode(): string

Generates a 16 character gift card code

Returns

string

the generated gift card code

Defined in

packages/medusa/dist/services/gift-card.d.ts:33


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 Type
giftCardTaxRate null | number
region Region

Returns

null | number

the tax rate for the gift card

Defined in

packages/medusa/dist/services/gift-card.d.ts:58