108 lines
2.4 KiB
TypeScript
108 lines
2.4 KiB
TypeScript
export type DiscountCodeType = "percentage" | "fixed" | "fee_percentage";
|
|
|
|
export type DiscountApplicationLevel =
|
|
| "invoice"
|
|
| "category"
|
|
| "product"
|
|
| "shipping"
|
|
| "product_fee";
|
|
|
|
export type DiscountStatus = "active" | "inactive";
|
|
|
|
export type UserGroup = "new" | "loyal" | "all";
|
|
|
|
export interface DiscountUserRestrictions {
|
|
user_ids?: number[];
|
|
user_group?: UserGroup;
|
|
min_purchase_count?: number;
|
|
max_purchase_count?: number;
|
|
referrer_user_id?: number;
|
|
new_users_only?: boolean;
|
|
loyal_users_only?: boolean;
|
|
}
|
|
|
|
export interface DiscountMeta {
|
|
[key: string]: string | number | boolean | null;
|
|
}
|
|
|
|
export interface SteppedDiscountStep {
|
|
min_amount: number;
|
|
value: number;
|
|
}
|
|
|
|
export interface SteppedDiscount {
|
|
steps: SteppedDiscountStep[];
|
|
}
|
|
|
|
export interface DiscountCode {
|
|
id: number;
|
|
code: string;
|
|
name: string;
|
|
description?: string;
|
|
type: DiscountCodeType;
|
|
value: number;
|
|
status: DiscountStatus;
|
|
application_level: DiscountApplicationLevel;
|
|
min_purchase_amount?: number;
|
|
max_discount_amount?: number;
|
|
usage_limit?: number;
|
|
user_usage_limit?: number;
|
|
single_use: boolean;
|
|
valid_from?: string;
|
|
valid_to?: string;
|
|
user_restrictions?: DiscountUserRestrictions;
|
|
stepped_discount?: SteppedDiscount;
|
|
meta?: DiscountMeta;
|
|
created_at?: string;
|
|
updated_at?: string;
|
|
}
|
|
|
|
export interface DiscountCodeFilters {
|
|
page?: number;
|
|
limit?: number;
|
|
status?: DiscountStatus;
|
|
type?: DiscountCodeType;
|
|
application_level?: DiscountApplicationLevel;
|
|
code?: string;
|
|
active_only?: boolean;
|
|
}
|
|
|
|
export interface CreateDiscountCodeRequest {
|
|
code: string;
|
|
name: string;
|
|
description?: string;
|
|
type: DiscountCodeType;
|
|
value: number;
|
|
status: DiscountStatus;
|
|
application_level: DiscountApplicationLevel;
|
|
min_purchase_amount?: number;
|
|
max_discount_amount?: number;
|
|
usage_limit?: number;
|
|
user_usage_limit?: number;
|
|
single_use: boolean;
|
|
valid_from?: string;
|
|
valid_to?: string;
|
|
user_restrictions?: DiscountUserRestrictions;
|
|
stepped_discount?: SteppedDiscount;
|
|
meta?: DiscountMeta;
|
|
}
|
|
|
|
export interface UpdateDiscountCodeRequest
|
|
extends Partial<CreateDiscountCodeRequest> {
|
|
id: number;
|
|
}
|
|
|
|
export interface PaginatedDiscountCodesResponse {
|
|
discount_codes: DiscountCode[];
|
|
total: number;
|
|
page: number;
|
|
limit: number;
|
|
total_pages: number;
|
|
}
|
|
|
|
export type Response<T> = {
|
|
data: T;
|
|
message?: string;
|
|
success?: boolean;
|
|
};
|