Skip to content

Commit f69c1c9

Browse files
authored
feat!: add RulePromotionFilter type (#18)
BREAKING CHANGE: add RulePromotionFilter type
1 parent 6d1d792 commit f69c1c9

File tree

1 file changed

+109
-101
lines changed

1 file changed

+109
-101
lines changed

src/types/rule-promotions.ts

Lines changed: 109 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -5,116 +5,124 @@
55
* or require codes, which are then used by the end user to get a discount.
66
*/
77
import {
8-
CrudQueryableResource,
9-
Identifiable,
10-
ResourceList,
11-
ResourcePage,
12-
Resource
13-
} from './core'
14-
15-
export interface ActionLimitation {
16-
max_discount?: number
17-
max_quantity?: number
18-
items?: {
19-
max_items?: number
20-
price_strategy?: string
21-
}
8+
CrudQueryableResource,
9+
Identifiable,
10+
ResourceList,
11+
ResourcePage,
12+
Resource
13+
} from './core'
14+
15+
export interface ActionLimitation {
16+
max_discount?: number
17+
max_quantity?: number
18+
items?: {
19+
max_items?: number
20+
price_strategy?: string
2221
}
22+
}
2323

24-
export interface ActionCondition {
25-
strategy: string
24+
export interface ActionCondition {
25+
strategy: string
26+
operator?: string
27+
args?: any[]
28+
children?: {
29+
strategy?: string
2630
operator?: string
2731
args?: any[]
28-
children?: {
29-
strategy?: string
30-
operator?: string
31-
args?: any[]
32-
}[]
33-
}
32+
}[]
33+
}
3434

35-
export interface Action {
36-
strategy: string
37-
args: any[]
38-
limitations?: ActionLimitation
39-
condition?: ActionCondition
40-
}
35+
export interface Action {
36+
strategy: string
37+
args: any[]
38+
limitations?: ActionLimitation
39+
condition?: ActionCondition
40+
}
4141

42-
export interface Condition {
43-
strategy: string
44-
operator?: string
45-
args?: any[]
46-
children?: Condition[]
47-
}
42+
export interface Condition {
43+
strategy: string
44+
operator?: string
45+
args?: any[]
46+
children?: Condition[]
47+
}
4848

49-
/**
50-
* Promotions Builder
51-
* Description:Base Promotion Type
52-
*/
53-
export interface RulePromotionBase {
54-
type: 'rule_promotion'
55-
name: string
56-
description: string
57-
enabled: boolean
58-
automatic?: boolean
59-
start: string
60-
end: string
61-
stackable: boolean
62-
priority?: number | null | undefined
63-
rule_set: {
64-
currencies: string[]
65-
catalog_ids: string[]
66-
rules: Condition
67-
actions: Action[]
68-
}
69-
}
70-
71-
export interface RulePromotionMeta {
72-
timestamps: {
73-
created_at: string
74-
updated_at: string
75-
}
76-
}
77-
78-
export interface RulePromotion extends Identifiable, RulePromotionBase {
79-
meta: RulePromotionMeta
49+
/**
50+
* Promotions Builder
51+
* Description:Base Promotion Type
52+
*/
53+
export interface RulePromotionBase {
54+
type: 'rule_promotion'
55+
name: string
56+
description: string
57+
enabled: boolean
58+
automatic?: boolean
59+
start: string
60+
end: string
61+
stackable: boolean
62+
priority?: number | null | undefined
63+
rule_set: {
64+
currencies: string[]
65+
catalog_ids: string[]
66+
rules: Condition
67+
actions: Action[]
8068
}
69+
}
8170

82-
export interface RulePromotionCode {
83-
code: string
84-
uses?: number
85-
user?: string
86-
created_by?: string
87-
max_uses?: number
88-
meta?: RulePromotionMeta
89-
consume_unit?: 'per_application' | 'per_checkout'
71+
export interface RulePromotionMeta {
72+
timestamps: {
73+
created_at: string
74+
updated_at: string
9075
}
76+
}
9177

92-
export interface DeleteRulePromotionCodes extends ResourceList<any> {
93-
code: string
94-
}
95-
96-
export interface RulePromotionsEndpoint
97-
extends CrudQueryableResource<
98-
RulePromotion,
99-
RulePromotionBase,
100-
Partial<RulePromotionBase>,
101-
never,
102-
never,
103-
never
104-
> {
105-
endpoint: 'rule-promotions'
106-
107-
Codes(promotionId: string): Promise<ResourcePage<RulePromotionCode>>
108-
109-
AddCodes(
110-
promotionId: string,
111-
codes: RulePromotionCode[]
112-
): Promise<Resource<RulePromotionBase>>
113-
114-
DeleteCode(promotionId: string, codeId: string): Promise<{}>
115-
116-
DeleteCodes(
117-
promotionId: string,
118-
codes: DeleteRulePromotionCodes[]
119-
): Promise<{}>
78+
export interface RulePromotion extends Identifiable, RulePromotionBase {
79+
meta: RulePromotionMeta
80+
}
81+
82+
export interface RulePromotionCode {
83+
code: string
84+
uses?: number
85+
user?: string
86+
created_by?: string
87+
max_uses?: number
88+
meta?: RulePromotionMeta
89+
consume_unit?: 'per_application' | 'per_checkout'
90+
}
91+
92+
export interface DeleteRulePromotionCodes extends ResourceList<any> {
93+
code: string
94+
}
95+
96+
export interface RulePromotionFilter {
97+
eq?: {
98+
code?: string
12099
}
100+
}
101+
102+
export interface RulePromotionsEndpoint
103+
extends CrudQueryableResource<
104+
RulePromotion,
105+
RulePromotionBase,
106+
Partial<RulePromotionBase>,
107+
RulePromotionFilter,
108+
never,
109+
never
110+
> {
111+
endpoint: 'rule-promotions'
112+
113+
Filter(filter: RulePromotionFilter): RulePromotionsEndpoint
114+
115+
Codes(promotionId: string): Promise<ResourcePage<RulePromotionCode>>
116+
117+
AddCodes(
118+
promotionId: string,
119+
codes: RulePromotionCode[]
120+
): Promise<Resource<RulePromotionBase>>
121+
122+
DeleteCode(promotionId: string, codeId: string): Promise<{}>
123+
124+
DeleteCodes(
125+
promotionId: string,
126+
codes: DeleteRulePromotionCodes[]
127+
): Promise<{}>
128+
}

0 commit comments

Comments
 (0)