@withpotter/giftcard — module reference

HTTP routes this module mounts, plus its internal use-cases, entities, and repositories. The exhaustive request/response contract is the engine’s OpenAPI document at /docs; the layered structure below follows the package internal architecture.

HTTP routes

Gift Cards /giftcards

MethodPathAuthDescription
GET/giftcardsYesGet all gift cards
GET/giftcards/:idYesGet a gift card by ID
GET/giftcards/statsYesGet gift card statistics
POST/giftcardsYesCreate a new gift card
POST/giftcards/check-balanceCheck gift card balance by code
POST/giftcards/code/:code/redeemYesRedeem a gift card by code
PUT/giftcards/:idYesUpdate a gift card
DELETE/giftcards/:idYesDelete a gift card

Internals

Use-cases

Application operations. Each is a single-purpose class with one execute() method.

Use-caseSignature
CheckGiftCardBalanceUseCaseexecute(tenantId: string, code: string)
CreateGiftCardUseCaseexecute(tenantId: string, dto: CreateGiftCardDto)
DeleteGiftCardUseCaseexecute(tenantId: string, giftCardId: string)
GetGiftCardStatsUseCaseexecute(tenantId: string)
GetGiftCardUseCaseexecute(tenantId: string, giftCardId: string)
ListGiftCardsUseCaseexecute(tenantId: string, query: ListGiftCardsQuery)
RedeemGiftCardUseCaseexecute(tenantId: string, code: string, amount: number, referenceId?: string, note?: string)
UpdateGiftCardUseCaseexecute(tenantId: string, giftCardId: string, dto: UpdateGiftCardDto)

Entities

Sequelize models owned by this module.

GiftCard — table gift_cards

FieldType
idstring
tenantIdstring
tenantTenant
codestring
originalAmountnumber
balancenumber
currencystring
recipientEmailstring | null
recipientNamestring | null
personalMessagestring | null
purchaserEmailstring | null
purchaserNamestring | null
orderIdstring | null
statusGiftCardStatus
expiresAtDate | null
activatedAtDate | null
lastUsedAtDate | null
redemptionsGiftCardRedemption[]
emailSentboolean
emailSentAtDate | null
scheduledDeliveryDateDate | null
createdAtDate
updatedAtDate

Repositories

Data-access classes wrapping the entities.

GiftCardRepository

createForTenant · findByTenant · findByCode · findAllForTenant · updateForTenant · deleteForTenant · redeem · checkBalance · getStats · findPendingDelivery · markEmailSent

Generated from the module’s source. Routes are relative to the engine root (default http://localhost:3001). For full request/response schemas use the live OpenAPI document.