4.6 KiB
Class: GiftCardService
Provides layer to manipulate gift cards.
Hierarchy
-
"medusa-interfaces"↳
GiftCardService
Constructors
constructor
• new GiftCardService(__namedParameters)
Parameters
| Name | Type |
|---|---|
__namedParameters |
Object |
Overrides
BaseService.constructor
Defined in
Properties
Events
▪ Static Events: Object
Type declaration
| Name | Type |
|---|---|
CREATED |
string |
Defined in
Methods
create
▸ create(giftCard): Promise<GiftCard>
Creates a gift card with provided data given that the data is validated.
Parameters
| Name | Type | Description |
|---|---|---|
giftCard |
GiftCard |
the gift card data to create |
Returns
Promise<GiftCard>
the result of the create operation
Defined in
createTransaction
▸ createTransaction(data): Promise<any>
Parameters
| Name | Type |
|---|---|
data |
any |
Returns
Promise<any>
Defined in
delete
▸ delete(giftCardId): Promise<any>
Deletes a gift card idempotently
Parameters
| Name | Type | Description |
|---|---|---|
giftCardId |
string |
id of gift card to delete |
Returns
Promise<any>
the result of the delete operation
Defined in
generateCode_
▸ generateCode_(): string
Generates a 16 character gift card code
Returns
string
the generated gift card code
Defined in
list
▸ list(selector?, config?): Promise<any>
Parameters
| Name | Type | Description |
|---|---|---|
selector |
any |
the query object for find |
config |
any |
the configuration used to find the objects. contains relations, skip, and take. |
Returns
Promise<any>
the result of the find operation
Defined in
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 |
any |
optional values to include with gift card query |
Returns
Promise<GiftCard>
the gift card
Defined in
retrieveByCode
▸ retrieveByCode(code, config?): Promise<any>
Parameters
| Name | Type |
|---|---|
code |
any |
config |
Object |
Returns
Promise<any>
Defined in
update
▸ update(giftCardId, update): Promise<any>
Updates a giftCard.
Parameters
| Name | Type | Description |
|---|---|---|
giftCardId |
string |
giftCard id of giftCard to update |
update |
GiftCard |
the data to update the giftCard with |
Returns
Promise<any>
the result of the update operation
Defined in
withTransaction
▸ withTransaction(transactionManager): GiftCardService
Parameters
| Name | Type |
|---|---|
transactionManager |
any |