Skip to main content

Class: DiscountsService

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:56

Extends​

  • BaseService

Constructors​

Constructor​

new DiscountsService(client): DiscountsService

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/base.ts:12

Parameters​

client​

TanqoryClient

Returns​

DiscountsService

Inherited from​

BaseService.constructor

Properties​

client​

protected client: TanqoryClient

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/base.ts:10

Inherited from​

BaseService.client

Methods​

activateDiscount()​

activateDiscount(storeId, discountId): Promise<{ code: string; createdAt: Date; description?: string; endsAt?: Date; id: string; isActive: boolean; maxUsage?: number; minOrderAmount?: number; startsAt?: Date; storeId: string; type: "percentage" | "fixed"; updatedAt: Date; usageCount: number; value: number; }>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:150

Activate discount (sets status to 'active', isActive to true)

Parameters​

storeId​

string

discountId​

string

Returns​

Promise<{ code: string; createdAt: Date; description?: string; endsAt?: Date; id: string; isActive: boolean; maxUsage?: number; minOrderAmount?: number; startsAt?: Date; storeId: string; type: "percentage" | "fixed"; updatedAt: Date; usageCount: number; value: number; }>


addComment()​

addComment(storeId, discountId, message, mentions?, attachments?): Promise<DiscountTimeline>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:300

Add a comment to the discount timeline Supports attachments and

Parameters​

storeId​

string

discountId​

string

message​

string

mentions?​

object[]

attachments?​

object[]

Returns​

Promise<DiscountTimeline>

Mentions​

(Tanqory pattern)


addDiscountComment()​

addDiscountComment(storeId, discountId, message): Promise<DiscountTimeline>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:349

Parameters​

storeId​

string

discountId​

string

message​

string

Returns​

Promise<DiscountTimeline>


buildQuery()​

protected buildQuery(options?): Record<string, any>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/base.ts:26

Build query parameters

Parameters​

options?​

ListOptions

Returns​

Record<string, any>

Inherited from​

BaseService.buildQuery


bulkDelete()​

bulkDelete(storeId, data): Promise<{ success: true; }>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:173

Bulk delete discounts

Parameters​

storeId​

string

data​

BulkDeleteDiscountsInput

Returns​

Promise<{ success: true; }>


bulkStatusChange()​

bulkStatusChange(storeId, data): Promise<{ success: true; }>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:182

Bulk status change

Parameters​

storeId​

string

data​

BulkStatusChangeInput

Returns​

Promise<{ success: true; }>


bulkUpdate()​

bulkUpdate(storeId, data): Promise<{ success: true; }>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:164

Bulk update discounts

Parameters​

storeId​

string

data​

BulkUpdateDiscountsInput

Returns​

Promise<{ success: true; }>


createDiscount()​

createDiscount(storeId, data): Promise<{ code: string; createdAt: Date; description?: string; endsAt?: Date; id: string; isActive: boolean; maxUsage?: number; minOrderAmount?: number; startsAt?: Date; storeId: string; type: "percentage" | "fixed"; updatedAt: Date; usageCount: number; value: number; }>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:93

Create new discount for a store Returns the created Discount directly (HTTP 201)

Parameters​

storeId​

string

data​
code​

string

description?​

string

endsAt?​

Date

isActive​

boolean

maxUsage?​

number

minOrderAmount?​

number

startsAt?​

Date

type​

"percentage" | "fixed"

value​

number

Returns​

Promise<{ code: string; createdAt: Date; description?: string; endsAt?: Date; id: string; isActive: boolean; maxUsage?: number; minOrderAmount?: number; startsAt?: Date; storeId: string; type: "percentage" | "fixed"; updatedAt: Date; usageCount: number; value: number; }>


deactivateDiscount()​

deactivateDiscount(storeId, discountId): Promise<{ code: string; createdAt: Date; description?: string; endsAt?: Date; id: string; isActive: boolean; maxUsage?: number; minOrderAmount?: number; startsAt?: Date; storeId: string; type: "percentage" | "fixed"; updatedAt: Date; usageCount: number; value: number; }>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:140

Deactivate discount (sets status to 'draft', isActive to false)

Parameters​

storeId​

string

discountId​

string

Returns​

Promise<{ code: string; createdAt: Date; description?: string; endsAt?: Date; id: string; isActive: boolean; maxUsage?: number; minOrderAmount?: number; startsAt?: Date; storeId: string; type: "percentage" | "fixed"; updatedAt: Date; usageCount: number; value: number; }>


deleteComment()​

deleteComment(storeId, discountId, commentId): Promise<DeletedResponse>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:334

Delete a comment from the discount timeline Returns Stripe-style: { id, object, deleted: true }

Parameters​

storeId​

string

discountId​

string

commentId​

string

Returns​

Promise<DeletedResponse>


deleteDiscount()​

deleteDiscount(storeId, discountId): Promise<DeletedResponse>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:115

Delete discount from store Returns Stripe-style: { id, object, deleted: true }

Parameters​

storeId​

string

discountId​

string

Returns​

Promise<DeletedResponse>


deleteDiscountComment()​

deleteDiscountComment(storeId, discountId, commentId): Promise<DeletedResponse>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:366

Parameters​

storeId​

string

discountId​

string

commentId​

string

Returns​

Promise<DeletedResponse>


duplicateDiscount()​

duplicateDiscount(storeId, discountId): Promise<{ code: string; createdAt: Date; description?: string; endsAt?: Date; id: string; isActive: boolean; maxUsage?: number; minOrderAmount?: number; startsAt?: Date; storeId: string; type: "percentage" | "fixed"; updatedAt: Date; usageCount: number; value: number; }>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:130

