Files
medusa-store/docs/content/references/services/classes/GiftCardService.md
Shahed Nasser 02d5c1da88 docs: update Typedoc and regenerate references (#1994)
* generated new services reference

* changed from automatic push to automated pull request

* updated typedoc, regenerated JS Client reference

* regenerated the reference after updating typedoc

* added action for js client
2022-08-04 17:29:52 +03:00

10 KiB

Class: GiftCardService

Provides layer to manipulate gift cards.

Hierarchy

Constructors

constructor

new GiftCardService(__namedParameters)

Parameters

Name Type
__namedParameters InjectedDependencies

Overrides

TransactionBaseService<GiftCardService&gt;.constructor

Defined in

packages/medusa/src/services/gift-card.ts:46

Properties

configModule

Protected Optional Readonly configModule: Record<string, unknown>

Inherited from

TransactionBaseService.configModule

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:13


container

Protected Readonly container: unknown

Inherited from

TransactionBaseService.container

Defined in

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


eventBus_

Protected Readonly eventBus_: EventBusService

Defined in

packages/medusa/src/services/gift-card.ts:37


giftCardRepository_

Protected Readonly giftCardRepository_: typeof GiftCardRepository

Defined in

packages/medusa/src/services/gift-card.ts:34


giftCardTransactionRepo_

Protected Readonly giftCardTransactionRepo_: typeof GiftCardTransactionRepository

Defined in

packages/medusa/src/services/gift-card.ts:35


manager_

Protected manager_: EntityManager

Overrides

TransactionBaseService.manager_

Defined in

packages/medusa/src/services/gift-card.ts:39


regionService_

Protected Readonly regionService_: RegionService

Defined in

packages/medusa/src/services/gift-card.ts:36


transactionManager_

Protected transactionManager_: undefined | EntityManager

Overrides

TransactionBaseService.transactionManager_

Defined in

packages/medusa/src/services/gift-card.ts:40


Events

Static Events: Object

Type declaration

Name Type
CREATED string

Defined in

packages/medusa/src/services/gift-card.ts:42

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/src/interfaces/transaction-base-service.ts:53


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/src/services/gift-card.ts:152


createTransaction

createTransaction(data): Promise<string>

Parameters

Name Type
data CreateGiftCardTransactionInput

Returns

Promise<string>

Defined in

packages/medusa/src/services/gift-card.ts:137


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/src/services/gift-card.ts:282


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/src/services/gift-card.ts:113


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/src/services/gift-card.ts:84


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/src/services/gift-card.ts:216


retrieveByCode

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

Parameters

Name Type
code string
config FindConfig<GiftCard>

Returns

Promise<GiftCard>

Defined in

packages/medusa/src/services/gift-card.ts:223


retrieve_

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

Parameters

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

Returns

Promise<GiftCard>

Defined in

packages/medusa/src/services/gift-card.ts:182


shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

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

Returns

boolean

Inherited from

TransactionBaseService.shouldRetryTransaction_

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:34


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/src/services/gift-card.ts:236


withTransaction

withTransaction(transactionManager?): GiftCardService

Parameters

Name Type
transactionManager? EntityManager

Returns

GiftCardService

Inherited from

TransactionBaseService.withTransaction

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:16


generateCode

Static generateCode(): string

Generates a 16 character gift card code

Returns

string

the generated gift card code

Defined in

packages/medusa/src/services/gift-card.ts:68