-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.d.ts
More file actions
256 lines (234 loc) · 6.98 KB
/
Copy pathindex.d.ts
File metadata and controls
256 lines (234 loc) · 6.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
declare module '@rewardops/sdk-node' {
interface SDKError extends Error {
message: string;
status: number;
result: Record<string, unknown> | null;
}
type Config = {
apiServerUrl?: string;
apiVersion: 'v3' | 'v4' | 'v5';
piiServerUrl?: string;
supportedLocales?: string[];
clientId: string;
clientSecret: string;
logFilePath: string;
logToFile: boolean;
timeout?: number;
verbose: boolean;
quiet?: boolean;
silent?: boolean;
};
interface RequestCallback<Data = unknown, Res = unknown> extends Function {
(error?: SDKError, data?: Data, response?: Res, request?: unknown): void;
}
type Sort = 'NAME' | 'SALE_PRICE' | 'MEMBER_SALE_PRICE' | 'CREATED_DATE' | 'UPDATED_DATE';
type CustomCategoriesSort = 'category_code' | 'created_at' | 'name';
type SortOrder = 'ASCENDING' | 'DESCENDING';
type BaseParams = {
segment_id?: number;
segment_code?: string;
accept_language?: string;
// Allow BaseParams to be extended
} & Record<string, unknown>;
type ItemsParams = {
filter?: string;
accept_language?: string;
detailed?: boolean;
sort_by?: Sort;
sort_order?: SortOrder;
page?: number;
per_page_count?: number;
in_stock?: boolean;
permitted?: boolean;
q?: string;
} & BaseParams;
type GetAllParams = {
filter?: string;
q?: string;
filter_category_code?: string;
LABEL?: string;
PROPERTY?: string;
VARIANT_PROPERTY?: string;
CUSTOM_PROPERTY?: string;
CUSTOM_CATEGORY?: string;
} & BaseParams;
type GetCustomCategoriesParams = {
detailed?: boolean;
include_descendants?: boolean;
} & BaseParams;
type CouponPreflightItem = {
item_order_token: string;
quantity: number;
};
type PostValidateParams = {
coupon_preflight: {
owner_type: string;
owner_code: string;
coupon_code: string;
external_member_id: string;
items: Array<CouponPreflightItem>;
};
accept_language?: string;
} & BaseParams;
type PostValidateResponse = {
status: string;
result: {
items: [
{
order_token: string;
supplier_item_variant_id: string;
quantity: number;
regular_price: {
amount: number;
currency_code: string;
};
sale_price: {
amount: number;
currency_code: string;
};
coupon_discount: {
amount: number;
currency_code: string;
};
}
];
coupon_group: {
id: number;
name: string;
description: string;
code_prefix: string;
code_count: number;
starts_at: string;
ends_at: string;
state: string;
currency_code: string;
discount_rate: string | null;
volume_discount_count: number;
bundle_item_offer_item_count: number | null;
global_usage_cap_limit: number | null;
order_usage_cap_limit: number | null;
member_usage_cap_limit: number | null;
is_active: boolean;
updated_at: string;
created_at: string;
eligible_item_filter_definition: any; // TODO: put the correct type. Docs were not clear at the time
bundle_offer_filter_definition: any; // TODO: put the correct type. Docs were not clear at the time
owner: {
type: string;
code: string;
};
discount_fixed: {
amount: number;
currency_code: string;
} | null;
minimum_purchase_amount: {
amount: number;
currency_code: string;
} | null;
};
coupon_code: string;
};
};
enum Segment {
status = 'status',
nonStatus = 'non_status',
}
interface GenericRegisterMemberTagsParams {
foreign_id: string;
member_tags: string;
segment: Segment;
}
interface RegisterMemberTagsParams extends GenericRegisterMemberTagsParams {
program_code: string;
}
interface RegisterMemberTagsResponse extends GenericRegisterMemberTagsParams {
id: string;
}
interface SubsegmentsParams {
member_tags: string;
}
interface Program {
details: any;
items: {
/**
* Get an array of item JSON objects.
*
* @example
*
* // Gets an array of item detail objects the program with id 12
* ro.program(12).items.getAll({}, function(error, data) {
* // ...
* });
*/
getAll: (params: ItemsParams, callback: RequestCallback) => void;
/**
* Get a item JSON object.
*
* @example
*
* // Get JSON for the item with ID 938
* ro.program(12).items.get(938, {}, function(error, result, body) {
* if (error) {
* console.log(error);
* } else {
* console.log(result);
* }
* });
*/
get: (id: string, params: BaseParams, callback: RequestCallback) => void;
/**
* Get an array of filter parameter JSON objects that are relevant to the program.
*
* @example
*
* // Gets an array of filter parameter objects for the program with id 12
* ro.program(12).items.getParameters({}, function(error, data) {
* // ...
* });
*/
getParameters: (params: GetAllParams, callback: RequestCallback) => void;
};
customCategories: {
programId: string;
getAll: (params: GetAllCustomCategoriesParams, callback: RequestCallback) => void;
get: (code: string, params: GetCustomCategoriesParams, callback: RequestCallback) => void;
};
rewards: any;
orders: {
cancel: (
orderId: string,
cancelReason: string,
requestBody: Record<string, unknown>,
callback: RequestCallback
) => void;
get: (orderId: string, requestBody: Record<string, unknown>, callback: RequestCallback) => void;
};
coupons: {
postValidate: (params: PostValidateParams, callback: RequestCallback) => PostValidateResponse;
};
members: (memberUUID: string) => any;
personalization: {
registerMemberTags: (member: RegisterMemberTagsParams, callback: RequestCallback) => RegisterMemberTagsResponse;
};
subsegments: {
getAll: (params: SubsegmentsParams, callback: RequestCallback) => void;
};
memberSavedItems: {
getAll: (params: ItemsParams, callback: RequestCallback) => void;
get: (id: string, params: BaseParams, callback: RequestCallback) => void;
getParameters: (params: GetAllParams, callback: RequestCallback) => void;
summary: (memberUUID: string, callback: RequestCallback) => void;
};
}
const program = (id: number, code?: string) => ({} as Program);
const config = {
init: (params: Config) => ({} as Config),
reset: () => ({} as Config),
getAll: () => ({} as Config),
get: (attr: string) => null as any,
};
const urls = {
getApiBaseUrl: () => '',
};
export { SDKError, Config, Sort, CustomCategoriesSort, SortOrder, Program, program, config, urls };
}