--- displayed_sidebar: servicesSidebar --- import ParameterTypes from "@site/src/components/ParameterTypes" # GiftCardService Provides layer to manipulate gift cards. ## Constructors ### constructor **new GiftCardService**(`«destructured»`) #### Parameters ## Properties ", "description": "", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "__container__", "type": "`any`", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "__moduleDeclaration__", "type": "Record<`string`, `unknown`\\>", "description": "", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "eventBus_", "type": "[`EventBusService`](EventBusService.mdx)", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "giftCardRepository_", "type": "`Repository`<[`GiftCard`](GiftCard.mdx)\\> & { `listGiftCardsAndCount`: Method listGiftCardsAndCount }", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "giftCardTransactionRepo_", "type": "`Repository`<[`GiftCardTransaction`](GiftCardTransaction.mdx)\\>", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "manager_", "type": "`EntityManager`", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "regionService_", "type": "[`RegionService`](RegionService.mdx)", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "transactionManager_", "type": "`undefined` \\| `EntityManager`", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "Events", "type": "`object`", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "Events.CREATED", "type": "`string`", "description": "", "optional": false, "defaultValue": "\"gift_card.created\"", "expandable": false, "children": [] } ]} /> ## Accessors ### activeManager\_ `Protected` `get` **activeManager_**(): `EntityManager` #### Returns `EntityManager` ## 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. #### Parameters `Promise`<`TResult`\\>", "description": "the transactional work to be done", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "isolationOrErrorHandler", "type": "`IsolationLevel` \\| (`error`: `TError`) => `Promise`<`void` \\| `TResult`\\>", "description": "the isolation level to be used for the work.", "optional": true, "defaultValue": "", "expandable": false, "children": [] }, { "name": "maybeErrorHandlerOrDontFail", "type": "(`error`: `TError`) => `Promise`<`void` \\| `TResult`\\>", "description": "Potential error handler", "optional": true, "defaultValue": "", "expandable": false, "children": [] } ]} /> #### Returns `Promise`<`TResult`\> ", "optional": false, "defaultValue": "", "description": "the result of the transactional work", "expandable": false, "children": [] } ]} /> ___ ### create **create**(`giftCard`): `Promise`<[`GiftCard`](GiftCard.mdx)\> Creates a gift card with provided data given that the data is validated. #### Parameters #### Returns `Promise`<[`GiftCard`](GiftCard.mdx)\> ", "optional": false, "defaultValue": "", "description": "the result of the create operation", "expandable": false, "children": [] } ]} /> ___ ### createTransaction **createTransaction**(`data`): `Promise`<`string`\> #### Parameters #### Returns `Promise`<`string`\> ", "optional": false, "defaultValue": "", "description": "", "expandable": false, "children": [] } ]} /> ___ ### delete **delete**(`giftCardId`): `Promise`<`void` \| [`GiftCard`](GiftCard.mdx)\> Deletes a gift card idempotently #### Parameters #### Returns `Promise`<`void` \| [`GiftCard`](GiftCard.mdx)\> ", "optional": false, "defaultValue": "", "description": "the result of the delete operation", "expandable": false, "children": [] } ]} /> ___ ### list **list**(`selector?`, `config?`): `Promise`<[`GiftCard`](GiftCard.mdx)[]\> #### Parameters ", "description": "the query object for find", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] }, { "name": "config", "type": "[`FindConfig`](../interfaces/FindConfig.mdx)<[`GiftCard`](GiftCard.mdx)\\>", "description": "the configuration used to find the objects. contains relations, skip, and take.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ]} /> #### Returns `Promise`<[`GiftCard`](GiftCard.mdx)[]\> ", "optional": false, "defaultValue": "", "description": "the result of the find operation", "expandable": false, "children": [] } ]} /> ___ ### listAndCount **listAndCount**(`selector?`, `config?`): `Promise`<[[`GiftCard`](GiftCard.mdx)[], `number`]\> #### Parameters ", "description": "the query object for find", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] }, { "name": "config", "type": "[`FindConfig`](../interfaces/FindConfig.mdx)<[`GiftCard`](GiftCard.mdx)\\>", "description": "the configuration used to find the objects. contains relations, skip, and take.", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ]} /> #### Returns `Promise`<[[`GiftCard`](GiftCard.mdx)[], `number`]\> ", "optional": false, "defaultValue": "", "description": "the result of the find operation", "expandable": false, "children": [] } ]} /> ___ ### retrieve **retrieve**(`giftCardId`, `config?`): `Promise`<[`GiftCard`](GiftCard.mdx)\> Gets a gift card by id. #### Parameters ", "description": "optional values to include with gift card query", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `Promise`<[`GiftCard`](GiftCard.mdx)\> ", "optional": false, "defaultValue": "", "description": "the gift card", "expandable": false, "children": [] } ]} /> ___ ### retrieveByCode **retrieveByCode**(`code`, `config?`): `Promise`<[`GiftCard`](GiftCard.mdx)\> #### Parameters ", "description": "", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `Promise`<[`GiftCard`](GiftCard.mdx)\> ", "optional": false, "defaultValue": "", "description": "", "expandable": false, "children": [] } ]} /> ___ ### retrieve\_ `Protected` **retrieve_**(`selector`, `config?`): `Promise`<[`GiftCard`](GiftCard.mdx)\> #### Parameters ", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] }, { "name": "config", "type": "[`FindConfig`](../interfaces/FindConfig.mdx)<[`GiftCard`](GiftCard.mdx)\\>", "description": "", "optional": false, "defaultValue": "{}", "expandable": false, "children": [] } ]} /> #### Returns `Promise`<[`GiftCard`](GiftCard.mdx)\> ", "optional": false, "defaultValue": "", "description": "", "expandable": false, "children": [] } ]} /> ___ ### shouldRetryTransaction\_ `Protected` **shouldRetryTransaction_**(`err`): `boolean` #### Parameters \\| { `code`: `string` }", "description": "", "optional": false, "defaultValue": "", "expandable": false, "children": [] } ]} /> #### Returns `boolean` ___ ### update **update**(`giftCardId`, `update`): `Promise`<[`GiftCard`](GiftCard.mdx)\> Updates a giftCard. #### Parameters #### Returns `Promise`<[`GiftCard`](GiftCard.mdx)\> ", "optional": false, "defaultValue": "", "description": "the result of the update operation", "expandable": false, "children": [] } ]} /> ___ ### withTransaction **withTransaction**(`transactionManager?`): [`GiftCardService`](GiftCardService.mdx) #### Parameters #### Returns [`GiftCardService`](GiftCardService.mdx) ___ ### generateCode `Static` **generateCode**(): `string` Generates a 16 character gift card code #### Returns `string` ___ ### 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 #### Returns ``null`` \| `number`