Duplicate a discount Returns the duplicated Discount directly (HTTP 201)

Parameters​

storeId​

string

discountId​

string

Returns​

Promise<{ code: string; createdAt: Date; description?: string; endsAt?: Date; id: string; isActive: boolean; maxUsage?: number; minOrderAmount?: number; startsAt?: Date; storeId: string; type: "percentage" | "fixed"; updatedAt: Date; usageCount: number; value: number; }>


editComment()​

editComment(storeId, discountId, commentId, message): Promise<DiscountTimeline>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:317

Edit a comment in the discount timeline

Parameters​

storeId​

string

discountId​

string

commentId​

string

message​

string

Returns​

Promise<DiscountTimeline>


editDiscountComment()​

editDiscountComment(storeId, discountId, commentId, message): Promise<DiscountTimeline>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:357

Parameters​

storeId​

string

discountId​

string

commentId​

string

message​

string

Returns​

Promise<DiscountTimeline>


exportDiscounts()​

exportDiscounts(storeId, data): Promise<ExportDiscountsResult>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:239

Export discounts

Parameters​

storeId​

string

data​

ExportDiscountsInput

Returns​

Promise<ExportDiscountsResult>


generateIdempotencyKey()​

protected generateIdempotencyKey(prefix): string

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/base.ts:19

Generate idempotency key

Parameters​

prefix​

string

Returns​

string

Inherited from​

BaseService.generateIdempotencyKey


getAnalytics()​

getAnalytics(storeId): Promise<DiscountAnalytics>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:197

Get discount analytics for store

Parameters​

storeId​

string

Returns​

Promise<DiscountAnalytics>


getCountsTimeseries()​

getCountsTimeseries(storeId, params): Promise<{ active: object[]; all: object[]; draft: object[]; expired: object[]; scheduled: object[]; }>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:204

Get discount counts time-series data

Parameters​

storeId​

string

params​
from​

string

groupBy?​

"day" | "week" | "month"

to​

string

Returns​

Promise<{ active: object[]; all: object[]; draft: object[]; expired: object[]; scheduled: object[]; }>


getDiscountById()​

getDiscountById(storeId, discountId): Promise<DiscountDetailResponse>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:78

Get single discount by ID with related discounts Returns directly: { discount, relatedDiscounts }

Parameters​

storeId​

string

discountId​

string

Returns​

Promise<DiscountDetailResponse>


getDiscounts()​

getDiscounts(storeId, params?): Promise<ListResponse<{ code: string; createdAt: Date; description?: string; endsAt?: Date; id: string; isActive: boolean; maxUsage?: number; minOrderAmount?: number; startsAt?: Date; storeId: string; type: "percentage" | "fixed"; updatedAt: Date; usageCount: number; value: number; }>>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:65

List discounts with pagination and filters Returns Stripe-style: { data, total, page, limit, total_pages }

Parameters​

storeId​

string

params?​

DiscountQueryParams

Returns​

Promise<ListResponse<{ code: string; createdAt: Date; description?: string; endsAt?: Date; id: string; isActive: boolean; maxUsage?: number; minOrderAmount?: number; startsAt?: Date; storeId: string; type: "percentage" | "fixed"; updatedAt: Date; usageCount: number; value: number; }>>


getExportMimeType()​

protected getExportMimeType(format): string

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/base.ts:45

Get MIME type for export format

Parameters​

format​

string

Returns​

string

Inherited from​

BaseService.getExportMimeType


getPerformance()​

getPerformance(storeId, discountId): Promise<DiscountPerformance>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:225

Get discount performance metrics

Parameters​

storeId​

string

discountId​

string

Returns​

Promise<DiscountPerformance>


getTimeline()​

getTimeline(storeId, discountId): Promise<DiscountTimeline[]>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:289

Get discount timeline events

Parameters​

storeId​

string

discountId​

string

Returns​

Promise<DiscountTimeline[]>


updateDiscount()​

updateDiscount(storeId, discountId, data): Promise<{ code: string; createdAt: Date; description?: string; endsAt?: Date; id: string; isActive: boolean; maxUsage?: number; minOrderAmount?: number; startsAt?: Date; storeId: string; type: "percentage" | "fixed"; updatedAt: Date; usageCount: number; value: number; }>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:101

Update discount Returns the updated Discount directly

Parameters​

storeId​

string

discountId​

string

data​
code?​

string

description?​

string

endsAt?​

Date

isActive?​

boolean

maxUsage?​

number

minOrderAmount?​

number

startsAt?​

Date

type?​

"percentage" | "fixed"

value?​

number

Returns​

Promise<{ code: string; createdAt: Date; description?: string; endsAt?: Date; id: string; isActive: boolean; maxUsage?: number; minOrderAmount?: number; startsAt?: Date; storeId: string; type: "percentage" | "fixed"; updatedAt: Date; usageCount: number; value: number; }>


validateDiscount()​

validateDiscount(storeId, data): Promise<DiscountValidationResult>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:257

Validate discount configuration

Parameters​

storeId​

string

data​
code​

string

description?​

string

endsAt?​

Date

isActive​

boolean

maxUsage?​

number

minOrderAmount?​

number

startsAt?​

Date

type​

"percentage" | "fixed"

value​

number

Returns​

Promise<DiscountValidationResult>


validateDiscountCode()​

validateDiscountCode(storeId, input): Promise<DiscountCheckoutValidationResult>

Defined in: tanqory-platform-packages/packages/api/sdk/src/services/discounts.ts:271

Validate discount code for checkout

Parameters​

storeId​

string

input​

ValidateDiscountCodeInput

Returns​

Promise<DiscountCheckoutValidationResult>