|
5 | 5 | * or require codes, which are then used by the end user to get a discount. |
6 | 6 | */ |
7 | 7 | 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 |
22 | 21 | } |
| 22 | +} |
23 | 23 |
|
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 |
26 | 30 | operator?: string |
27 | 31 | args?: any[] |
28 | | - children?: { |
29 | | - strategy?: string |
30 | | - operator?: string |
31 | | - args?: any[] |
32 | | - }[] |
33 | | - } |
| 32 | + }[] |
| 33 | +} |
34 | 34 |
|
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 | +} |
41 | 41 |
|
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 | +} |
48 | 48 |
|
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[] |
80 | 68 | } |
| 69 | +} |
81 | 70 |
|
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 |
90 | 75 | } |
| 76 | +} |
91 | 77 |
|
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 |
120 | 99 | } |
| 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