@voucherify/sdk 2.9.2 → 2.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ApiLimitsHandler.d.ts +13 -10
- package/dist/AsyncActions.d.ts +17 -15
- package/dist/Balance.d.ts +15 -12
- package/dist/Campaigns.d.ts +66 -58
- package/dist/Categories.d.ts +29 -26
- package/dist/ClientSide.d.ts +77 -53
- package/dist/Consents.d.ts +13 -10
- package/dist/Customers.d.ts +75 -72
- package/dist/Distributions.d.ts +29 -22
- package/dist/Events.d.ts +15 -10
- package/dist/Exports.d.ts +25 -22
- package/dist/Loyalties.d.ts +171 -159
- package/dist/MetadataSchemas.d.ts +17 -14
- package/dist/Orders.d.ts +32 -27
- package/dist/ProductCollections.d.ts +30 -26
- package/dist/Products.d.ts +66 -63
- package/dist/PromotionTiers.d.ts +43 -34
- package/dist/Promotions.d.ts +30 -18
- package/dist/PromotionsStacks.d.ts +34 -30
- package/dist/Qualifications.d.ts +24 -10
- package/dist/Redemptions.d.ts +53 -35
- package/dist/RequestController.d.ts +31 -29
- package/dist/Rewards.d.ts +46 -43
- package/dist/Segments.d.ts +25 -22
- package/dist/ValidationRules.d.ts +47 -43
- package/dist/Validations.d.ts +39 -17
- package/dist/VoucherifyClientSide.d.ts +112 -86
- package/dist/VoucherifyError.d.ts +23 -20
- package/dist/VoucherifyServerSide.d.ts +170 -131
- package/dist/Vouchers.d.ts +84 -78
- package/dist/helpers.d.ts +20 -18
- package/dist/index.d.ts +63 -25
- package/dist/types/ApplicableTo.d.ts +32 -30
- package/dist/types/AsyncActions.d.ts +23 -21
- package/dist/types/Balance.d.ts +18 -16
- package/dist/types/Campaigns.d.ts +124 -120
- package/dist/types/Categories.d.ts +40 -38
- package/dist/types/ClientSide.d.ts +145 -134
- package/dist/types/Consents.d.ts +34 -33
- package/dist/types/Customers.d.ts +363 -361
- package/dist/types/DiscountVoucher.d.ts +94 -93
- package/dist/types/Distributions.d.ts +148 -144
- package/dist/types/Events.d.ts +21 -17
- package/dist/types/Exports.d.ts +151 -149
- package/dist/types/Gift.d.ts +5 -3
- package/dist/types/Loyalties.d.ts +1061 -1057
- package/dist/types/MetadataSchemas.d.ts +34 -33
- package/dist/types/Orders.d.ts +199 -195
- package/dist/types/ProductCollections.d.ts +99 -96
- package/dist/types/Products.d.ts +108 -106
- package/dist/types/PromotionTiers.d.ts +131 -127
- package/dist/types/Promotions.d.ts +113 -108
- package/dist/types/PromotionsStacks.d.ts +74 -71
- package/dist/types/Qualifications.d.ts +92 -86
- package/dist/types/Redemptions.d.ts +215 -205
- package/dist/types/Rewards.d.ts +220 -219
- package/dist/types/Segments.d.ts +34 -32
- package/dist/types/Stackable.d.ts +106 -101
- package/dist/types/UtilityTypes.d.ts +5 -3
- package/dist/types/ValidateSession.d.ts +19 -17
- package/dist/types/ValidationError.d.ts +9 -7
- package/dist/types/ValidationRules.d.ts +96 -93
- package/dist/types/Validations.d.ts +109 -98
- package/dist/types/Vouchers.d.ts +452 -364
- package/dist/types/index.d.ts +27 -25
- package/dist/voucherifysdk.cjs +2023 -0
- package/dist/voucherifysdk.cjs.map +1 -0
- package/dist/voucherifysdk.esm.js +981 -1256
- package/dist/voucherifysdk.esm.js.map +1 -1
- package/package.json +13 -9
- package/CHANGELOG.md +0 -663
- package/dist/voucherifysdk.umd.development.js +0 -2270
- package/dist/voucherifysdk.umd.development.js.map +0 -1
- package/dist/voucherifysdk.umd.production.min.js +0 -2
- package/dist/voucherifysdk.umd.production.min.js.map +0 -1
|
@@ -1,37 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
|
|
6
|
+
// src/types/DiscountVoucher.ts
|
|
7
|
+
var DiscountVouchersTypesEnum = /* @__PURE__ */ ((DiscountVouchersTypesEnum2) => {
|
|
8
|
+
DiscountVouchersTypesEnum2["AMOUNT"] = "AMOUNT";
|
|
9
|
+
DiscountVouchersTypesEnum2["PERCENT"] = "PERCENT";
|
|
10
|
+
DiscountVouchersTypesEnum2["UNIT"] = "UNIT";
|
|
11
|
+
DiscountVouchersTypesEnum2["FIXED"] = "FIXED";
|
|
12
|
+
return DiscountVouchersTypesEnum2;
|
|
13
|
+
})(DiscountVouchersTypesEnum || {});
|
|
14
|
+
|
|
15
|
+
// src/RequestController.ts
|
|
16
|
+
import axios from "axios";
|
|
17
|
+
import Qs from "qs";
|
|
18
|
+
|
|
19
|
+
// src/VoucherifyError.ts
|
|
20
|
+
var _VoucherifyError = class _VoucherifyError extends Error {
|
|
18
21
|
constructor(statusCode, body, axiosError) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
body = (_body = body) != null ? _body : {};
|
|
22
|
-
const message = ((_body2 = body) == null ? void 0 : _body2.message) || generateMessage(body, statusCode);
|
|
22
|
+
body = body != null ? body : {};
|
|
23
|
+
const message = (body == null ? void 0 : body.message) || generateMessage(body, statusCode);
|
|
23
24
|
super(message);
|
|
24
|
-
this
|
|
25
|
-
this
|
|
26
|
-
this
|
|
27
|
-
this
|
|
28
|
-
this
|
|
29
|
-
this
|
|
30
|
-
this
|
|
31
|
-
this
|
|
32
|
-
this
|
|
33
|
-
this
|
|
34
|
-
this
|
|
25
|
+
__publicField(this, "code");
|
|
26
|
+
__publicField(this, "key");
|
|
27
|
+
__publicField(this, "details");
|
|
28
|
+
__publicField(this, "request_id");
|
|
29
|
+
__publicField(this, "resource_id");
|
|
30
|
+
__publicField(this, "resource_type");
|
|
31
|
+
__publicField(this, "related_object_ids");
|
|
32
|
+
__publicField(this, "related_object_type");
|
|
33
|
+
__publicField(this, "related_object_total");
|
|
34
|
+
__publicField(this, "error");
|
|
35
|
+
__publicField(this, "cause");
|
|
35
36
|
this.code = body.code;
|
|
36
37
|
this.key = body.key;
|
|
37
38
|
this.details = body.details;
|
|
@@ -44,34 +45,26 @@ class VoucherifyError extends Error {
|
|
|
44
45
|
this.error = body.error;
|
|
45
46
|
this.cause = axiosError;
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
};
|
|
49
|
+
__name(_VoucherifyError, "VoucherifyError");
|
|
50
|
+
var VoucherifyError = _VoucherifyError;
|
|
50
51
|
function generateMessage(body, statusCode) {
|
|
51
|
-
body = typeof body ===
|
|
52
|
+
body = typeof body === "string" ? body : JSON.stringify(body, null, 2);
|
|
52
53
|
return `Unexpected status code: ${statusCode} - Details: ${body}`;
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
this.baseURL = void 0;
|
|
68
|
-
this.basePath = void 0;
|
|
69
|
-
this.headers = void 0;
|
|
70
|
-
this.request = void 0;
|
|
71
|
-
this.lastResponseHeaders = void 0;
|
|
72
|
-
this.isLastResponseHeadersSet = void 0;
|
|
73
|
-
this.exposeErrorCause = void 0;
|
|
74
|
-
this.timeoutMs = void 0;
|
|
55
|
+
__name(generateMessage, "generateMessage");
|
|
56
|
+
|
|
57
|
+
// src/RequestController.ts
|
|
58
|
+
var _RequestController = class _RequestController {
|
|
59
|
+
constructor({ basePath, baseURL, headers, exposeErrorCause, timeoutMs }) {
|
|
60
|
+
__publicField(this, "baseURL");
|
|
61
|
+
__publicField(this, "basePath");
|
|
62
|
+
__publicField(this, "headers");
|
|
63
|
+
__publicField(this, "request");
|
|
64
|
+
__publicField(this, "lastResponseHeaders");
|
|
65
|
+
__publicField(this, "isLastResponseHeadersSet");
|
|
66
|
+
__publicField(this, "exposeErrorCause");
|
|
67
|
+
__publicField(this, "timeoutMs");
|
|
75
68
|
this.basePath = basePath;
|
|
76
69
|
this.baseURL = baseURL;
|
|
77
70
|
this.headers = headers;
|
|
@@ -83,1920 +76,1675 @@ class RequestController {
|
|
|
83
76
|
baseURL: `${this.baseURL}/${this.basePath}/`,
|
|
84
77
|
allowAbsoluteUrls: false,
|
|
85
78
|
headers: this.headers,
|
|
86
|
-
responseType:
|
|
79
|
+
responseType: "json"
|
|
87
80
|
});
|
|
88
|
-
this.request.interceptors.response.use(void 0, error => {
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
81
|
+
this.request.interceptors.response.use(void 0, (error) => {
|
|
82
|
+
var _a;
|
|
83
|
+
if ((_a = error == null ? void 0 : error.response) == null ? void 0 : _a.status) {
|
|
84
|
+
return Promise.reject(
|
|
85
|
+
new VoucherifyError(
|
|
86
|
+
error.response.status,
|
|
87
|
+
error.response.data,
|
|
88
|
+
this.exposeErrorCause === true ? error : void 0
|
|
89
|
+
)
|
|
90
|
+
);
|
|
96
91
|
}
|
|
97
|
-
|
|
98
92
|
return Promise.reject(error);
|
|
99
93
|
});
|
|
100
94
|
}
|
|
101
|
-
|
|
102
95
|
isLastReponseHeadersSet() {
|
|
103
96
|
return this.isLastResponseHeadersSet;
|
|
104
97
|
}
|
|
105
|
-
|
|
106
98
|
getLastResponseHeaders() {
|
|
107
99
|
return this.lastResponseHeaders;
|
|
108
100
|
}
|
|
109
|
-
|
|
110
101
|
setLastResponseHeaders(headers) {
|
|
111
102
|
const result = {};
|
|
112
|
-
|
|
113
103
|
for (const key in headers) {
|
|
114
104
|
result[key] = String(headers[key]);
|
|
115
105
|
}
|
|
116
|
-
|
|
117
106
|
this.lastResponseHeaders = result;
|
|
118
107
|
this.isLastResponseHeadersSet = true;
|
|
119
108
|
}
|
|
120
|
-
|
|
121
109
|
setBaseUrl(baseURL) {
|
|
122
110
|
this.baseURL = baseURL;
|
|
123
111
|
this.request.defaults.baseURL = `${baseURL}/${this.basePath}/`;
|
|
124
112
|
}
|
|
125
|
-
|
|
126
113
|
async get(path, params) {
|
|
127
114
|
const response = await this.request.get(path, {
|
|
128
115
|
params,
|
|
129
|
-
paramsSerializer:
|
|
130
|
-
return Qs.stringify(
|
|
131
|
-
},
|
|
116
|
+
paramsSerializer: /* @__PURE__ */ __name(function(params2) {
|
|
117
|
+
return Qs.stringify(params2);
|
|
118
|
+
}, "paramsSerializer"),
|
|
132
119
|
timeout: this.timeoutMs
|
|
133
120
|
});
|
|
134
121
|
this.setLastResponseHeaders(response.headers);
|
|
135
122
|
return response.data;
|
|
136
123
|
}
|
|
137
|
-
|
|
138
124
|
async post(path, body, params, headers) {
|
|
139
125
|
const response = await this.request.post(path, body, {
|
|
140
126
|
params,
|
|
141
|
-
paramsSerializer:
|
|
142
|
-
return Qs.stringify(
|
|
143
|
-
},
|
|
127
|
+
paramsSerializer: /* @__PURE__ */ __name(function(params2) {
|
|
128
|
+
return Qs.stringify(params2);
|
|
129
|
+
}, "paramsSerializer"),
|
|
144
130
|
headers,
|
|
145
131
|
timeout: this.timeoutMs
|
|
146
132
|
});
|
|
147
133
|
this.setLastResponseHeaders(response.headers);
|
|
148
134
|
return response.data;
|
|
149
135
|
}
|
|
150
|
-
|
|
151
136
|
async put(path, body, params) {
|
|
152
|
-
const response = await this.request.put(path, body, {
|
|
153
|
-
params,
|
|
154
|
-
timeout: this.timeoutMs
|
|
155
|
-
});
|
|
137
|
+
const response = await this.request.put(path, body, { params, timeout: this.timeoutMs });
|
|
156
138
|
this.setLastResponseHeaders(response.headers);
|
|
157
139
|
return response.data;
|
|
158
140
|
}
|
|
159
|
-
|
|
160
141
|
async delete(path, params) {
|
|
161
|
-
const response = await this.request.delete(path, {
|
|
162
|
-
params,
|
|
163
|
-
timeout: this.timeoutMs
|
|
164
|
-
});
|
|
142
|
+
const response = await this.request.delete(path, { params, timeout: this.timeoutMs });
|
|
165
143
|
this.setLastResponseHeaders(response.headers);
|
|
166
144
|
return response.data;
|
|
167
145
|
}
|
|
146
|
+
};
|
|
147
|
+
__name(_RequestController, "RequestController");
|
|
148
|
+
var RequestController = _RequestController;
|
|
168
149
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
function encode(value = '') {
|
|
150
|
+
// src/helpers.ts
|
|
151
|
+
function encode(value = "") {
|
|
172
152
|
return encodeURIComponent(value);
|
|
173
153
|
}
|
|
154
|
+
__name(encode, "encode");
|
|
174
155
|
function isString(value) {
|
|
175
|
-
return typeof value ===
|
|
156
|
+
return typeof value === "string";
|
|
176
157
|
}
|
|
158
|
+
__name(isString, "isString");
|
|
177
159
|
function isOptionalString(value) {
|
|
178
160
|
return value == null || isString(value);
|
|
179
161
|
}
|
|
162
|
+
__name(isOptionalString, "isOptionalString");
|
|
180
163
|
function isObject(value) {
|
|
181
|
-
return typeof value ===
|
|
164
|
+
return typeof value === "object" && !Array.isArray(value) && value !== null;
|
|
182
165
|
}
|
|
166
|
+
__name(isObject, "isObject");
|
|
183
167
|
function isOptionalObject(value) {
|
|
184
168
|
return value == null || isObject(value);
|
|
185
169
|
}
|
|
170
|
+
__name(isOptionalObject, "isOptionalObject");
|
|
186
171
|
function environment() {
|
|
187
|
-
if (typeof window !==
|
|
188
|
-
return
|
|
189
|
-
} else if (typeof self ===
|
|
190
|
-
return
|
|
191
|
-
} else if (typeof process !==
|
|
172
|
+
if (typeof window !== "undefined" && typeof window.document !== "undefined") {
|
|
173
|
+
return "Browser";
|
|
174
|
+
} else if (typeof self === "object" && self.constructor && self.constructor.name === "DedicatedWorkerGlobalScope") {
|
|
175
|
+
return "WebWorker";
|
|
176
|
+
} else if (typeof process !== "undefined" && process.versions != null && process.versions.node != null) {
|
|
192
177
|
return `Node.js-${process.version}`;
|
|
193
|
-
} else if (typeof window !==
|
|
194
|
-
return
|
|
178
|
+
} else if (typeof window !== "undefined" && window.name === "nodejs" || navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom")) {
|
|
179
|
+
return "JsDom";
|
|
195
180
|
}
|
|
196
|
-
|
|
197
|
-
return 'Unknown';
|
|
181
|
+
return "Unknown";
|
|
198
182
|
}
|
|
183
|
+
__name(environment, "environment");
|
|
199
184
|
function assert(condition, message) {
|
|
200
185
|
if (condition) return;
|
|
201
186
|
throw new Error(message);
|
|
202
187
|
}
|
|
203
|
-
|
|
204
|
-
* Return an object containing all properties of `obj` excluding the ones in `keys` array
|
|
205
|
-
* e.g:
|
|
206
|
-
* ```javascript
|
|
207
|
-
* omit({ a: 1, b: 2, c: 3, d: 4 }, ['b', 'd']) // output: { a: 1, c: 3 }
|
|
208
|
-
* ```
|
|
209
|
-
*/
|
|
210
|
-
|
|
188
|
+
__name(assert, "assert");
|
|
211
189
|
function omit(obj, keys) {
|
|
212
|
-
return Object.fromEntries(
|
|
213
|
-
|
|
214
|
-
|
|
190
|
+
return Object.fromEntries(
|
|
191
|
+
Object.entries(obj).filter(([propertyKey]) => {
|
|
192
|
+
return !keys.includes(propertyKey);
|
|
193
|
+
})
|
|
194
|
+
);
|
|
215
195
|
}
|
|
196
|
+
__name(omit, "omit");
|
|
216
197
|
|
|
217
|
-
|
|
198
|
+
// src/AsyncActions.ts
|
|
199
|
+
var _AsyncActions = class _AsyncActions {
|
|
218
200
|
constructor(client) {
|
|
219
|
-
this.client = void 0;
|
|
220
201
|
this.client = client;
|
|
221
202
|
}
|
|
222
|
-
/**
|
|
223
|
-
* @see https://docs.voucherify.io/reference/get-async-actions-1
|
|
203
|
+
/**
|
|
204
|
+
* @see https://docs.voucherify.io/reference/get-async-actions-1
|
|
224
205
|
*/
|
|
225
|
-
|
|
226
|
-
|
|
227
206
|
get(asyncActionId) {
|
|
228
207
|
return this.client.get(`/async-actions/${encode(asyncActionId)}`);
|
|
229
208
|
}
|
|
230
|
-
/**
|
|
231
|
-
* @see https://docs.voucherify.io/reference/list-async-actions
|
|
209
|
+
/**
|
|
210
|
+
* @see https://docs.voucherify.io/reference/list-async-actions
|
|
232
211
|
*/
|
|
233
|
-
|
|
234
|
-
|
|
235
212
|
list(params) {
|
|
236
|
-
return this.client.get(
|
|
213
|
+
return this.client.get("/async-actions", params);
|
|
237
214
|
}
|
|
215
|
+
};
|
|
216
|
+
__name(_AsyncActions, "AsyncActions");
|
|
217
|
+
var AsyncActions = _AsyncActions;
|
|
238
218
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
class
|
|
219
|
+
// src/Campaigns.ts
|
|
220
|
+
import FormData from "form-data";
|
|
221
|
+
var _CampaignsQualifications = class _CampaignsQualifications {
|
|
242
222
|
constructor(client) {
|
|
243
|
-
this.client = void 0;
|
|
244
223
|
this.client = client;
|
|
245
224
|
}
|
|
246
|
-
|
|
247
225
|
examine(body = {}, params) {
|
|
248
|
-
return this.client.post(
|
|
226
|
+
return this.client.post("/campaigns/qualification", body, params);
|
|
249
227
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
class
|
|
228
|
+
};
|
|
229
|
+
__name(_CampaignsQualifications, "CampaignsQualifications");
|
|
230
|
+
var CampaignsQualifications = _CampaignsQualifications;
|
|
231
|
+
var _Campaigns = class _Campaigns {
|
|
254
232
|
constructor(client) {
|
|
255
|
-
this.client = void 0;
|
|
256
|
-
this.qualifications = void 0;
|
|
257
233
|
this.client = client;
|
|
234
|
+
__publicField(this, "qualifications");
|
|
258
235
|
this.qualifications = new CampaignsQualifications(this.client);
|
|
259
236
|
}
|
|
260
|
-
/**
|
|
261
|
-
* @see https://docs.voucherify.io/reference/create-campaign
|
|
237
|
+
/**
|
|
238
|
+
* @see https://docs.voucherify.io/reference/create-campaign
|
|
262
239
|
*/
|
|
263
|
-
|
|
264
|
-
|
|
265
240
|
create(campaign) {
|
|
266
|
-
return this.client.post(
|
|
241
|
+
return this.client.post("/campaigns", campaign);
|
|
267
242
|
}
|
|
268
|
-
/**
|
|
269
|
-
* @see https://docs.voucherify.io/reference/update-campaign
|
|
243
|
+
/**
|
|
244
|
+
* @see https://docs.voucherify.io/reference/update-campaign
|
|
270
245
|
*/
|
|
271
|
-
|
|
272
|
-
|
|
273
246
|
update(nameOrId, campaign) {
|
|
274
247
|
return this.client.put(`/campaigns/${encode(nameOrId)}`, campaign);
|
|
275
248
|
}
|
|
276
|
-
/**
|
|
277
|
-
* @see https://docs.voucherify.io/reference/get-campaign
|
|
249
|
+
/**
|
|
250
|
+
* @see https://docs.voucherify.io/reference/get-campaign
|
|
278
251
|
*/
|
|
279
|
-
|
|
280
|
-
|
|
281
252
|
get(name) {
|
|
282
253
|
return this.client.get(`/campaigns/${encode(name)}`);
|
|
283
254
|
}
|
|
284
|
-
/**
|
|
285
|
-
* @see https://docs.voucherify.io/reference/delete-campaign
|
|
255
|
+
/**
|
|
256
|
+
* @see https://docs.voucherify.io/reference/delete-campaign
|
|
286
257
|
*/
|
|
287
|
-
|
|
288
|
-
|
|
289
258
|
delete(name, params = {}) {
|
|
290
259
|
return this.client.delete(`/campaigns/${encode(name)}`, params);
|
|
291
260
|
}
|
|
292
|
-
/**
|
|
293
|
-
* @see https://docs.voucherify.io/reference/add-voucher-to-campaign
|
|
261
|
+
/**
|
|
262
|
+
* @see https://docs.voucherify.io/reference/add-voucher-to-campaign
|
|
294
263
|
*/
|
|
295
|
-
|
|
296
|
-
|
|
297
264
|
addVoucher(name, body = {}, params = {}) {
|
|
298
265
|
return this.client.post(`/campaigns/${encode(name)}/vouchers`, body, params);
|
|
299
266
|
}
|
|
300
|
-
/**
|
|
301
|
-
* @see https://docs.voucherify.io/reference/add-voucher-with-certain-code-to-campaign
|
|
267
|
+
/**
|
|
268
|
+
* @see https://docs.voucherify.io/reference/add-voucher-with-certain-code-to-campaign
|
|
302
269
|
*/
|
|
303
|
-
|
|
304
|
-
|
|
305
270
|
addCertainVoucher(name, code, body = {}) {
|
|
306
|
-
return this.client.post(
|
|
271
|
+
return this.client.post(
|
|
272
|
+
`/campaigns/${encode(name)}/vouchers/${encode(code)}`,
|
|
273
|
+
body
|
|
274
|
+
);
|
|
307
275
|
}
|
|
308
|
-
/**
|
|
309
|
-
* @see https://docs.voucherify.io/reference/import-vouchers
|
|
276
|
+
/**
|
|
277
|
+
* @see https://docs.voucherify.io/reference/import-vouchers
|
|
310
278
|
*/
|
|
311
|
-
|
|
312
|
-
|
|
313
279
|
importVouchers(campaignName, vouchers) {
|
|
314
280
|
return this.client.post(`/campaigns/${encode(campaignName)}/import`, vouchers);
|
|
315
281
|
}
|
|
316
|
-
/**
|
|
317
|
-
* @see https://docs.voucherify.io/reference/list-campaigns
|
|
282
|
+
/**
|
|
283
|
+
* @see https://docs.voucherify.io/reference/list-campaigns
|
|
318
284
|
*/
|
|
319
|
-
|
|
320
|
-
|
|
321
285
|
list(params = {}) {
|
|
322
|
-
return this.client.get(
|
|
286
|
+
return this.client.get("/campaigns", params);
|
|
323
287
|
}
|
|
324
|
-
/**
|
|
325
|
-
* @see https://api.voucherify.io/v1/campaigns/{campaignId}/importCSV
|
|
288
|
+
/**
|
|
289
|
+
* @see https://api.voucherify.io/v1/campaigns/{campaignId}/importCSV
|
|
326
290
|
*/
|
|
327
|
-
|
|
328
|
-
|
|
329
291
|
async importVouchersCSV(campaignId, filePath) {
|
|
330
|
-
assert(
|
|
331
|
-
|
|
292
|
+
assert(
|
|
293
|
+
environment().startsWith("Node"),
|
|
294
|
+
`Method "client.campaigns.importVouchersCSV(campaignId, filePath)" is only for Node environment`
|
|
295
|
+
);
|
|
296
|
+
const fs = (await import("fs")).default;
|
|
332
297
|
const fileStream = fs.createReadStream(filePath);
|
|
333
298
|
const form = new FormData();
|
|
334
|
-
form.append(
|
|
335
|
-
const headers = {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
299
|
+
form.append("file", fileStream);
|
|
300
|
+
const headers = { "Content-Type": "multipart/form-data" };
|
|
301
|
+
return this.client.post(
|
|
302
|
+
`/campaigns/${campaignId}/importCSV`,
|
|
303
|
+
form,
|
|
304
|
+
void 0,
|
|
305
|
+
headers
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* @see https://docs.voucherify.io/reference/enable-campaign
|
|
342
310
|
*/
|
|
343
|
-
|
|
344
|
-
|
|
345
311
|
enable(campaignId) {
|
|
346
312
|
return this.client.post(`/campaigns/${encode(campaignId)}/enable`, {});
|
|
347
313
|
}
|
|
348
|
-
/**
|
|
349
|
-
* @see https://docs.voucherify.io/reference/disable-campaign
|
|
314
|
+
/**
|
|
315
|
+
* @see https://docs.voucherify.io/reference/disable-campaign
|
|
350
316
|
*/
|
|
351
|
-
|
|
352
|
-
|
|
353
317
|
disable(campaignId) {
|
|
354
318
|
return this.client.post(`/campaigns/${encode(campaignId)}/disable`, {});
|
|
355
319
|
}
|
|
320
|
+
};
|
|
321
|
+
__name(_Campaigns, "Campaigns");
|
|
322
|
+
var Campaigns = _Campaigns;
|
|
356
323
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
class DistributionsPublications {
|
|
324
|
+
// src/Distributions.ts
|
|
325
|
+
var _DistributionsPublications = class _DistributionsPublications {
|
|
360
326
|
constructor(client) {
|
|
361
|
-
this.client = void 0;
|
|
362
327
|
this.client = client;
|
|
363
328
|
}
|
|
364
|
-
/**
|
|
365
|
-
* @see https://docs.voucherify.io/reference/list-publications
|
|
329
|
+
/**
|
|
330
|
+
* @see https://docs.voucherify.io/reference/list-publications
|
|
366
331
|
*/
|
|
367
|
-
|
|
368
|
-
|
|
369
332
|
list(params = {}) {
|
|
370
|
-
return this.client.get(
|
|
333
|
+
return this.client.get("/publications", params);
|
|
371
334
|
}
|
|
372
|
-
/**
|
|
373
|
-
* @see https://docs.voucherify.io/reference/create-publication
|
|
335
|
+
/**
|
|
336
|
+
* @see https://docs.voucherify.io/reference/create-publication
|
|
374
337
|
*/
|
|
375
|
-
|
|
376
|
-
|
|
377
338
|
create(params) {
|
|
378
|
-
return this.client.post(
|
|
339
|
+
return this.client.post("/publications", params);
|
|
379
340
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
class
|
|
341
|
+
};
|
|
342
|
+
__name(_DistributionsPublications, "DistributionsPublications");
|
|
343
|
+
var DistributionsPublications = _DistributionsPublications;
|
|
344
|
+
var _Distributions = class _Distributions {
|
|
384
345
|
constructor(client, exports) {
|
|
385
|
-
this.client = void 0;
|
|
386
|
-
this.exports = void 0;
|
|
387
|
-
this.publications = void 0;
|
|
388
346
|
this.client = client;
|
|
389
347
|
this.exports = exports;
|
|
348
|
+
__publicField(this, "publications");
|
|
390
349
|
this.publications = new DistributionsPublications(this.client);
|
|
391
350
|
}
|
|
351
|
+
};
|
|
352
|
+
__name(_Distributions, "Distributions");
|
|
353
|
+
var Distributions = _Distributions;
|
|
392
354
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
class Exports {
|
|
355
|
+
// src/Exports.ts
|
|
356
|
+
var _Exports = class _Exports {
|
|
396
357
|
constructor(client) {
|
|
397
|
-
this.client = void 0;
|
|
398
358
|
this.client = client;
|
|
399
359
|
}
|
|
400
|
-
/**
|
|
401
|
-
* @see https://docs.voucherify.io/reference/create-export
|
|
360
|
+
/**
|
|
361
|
+
* @see https://docs.voucherify.io/reference/create-export
|
|
402
362
|
*/
|
|
403
|
-
|
|
404
|
-
|
|
405
363
|
create(exportResource) {
|
|
406
|
-
return this.client.post(
|
|
364
|
+
return this.client.post("/exports", exportResource);
|
|
407
365
|
}
|
|
408
|
-
/**
|
|
409
|
-
* @see https://docs.voucherify.io/reference/list-exports
|
|
366
|
+
/**
|
|
367
|
+
* @see https://docs.voucherify.io/reference/list-exports
|
|
410
368
|
*/
|
|
411
|
-
|
|
412
|
-
|
|
413
369
|
list(query = {}) {
|
|
414
|
-
return this.client.get(
|
|
370
|
+
return this.client.get("/exports", query);
|
|
415
371
|
}
|
|
416
|
-
/**
|
|
417
|
-
* @see https://docs.voucherify.io/reference/get-export
|
|
372
|
+
/**
|
|
373
|
+
* @see https://docs.voucherify.io/reference/get-export
|
|
418
374
|
*/
|
|
419
|
-
|
|
420
|
-
|
|
421
375
|
get(exportResourceId) {
|
|
422
376
|
return this.client.get(`/exports/${encode(exportResourceId)}`);
|
|
423
377
|
}
|
|
424
|
-
/**
|
|
425
|
-
* @see https://docs.voucherify.io/reference/delete-export
|
|
378
|
+
/**
|
|
379
|
+
* @see https://docs.voucherify.io/reference/delete-export
|
|
426
380
|
*/
|
|
427
|
-
|
|
428
|
-
|
|
429
381
|
delete(exportResourceId) {
|
|
430
382
|
return this.client.delete(`/exports/${encode(exportResourceId)}`);
|
|
431
383
|
}
|
|
384
|
+
};
|
|
385
|
+
__name(_Exports, "Exports");
|
|
386
|
+
var Exports = _Exports;
|
|
432
387
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
class Events {
|
|
388
|
+
// src/Events.ts
|
|
389
|
+
var _Events = class _Events {
|
|
436
390
|
constructor(client) {
|
|
437
|
-
this.client = void 0;
|
|
438
391
|
this.client = client;
|
|
439
392
|
}
|
|
440
|
-
/**
|
|
441
|
-
* @see https://docs.voucherify.io/reference/track-custom-event-client-side
|
|
393
|
+
/**
|
|
394
|
+
* @see https://docs.voucherify.io/reference/track-custom-event-client-side
|
|
442
395
|
*/
|
|
443
|
-
|
|
444
|
-
|
|
445
396
|
create(eventName, params) {
|
|
446
|
-
params = { ...params,
|
|
447
|
-
|
|
448
|
-
};
|
|
449
|
-
return this.client.post('/events', params);
|
|
397
|
+
params = { ...params, event: eventName };
|
|
398
|
+
return this.client.post("/events", params);
|
|
450
399
|
}
|
|
400
|
+
};
|
|
401
|
+
__name(_Events, "Events");
|
|
402
|
+
var Events = _Events;
|
|
451
403
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
class Balance {
|
|
404
|
+
// src/Balance.ts
|
|
405
|
+
var _Balance = class _Balance {
|
|
455
406
|
constructor(client) {
|
|
456
|
-
this.client = void 0;
|
|
457
407
|
this.client = client;
|
|
458
408
|
}
|
|
459
|
-
/**
|
|
460
|
-
* Add Gift Voucher Balance
|
|
461
|
-
* This method gives a possibility to add balance to an existing gift voucher.
|
|
462
|
-
* @see https://docs.voucherify.io/reference/add-gift-voucher-balance
|
|
409
|
+
/**
|
|
410
|
+
* Add Gift Voucher Balance
|
|
411
|
+
* This method gives a possibility to add balance to an existing gift voucher.
|
|
412
|
+
* @see https://docs.voucherify.io/reference/add-gift-voucher-balance
|
|
463
413
|
*/
|
|
464
|
-
|
|
465
|
-
|
|
466
414
|
create(code, params) {
|
|
467
415
|
return this.client.post(`/vouchers/${encode(code)}/balance`, params);
|
|
468
416
|
}
|
|
417
|
+
};
|
|
418
|
+
__name(_Balance, "Balance");
|
|
419
|
+
var Balance = _Balance;
|
|
469
420
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
class
|
|
421
|
+
// src/Vouchers.ts
|
|
422
|
+
import FormData2 from "form-data";
|
|
423
|
+
var _VouchersQualification = class _VouchersQualification {
|
|
473
424
|
constructor(client) {
|
|
474
|
-
this.client = void 0;
|
|
475
425
|
this.client = client;
|
|
476
426
|
}
|
|
477
|
-
/**
|
|
478
|
-
* The method can be used for sending a request to display all vouchers qualified to the given customer and context (e.g., order, loyalty reward). A checking logic won't run among coupons from bulk unique codes campaigns. For campaigns with multiple unique codes, you should run a dedicated function for searching for qualified campaigns.
|
|
479
|
-
* As a sample use case, you can imagine a requirement of displaying below cart the coupons eligible to a customer. The customer can take and apply the proposed voucher.
|
|
480
|
-
*
|
|
481
|
-
* @see https://docs.voucherify.io/reference/push-qualification-request
|
|
427
|
+
/**
|
|
428
|
+
* The method can be used for sending a request to display all vouchers qualified to the given customer and context (e.g., order, loyalty reward). A checking logic won't run among coupons from bulk unique codes campaigns. For campaigns with multiple unique codes, you should run a dedicated function for searching for qualified campaigns.
|
|
429
|
+
* As a sample use case, you can imagine a requirement of displaying below cart the coupons eligible to a customer. The customer can take and apply the proposed voucher.
|
|
430
|
+
*
|
|
431
|
+
* @see https://docs.voucherify.io/reference/push-qualification-request
|
|
482
432
|
*/
|
|
483
|
-
|
|
484
|
-
|
|
485
433
|
examine(body, params = {}) {
|
|
486
|
-
return this.client.post(
|
|
434
|
+
return this.client.post("/vouchers/qualification", body, params);
|
|
487
435
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
class
|
|
436
|
+
};
|
|
437
|
+
__name(_VouchersQualification, "VouchersQualification");
|
|
438
|
+
var VouchersQualification = _VouchersQualification;
|
|
439
|
+
var _Vouchers = class _Vouchers {
|
|
492
440
|
constructor(client, balance) {
|
|
493
|
-
this.client = void 0;
|
|
494
|
-
this.balance = void 0;
|
|
495
|
-
this.qualifications = void 0;
|
|
496
441
|
this.client = client;
|
|
497
442
|
this.balance = balance;
|
|
443
|
+
__publicField(this, "qualifications");
|
|
498
444
|
this.qualifications = new VouchersQualification(this.client);
|
|
499
445
|
}
|
|
500
|
-
/**
|
|
501
|
-
* @see https://docs.voucherify.io/reference/create-voucher
|
|
446
|
+
/**
|
|
447
|
+
* @see https://docs.voucherify.io/reference/create-voucher
|
|
502
448
|
*/
|
|
503
|
-
|
|
504
|
-
|
|
505
449
|
create(voucher) {
|
|
506
450
|
return this.client.post(`/vouchers/${encode(voucher.code)}`, voucher);
|
|
507
451
|
}
|
|
508
|
-
/**
|
|
509
|
-
* @see https://docs.voucherify.io/reference/vouchers-get
|
|
452
|
+
/**
|
|
453
|
+
* @see https://docs.voucherify.io/reference/vouchers-get
|
|
510
454
|
*/
|
|
511
|
-
|
|
512
|
-
|
|
513
455
|
get(code) {
|
|
514
456
|
return this.client.get(`/vouchers/${encode(code)}`);
|
|
515
457
|
}
|
|
516
|
-
/**
|
|
517
|
-
* @see https://docs.voucherify.io/reference/update-voucher
|
|
458
|
+
/**
|
|
459
|
+
* @see https://docs.voucherify.io/reference/update-voucher
|
|
518
460
|
*/
|
|
519
|
-
|
|
520
|
-
|
|
521
461
|
update(voucher) {
|
|
522
462
|
return this.client.put(`/vouchers/${encode(voucher.code)}`, voucher);
|
|
523
463
|
}
|
|
524
|
-
/**
|
|
525
|
-
* @see https://docs.voucherify.io/reference/delete-voucher
|
|
464
|
+
/**
|
|
465
|
+
* @see https://docs.voucherify.io/reference/delete-voucher
|
|
526
466
|
*/
|
|
527
|
-
|
|
528
|
-
|
|
529
467
|
delete(code, params = {}) {
|
|
530
468
|
return this.client.delete(`/vouchers/${encode(code)}`, params);
|
|
531
469
|
}
|
|
532
|
-
/**
|
|
533
|
-
* @see https://docs.voucherify.io/reference/list-vouchers
|
|
470
|
+
/**
|
|
471
|
+
* @see https://docs.voucherify.io/reference/list-vouchers
|
|
534
472
|
*/
|
|
535
|
-
|
|
536
|
-
|
|
537
473
|
list(params = {}) {
|
|
538
|
-
return this.client.get(
|
|
474
|
+
return this.client.get("/vouchers", params);
|
|
539
475
|
}
|
|
540
|
-
/**
|
|
541
|
-
* @see https://docs.voucherify.io/reference/enable-voucher
|
|
476
|
+
/**
|
|
477
|
+
* @see https://docs.voucherify.io/reference/enable-voucher
|
|
542
478
|
*/
|
|
543
|
-
|
|
544
|
-
|
|
545
479
|
enable(code) {
|
|
546
480
|
return this.client.post(`/vouchers/${encode(code)}/enable`, {});
|
|
547
481
|
}
|
|
548
|
-
/**
|
|
549
|
-
* @see https://docs.voucherify.io/reference/disable-voucher
|
|
482
|
+
/**
|
|
483
|
+
* @see https://docs.voucherify.io/reference/disable-voucher
|
|
550
484
|
*/
|
|
551
|
-
|
|
552
|
-
|
|
553
485
|
disable(code) {
|
|
554
486
|
return this.client.post(`/vouchers/${encode(code)}/disable`, {});
|
|
555
487
|
}
|
|
556
|
-
/**
|
|
557
|
-
* @see https://docs.voucherify.io/reference/import-vouchers-1
|
|
488
|
+
/**
|
|
489
|
+
* @see https://docs.voucherify.io/reference/import-vouchers-1
|
|
558
490
|
*/
|
|
559
|
-
|
|
560
|
-
|
|
561
491
|
import(vouchers) {
|
|
562
|
-
return this.client.post(
|
|
492
|
+
return this.client.post("/vouchers/import", vouchers);
|
|
563
493
|
}
|
|
564
|
-
/**
|
|
565
|
-
* @see https://docs.voucherify.io/reference/aaupdate-vouchers-metadata-in-bulk
|
|
494
|
+
/**
|
|
495
|
+
* @see https://docs.voucherify.io/reference/aaupdate-vouchers-metadata-in-bulk
|
|
566
496
|
*/
|
|
567
|
-
|
|
568
|
-
|
|
569
497
|
bulkUpdateMetadata(params) {
|
|
570
|
-
return this.client.post(
|
|
498
|
+
return this.client.post("/vouchers/metadata/async", params);
|
|
571
499
|
}
|
|
572
|
-
/**
|
|
573
|
-
* @see https://docs.voucherify.io/reference/aa-update-vouchers-in-bulk
|
|
500
|
+
/**
|
|
501
|
+
* @see https://docs.voucherify.io/reference/aa-update-vouchers-in-bulk
|
|
574
502
|
*/
|
|
575
|
-
|
|
576
|
-
|
|
577
503
|
bulkUpdate(vouchers) {
|
|
578
|
-
return this.client.post(
|
|
504
|
+
return this.client.post("/vouchers/bulk/async", vouchers);
|
|
579
505
|
}
|
|
580
|
-
/**
|
|
581
|
-
* @see https://docs.voucherify.io/reference/release-validation-session
|
|
506
|
+
/**
|
|
507
|
+
* @see https://docs.voucherify.io/reference/release-validation-session
|
|
582
508
|
*/
|
|
583
|
-
|
|
584
|
-
|
|
585
509
|
releaseValidationSession(code, sessionKey) {
|
|
586
510
|
return this.client.delete(`/vouchers/${encode(code)}/sessions/${encode(sessionKey)}`);
|
|
587
511
|
}
|
|
588
|
-
/**
|
|
589
|
-
* @see https://docs.voucherify.io/reference/import-vouchers-using-csv
|
|
512
|
+
/**
|
|
513
|
+
* @see https://docs.voucherify.io/reference/import-vouchers-using-csv
|
|
590
514
|
*/
|
|
591
|
-
|
|
592
|
-
|
|
593
515
|
async importCSV(filePath) {
|
|
594
|
-
assert(
|
|
595
|
-
|
|
516
|
+
assert(
|
|
517
|
+
environment().startsWith("Node"),
|
|
518
|
+
`Method "client.vouchers.importCSV(filePath)" is only for Node environment`
|
|
519
|
+
);
|
|
520
|
+
const fs = (await import("fs")).default;
|
|
596
521
|
const fileStream = fs.createReadStream(filePath);
|
|
597
|
-
const form = new
|
|
598
|
-
form.append(
|
|
599
|
-
const headers = {
|
|
600
|
-
|
|
601
|
-
};
|
|
602
|
-
return this.client.post('/vouchers/importCSV', form, undefined, headers);
|
|
522
|
+
const form = new FormData2();
|
|
523
|
+
form.append("file", fileStream);
|
|
524
|
+
const headers = { "Content-Type": "multipart/form-data" };
|
|
525
|
+
return this.client.post("/vouchers/importCSV", form, void 0, headers);
|
|
603
526
|
}
|
|
604
|
-
/**
|
|
605
|
-
* @see https://docs.voucherify.io/reference/list-voucher-transactions
|
|
527
|
+
/**
|
|
528
|
+
* @see https://docs.voucherify.io/reference/list-voucher-transactions
|
|
606
529
|
*/
|
|
607
|
-
|
|
608
|
-
|
|
609
530
|
listTransactions(code, params) {
|
|
610
531
|
return this.client.get(`/vouchers/${encode(code)}/transactions`, params);
|
|
611
532
|
}
|
|
612
|
-
/**
|
|
613
|
-
* @see https://docs.voucherify.io/reference/export-voucher-transactions
|
|
533
|
+
/**
|
|
534
|
+
* @see https://docs.voucherify.io/reference/export-voucher-transactions
|
|
614
535
|
*/
|
|
615
|
-
|
|
616
|
-
|
|
617
536
|
exportTransactions(code, body) {
|
|
618
|
-
return this.client.post(
|
|
537
|
+
return this.client.post(
|
|
538
|
+
`/vouchers/${encode(code)}/transactions/export`,
|
|
539
|
+
body
|
|
540
|
+
);
|
|
619
541
|
}
|
|
542
|
+
};
|
|
543
|
+
__name(_Vouchers, "Vouchers");
|
|
544
|
+
var Vouchers = _Vouchers;
|
|
620
545
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
class Validations {
|
|
546
|
+
// src/Validations.ts
|
|
547
|
+
var _Validations = class _Validations {
|
|
624
548
|
constructor(client, promotions) {
|
|
625
|
-
this.client = void 0;
|
|
626
|
-
this.promotions = void 0;
|
|
627
549
|
this.client = client;
|
|
628
550
|
this.promotions = promotions;
|
|
629
551
|
}
|
|
630
|
-
/**
|
|
631
|
-
* @see https://docs.voucherify.io/reference/validate-voucher
|
|
552
|
+
/**
|
|
553
|
+
* @see https://docs.voucherify.io/reference/validate-voucher
|
|
632
554
|
*/
|
|
633
|
-
|
|
634
|
-
|
|
635
555
|
validateVoucher(code, params = {}) {
|
|
636
556
|
return this.client.post(`/vouchers/${encode(code)}/validate`, params);
|
|
637
557
|
}
|
|
638
|
-
|
|
639
558
|
validate(code, context = {}) {
|
|
640
559
|
if (isObject(code)) {
|
|
641
560
|
return this.promotions.validate(code);
|
|
642
561
|
}
|
|
643
|
-
|
|
644
562
|
return this.validateVoucher(code, context);
|
|
645
563
|
}
|
|
646
|
-
/**
|
|
647
|
-
* @see https://docs.voucherify.io/reference/validate-stacked-discounts-1
|
|
564
|
+
/**
|
|
565
|
+
* @see https://docs.voucherify.io/reference/validate-stacked-discounts-1
|
|
648
566
|
*/
|
|
649
|
-
|
|
650
|
-
|
|
651
567
|
validateStackable(params) {
|
|
652
568
|
return this.client.post(`/validations`, params);
|
|
653
569
|
}
|
|
570
|
+
};
|
|
571
|
+
__name(_Validations, "Validations");
|
|
572
|
+
var Validations = _Validations;
|
|
654
573
|
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
class Redemptions {
|
|
574
|
+
// src/Redemptions.ts
|
|
575
|
+
var _Redemptions = class _Redemptions {
|
|
658
576
|
constructor(client) {
|
|
659
|
-
this.client = void 0;
|
|
660
577
|
this.client = client;
|
|
661
578
|
}
|
|
662
|
-
/**
|
|
663
|
-
* @see https://docs.voucherify.io/reference/redeem-voucher
|
|
579
|
+
/**
|
|
580
|
+
* @see https://docs.voucherify.io/reference/redeem-voucher
|
|
664
581
|
*/
|
|
665
|
-
|
|
666
|
-
|
|
667
582
|
redeem(code, body = {}) {
|
|
668
583
|
return this.client.post(`/vouchers/${encode(code)}/redemption`, body);
|
|
669
584
|
}
|
|
670
|
-
/**
|
|
671
|
-
* @see https://docs.voucherify.io/reference/redeem-stacked-discounts
|
|
585
|
+
/**
|
|
586
|
+
* @see https://docs.voucherify.io/reference/redeem-stacked-discounts
|
|
672
587
|
*/
|
|
673
|
-
|
|
674
|
-
|
|
675
588
|
redeemStackable(params) {
|
|
676
589
|
return this.client.post(`/redemptions`, params);
|
|
677
590
|
}
|
|
678
|
-
/**
|
|
679
|
-
* @see https://docs.voucherify.io/reference/get-redemption
|
|
591
|
+
/**
|
|
592
|
+
* @see https://docs.voucherify.io/reference/get-redemption
|
|
680
593
|
*/
|
|
681
|
-
|
|
682
|
-
|
|
683
594
|
get(redemptionId) {
|
|
684
595
|
return this.client.get(`/redemptions/${encode(redemptionId)}`);
|
|
685
596
|
}
|
|
686
|
-
/**
|
|
687
|
-
* @see https://docs.voucherify.io/reference/list-redemptions
|
|
597
|
+
/**
|
|
598
|
+
* @see https://docs.voucherify.io/reference/list-redemptions
|
|
688
599
|
*/
|
|
689
|
-
|
|
690
|
-
|
|
691
600
|
list(params = {}) {
|
|
692
|
-
return this.client.get(
|
|
601
|
+
return this.client.get("/redemptions", params);
|
|
693
602
|
}
|
|
694
|
-
/**
|
|
695
|
-
* @see https://docs.voucherify.io/reference/vouchers-redemptions
|
|
603
|
+
/**
|
|
604
|
+
* @see https://docs.voucherify.io/reference/vouchers-redemptions
|
|
696
605
|
*/
|
|
697
|
-
|
|
698
|
-
|
|
699
606
|
getForVoucher(code) {
|
|
700
607
|
return this.client.get(`/vouchers/${encode(code)}/redemption`);
|
|
701
608
|
}
|
|
702
|
-
/**
|
|
703
|
-
* @see https://docs.voucherify.io/reference/rollback-redemption
|
|
609
|
+
/**
|
|
610
|
+
* @see https://docs.voucherify.io/reference/rollback-redemption
|
|
704
611
|
*/
|
|
705
|
-
|
|
706
|
-
|
|
707
612
|
rollback(redemptionId, params) {
|
|
708
613
|
let queryParams = {};
|
|
709
614
|
let payload = {};
|
|
710
|
-
|
|
711
615
|
if (isString(params)) {
|
|
712
616
|
queryParams.reason = params;
|
|
713
617
|
} else if (isObject(params)) {
|
|
714
|
-
const {
|
|
715
|
-
reason,
|
|
716
|
-
tracking_id: trackingId,
|
|
717
|
-
customer
|
|
718
|
-
} = params;
|
|
618
|
+
const { reason, tracking_id: trackingId, customer } = params;
|
|
719
619
|
queryParams = {
|
|
720
|
-
reason: reason ? reason :
|
|
721
|
-
tracking_id: trackingId ? trackingId :
|
|
722
|
-
};
|
|
723
|
-
payload = {
|
|
724
|
-
customer
|
|
620
|
+
reason: reason ? reason : void 0,
|
|
621
|
+
tracking_id: trackingId ? trackingId : void 0
|
|
725
622
|
};
|
|
623
|
+
payload = { customer };
|
|
726
624
|
}
|
|
727
|
-
|
|
728
|
-
|
|
625
|
+
return this.client.post(
|
|
626
|
+
`/redemptions/${encode(redemptionId)}/rollback`,
|
|
627
|
+
payload,
|
|
628
|
+
queryParams
|
|
629
|
+
);
|
|
729
630
|
}
|
|
730
|
-
/**
|
|
731
|
-
* @see https://docs.voucherify.io/reference/rollback-stackable-redemptions
|
|
732
|
-
* Types of params and queryParams WILL be changed in future - please do not depend on it!
|
|
631
|
+
/**
|
|
632
|
+
* @see https://docs.voucherify.io/reference/rollback-stackable-redemptions
|
|
633
|
+
* Types of params and queryParams WILL be changed in future - please do not depend on it!
|
|
733
634
|
*/
|
|
734
|
-
|
|
735
|
-
|
|
736
635
|
rollbackStackable(parentRedemptionId, params, queryParams) {
|
|
737
|
-
return this.client.post(
|
|
636
|
+
return this.client.post(
|
|
637
|
+
`/redemptions/${encode(parentRedemptionId)}/rollbacks`,
|
|
638
|
+
params,
|
|
639
|
+
queryParams
|
|
640
|
+
);
|
|
738
641
|
}
|
|
642
|
+
};
|
|
643
|
+
__name(_Redemptions, "Redemptions");
|
|
644
|
+
var Redemptions = _Redemptions;
|
|
739
645
|
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
class PromotionTiers {
|
|
646
|
+
// src/PromotionTiers.ts
|
|
647
|
+
var _PromotionTiers = class _PromotionTiers {
|
|
743
648
|
constructor(client) {
|
|
744
|
-
this.client = void 0;
|
|
745
649
|
this.client = client;
|
|
746
650
|
}
|
|
747
|
-
/**
|
|
748
|
-
* @see https://docs.voucherify.io/reference/list-promotion-tiers
|
|
651
|
+
/**
|
|
652
|
+
* @see https://docs.voucherify.io/reference/list-promotion-tiers
|
|
749
653
|
*/
|
|
750
|
-
|
|
751
|
-
|
|
752
654
|
listAll(params = {}) {
|
|
753
|
-
return this.client.get(
|
|
655
|
+
return this.client.get("/promotions/tiers", params);
|
|
754
656
|
}
|
|
755
|
-
/**
|
|
756
|
-
* @see https://docs.voucherify.io/reference/get-promotions
|
|
657
|
+
/**
|
|
658
|
+
* @see https://docs.voucherify.io/reference/get-promotions
|
|
757
659
|
*/
|
|
758
|
-
|
|
759
|
-
|
|
760
660
|
list(promotionId) {
|
|
761
661
|
return this.client.get(`/promotions/${encode(promotionId)}/tiers`);
|
|
762
662
|
}
|
|
763
|
-
/**
|
|
764
|
-
* @see https://docs.voucherify.io/reference/get-promotion-tier
|
|
663
|
+
/**
|
|
664
|
+
* @see https://docs.voucherify.io/reference/get-promotion-tier
|
|
765
665
|
*/
|
|
766
|
-
|
|
767
|
-
|
|
768
666
|
get(tierId) {
|
|
769
667
|
return this.client.get(`/promotions/tiers/${encode(tierId)}`);
|
|
770
668
|
}
|
|
771
|
-
/**
|
|
772
|
-
* @see https://docs.voucherify.io/reference/add-promotion-tier-to-campaign
|
|
669
|
+
/**
|
|
670
|
+
* @see https://docs.voucherify.io/reference/add-promotion-tier-to-campaign
|
|
773
671
|
*/
|
|
774
|
-
|
|
775
|
-
|
|
776
672
|
create(promotionId, params) {
|
|
777
673
|
return this.client.post(`/promotions/${encode(promotionId)}/tiers`, params);
|
|
778
674
|
}
|
|
779
|
-
/**
|
|
780
|
-
* @see https://docs.voucherify.io/reference/redeem-promotion
|
|
675
|
+
/**
|
|
676
|
+
* @see https://docs.voucherify.io/reference/redeem-promotion
|
|
781
677
|
*/
|
|
782
|
-
|
|
783
|
-
|
|
784
678
|
redeem(promotionsTierId, params) {
|
|
785
|
-
return this.client.post(
|
|
679
|
+
return this.client.post(
|
|
680
|
+
`/promotions/tiers/${encode(promotionsTierId)}/redemption`,
|
|
681
|
+
params
|
|
682
|
+
);
|
|
786
683
|
}
|
|
787
|
-
/**
|
|
788
|
-
* @see https://docs.voucherify.io/reference/update-promotion
|
|
684
|
+
/**
|
|
685
|
+
* @see https://docs.voucherify.io/reference/update-promotion
|
|
789
686
|
*/
|
|
790
|
-
|
|
791
|
-
|
|
792
687
|
update(params) {
|
|
793
688
|
return this.client.put(`/promotions/tiers/${encode(params.id)}`, params);
|
|
794
689
|
}
|
|
795
|
-
/**
|
|
796
|
-
* @see https://docs.voucherify.io/reference/delete-promotion
|
|
690
|
+
/**
|
|
691
|
+
* @see https://docs.voucherify.io/reference/delete-promotion
|
|
797
692
|
*/
|
|
798
|
-
|
|
799
|
-
|
|
800
693
|
delete(promotionsTierId) {
|
|
801
694
|
return this.client.delete(`/promotions/tiers/${encode(promotionsTierId)}`);
|
|
802
695
|
}
|
|
696
|
+
};
|
|
697
|
+
__name(_PromotionTiers, "PromotionTiers");
|
|
698
|
+
var PromotionTiers = _PromotionTiers;
|
|
803
699
|
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
class Promotions {
|
|
700
|
+
// src/Promotions.ts
|
|
701
|
+
var _Promotions = class _Promotions {
|
|
807
702
|
constructor(client, tiers, stack) {
|
|
808
|
-
this.client = void 0;
|
|
809
|
-
this.tiers = void 0;
|
|
810
|
-
this.stack = void 0;
|
|
811
703
|
this.client = client;
|
|
812
704
|
this.tiers = tiers;
|
|
813
705
|
this.stack = stack;
|
|
814
706
|
}
|
|
815
|
-
/**
|
|
816
|
-
* @see https://docs.voucherify.io/reference/create-promotion-campaign
|
|
707
|
+
/**
|
|
708
|
+
* @see https://docs.voucherify.io/reference/create-promotion-campaign
|
|
817
709
|
*/
|
|
818
|
-
|
|
819
|
-
|
|
820
710
|
create(promotionCampaign) {
|
|
821
|
-
return this.client.post(
|
|
711
|
+
return this.client.post("/campaigns", promotionCampaign);
|
|
822
712
|
}
|
|
823
|
-
/**
|
|
824
|
-
* @see https://docs.voucherify.io/reference/validate-promotions-1
|
|
713
|
+
/**
|
|
714
|
+
* @see https://docs.voucherify.io/reference/validate-promotions-1
|
|
825
715
|
*/
|
|
826
|
-
|
|
827
|
-
|
|
828
716
|
validate(body, params) {
|
|
829
|
-
return this.client.post(
|
|
717
|
+
return this.client.post("/promotions/validation", body, params);
|
|
830
718
|
}
|
|
719
|
+
};
|
|
720
|
+
__name(_Promotions, "Promotions");
|
|
721
|
+
var Promotions = _Promotions;
|
|
831
722
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
class
|
|
723
|
+
// src/Customers.ts
|
|
724
|
+
import FormData3 from "form-data";
|
|
725
|
+
var _Customers = class _Customers {
|
|
835
726
|
constructor(client) {
|
|
836
|
-
this.client = void 0;
|
|
837
727
|
this.client = client;
|
|
838
728
|
}
|
|
839
|
-
/**
|
|
840
|
-
* @see https://docs.voucherify.io/reference/create-customer
|
|
729
|
+
/**
|
|
730
|
+
* @see https://docs.voucherify.io/reference/create-customer
|
|
841
731
|
*/
|
|
842
|
-
|
|
843
|
-
|
|
844
732
|
create(customer) {
|
|
845
|
-
return this.client.post(
|
|
733
|
+
return this.client.post("/customers", customer);
|
|
846
734
|
}
|
|
847
|
-
/**
|
|
848
|
-
* @see https://docs.voucherify.io/reference/read-customer
|
|
735
|
+
/**
|
|
736
|
+
* @see https://docs.voucherify.io/reference/read-customer
|
|
849
737
|
*/
|
|
850
|
-
|
|
851
|
-
|
|
852
738
|
get(customerId) {
|
|
853
739
|
return this.client.get(`/customers/${encode(customerId)}`);
|
|
854
740
|
}
|
|
855
|
-
/**
|
|
856
|
-
* @see https://docs.voucherify.io/reference/list-customers
|
|
741
|
+
/**
|
|
742
|
+
* @see https://docs.voucherify.io/reference/list-customers
|
|
857
743
|
*/
|
|
858
|
-
|
|
859
|
-
|
|
860
744
|
list(params) {
|
|
861
|
-
return this.client.get(
|
|
862
|
-
}
|
|
863
|
-
/**
|
|
864
|
-
* Standard list customers API has limitation of available pages to be shown equal to 100. To cover cases when you would like to fetch more, you must use scroll capabilities.
|
|
865
|
-
*
|
|
866
|
-
* ```javascript
|
|
867
|
-
* async function () {
|
|
868
|
-
* for await (const customer of voucherify.customers.scroll(params)) {
|
|
869
|
-
* console.log('Customer', customer)
|
|
870
|
-
* }
|
|
871
|
-
* }
|
|
872
|
-
* ```
|
|
745
|
+
return this.client.get("/customers", params);
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Standard list customers API has limitation of available pages to be shown equal to 100. To cover cases when you would like to fetch more, you must use scroll capabilities.
|
|
749
|
+
*
|
|
750
|
+
* ```javascript
|
|
751
|
+
* async function () {
|
|
752
|
+
* for await (const customer of voucherify.customers.scroll(params)) {
|
|
753
|
+
* console.log('Customer', customer)
|
|
754
|
+
* }
|
|
755
|
+
* }
|
|
756
|
+
* ```
|
|
873
757
|
*/
|
|
874
|
-
|
|
875
|
-
|
|
876
758
|
async *scroll(params) {
|
|
877
|
-
var
|
|
878
|
-
|
|
879
|
-
let
|
|
880
|
-
|
|
881
|
-
starting_after: startingAfter
|
|
882
|
-
|
|
883
|
-
|
|
759
|
+
var _a;
|
|
760
|
+
let startingAfter = (_a = params.starting_after) != null ? _a : params.order === "created_at" ? "1970-01-01T00:00:00Z" : "2200-01-01T00:00:00Z";
|
|
761
|
+
let response = await this.client.get(
|
|
762
|
+
"/customers",
|
|
763
|
+
Object.assign({}, params, { starting_after: startingAfter })
|
|
764
|
+
);
|
|
884
765
|
while (true) {
|
|
885
766
|
if (response.customers.length === 0) break;
|
|
886
|
-
|
|
887
767
|
for (const customer of response.customers) {
|
|
888
|
-
if (params.order ===
|
|
768
|
+
if (params.order === "created_at") {
|
|
889
769
|
startingAfter = startingAfter > customer.created_at ? startingAfter : customer.created_at;
|
|
890
770
|
} else {
|
|
891
771
|
startingAfter = startingAfter < customer.created_at ? startingAfter : customer.created_at;
|
|
892
772
|
}
|
|
893
|
-
|
|
894
773
|
yield customer;
|
|
895
774
|
}
|
|
896
|
-
|
|
897
775
|
if (!response.has_more) break;
|
|
898
|
-
response = await this.client.get(
|
|
899
|
-
starting_after: startingAfter
|
|
900
|
-
}));
|
|
776
|
+
response = await this.client.get("/customers", Object.assign({}, params, { starting_after: startingAfter }));
|
|
901
777
|
}
|
|
902
778
|
}
|
|
903
|
-
/**
|
|
904
|
-
* @see https://docs.voucherify.io/reference/update-customer
|
|
779
|
+
/**
|
|
780
|
+
* @see https://docs.voucherify.io/reference/update-customer
|
|
905
781
|
*/
|
|
906
|
-
|
|
907
|
-
|
|
908
782
|
update(customer) {
|
|
909
|
-
const id =
|
|
910
|
-
const customerWithoutId = omit(customer, [
|
|
783
|
+
const id = "id" in customer ? customer.id : customer.source_id;
|
|
784
|
+
const customerWithoutId = omit(customer, ["id"]);
|
|
911
785
|
return this.client.put(`/customers/${encode(id)}`, customerWithoutId);
|
|
912
786
|
}
|
|
913
|
-
/**
|
|
914
|
-
* @see https://docs.voucherify.io/reference/update-customers-in-bulk
|
|
787
|
+
/**
|
|
788
|
+
* @see https://docs.voucherify.io/reference/update-customers-in-bulk
|
|
915
789
|
*/
|
|
916
|
-
|
|
917
|
-
|
|
918
790
|
updateInBulk(customers) {
|
|
919
791
|
return this.client.post(`/customers/bulk/async`, customers);
|
|
920
792
|
}
|
|
921
|
-
/**
|
|
922
|
-
* @see https://docs.voucherify.io/reference/update-customers-metadata-in-bulk
|
|
793
|
+
/**
|
|
794
|
+
* @see https://docs.voucherify.io/reference/update-customers-metadata-in-bulk
|
|
923
795
|
*/
|
|
924
|
-
|
|
925
|
-
|
|
926
796
|
updateMetadataInBulk(sourceIdsAndMetadata) {
|
|
927
797
|
return this.client.post(`/customers/metadata/async`, sourceIdsAndMetadata);
|
|
928
798
|
}
|
|
929
|
-
/**
|
|
930
|
-
* @see https://docs.voucherify.io/reference/delete-customer
|
|
799
|
+
/**
|
|
800
|
+
* @see https://docs.voucherify.io/reference/delete-customer
|
|
931
801
|
*/
|
|
932
|
-
|
|
933
|
-
|
|
934
802
|
delete(customerId) {
|
|
935
803
|
return this.client.delete(`/customers/${encode(customerId)}`);
|
|
936
804
|
}
|
|
937
|
-
/**
|
|
938
|
-
* @see https://docs.voucherify.io/reference/delete-customer-permanently
|
|
805
|
+
/**
|
|
806
|
+
* @see https://docs.voucherify.io/reference/delete-customer-permanently
|
|
939
807
|
*/
|
|
940
|
-
|
|
941
|
-
|
|
942
808
|
deletePermanently(customerId) {
|
|
943
|
-
return this.client.post(
|
|
809
|
+
return this.client.post(
|
|
810
|
+
`/customers/${encode(customerId)}/permanent-deletion`,
|
|
811
|
+
{}
|
|
812
|
+
);
|
|
944
813
|
}
|
|
945
|
-
/**
|
|
946
|
-
* @see https://docs.voucherify.io/reference/list-customer-activity
|
|
814
|
+
/**
|
|
815
|
+
* @see https://docs.voucherify.io/reference/list-customer-activity
|
|
947
816
|
*/
|
|
948
|
-
|
|
949
|
-
|
|
950
817
|
listActivity(customerIdOrSourceId, params) {
|
|
951
|
-
return this.client.get(
|
|
818
|
+
return this.client.get(
|
|
819
|
+
`/customers/${encode(customerIdOrSourceId)}/activity`,
|
|
820
|
+
params
|
|
821
|
+
);
|
|
952
822
|
}
|
|
953
|
-
/**
|
|
954
|
-
* @deprecated This method is deprecated. We’re removing this method in next major version.
|
|
823
|
+
/**
|
|
824
|
+
* @deprecated This method is deprecated. We’re removing this method in next major version.
|
|
955
825
|
*/
|
|
956
|
-
|
|
957
|
-
|
|
958
826
|
updateConsents(idOrSourceId, consents) {
|
|
959
827
|
return this.client.put(`/customers/${encode(idOrSourceId)}/consents`, consents);
|
|
960
828
|
}
|
|
961
|
-
/**
|
|
962
|
-
* @deprecated This method is deprecated in favor of the `listActivity` method. We’re removing this method in next major version.
|
|
829
|
+
/**
|
|
830
|
+
* @deprecated This method is deprecated in favor of the `listActivity` method. We’re removing this method in next major version.
|
|
963
831
|
*/
|
|
964
|
-
|
|
965
|
-
|
|
966
832
|
listActivities(customerId, params) {
|
|
967
833
|
return this.client.get(`/customers/${encode(customerId)}/activities`, params);
|
|
968
834
|
}
|
|
969
|
-
/**
|
|
970
|
-
* @see https://docs.voucherify.io/reference/import-customers-using-csv
|
|
835
|
+
/**
|
|
836
|
+
* @see https://docs.voucherify.io/reference/import-customers-using-csv
|
|
971
837
|
*/
|
|
972
|
-
|
|
973
|
-
|
|
974
838
|
async importCSV(filePath) {
|
|
975
|
-
assert(
|
|
976
|
-
|
|
839
|
+
assert(
|
|
840
|
+
environment().startsWith("Node"),
|
|
841
|
+
`Method "client.customers.importCSV(filePath)" is only for Node environment`
|
|
842
|
+
);
|
|
843
|
+
const fs = (await import("fs")).default;
|
|
977
844
|
const fileStream = fs.createReadStream(filePath);
|
|
978
|
-
const form = new
|
|
979
|
-
form.append(
|
|
980
|
-
const headers = {
|
|
981
|
-
|
|
982
|
-
};
|
|
983
|
-
return this.client.post(`/customers/importCSV`, form, undefined, headers);
|
|
845
|
+
const form = new FormData3();
|
|
846
|
+
form.append("file", fileStream);
|
|
847
|
+
const headers = { "Content-Type": "multipart/form-data" };
|
|
848
|
+
return this.client.post(`/customers/importCSV`, form, void 0, headers);
|
|
984
849
|
}
|
|
985
|
-
/**
|
|
986
|
-
* @see https://docs.voucherify.io/reference/list-customer-redeemables
|
|
850
|
+
/**
|
|
851
|
+
* @see https://docs.voucherify.io/reference/list-customer-redeemables
|
|
987
852
|
*/
|
|
988
|
-
|
|
989
|
-
|
|
990
853
|
listRedeemables(id, params) {
|
|
991
854
|
return this.client.get(`/customers/${encode(id)}/redeemables`, params);
|
|
992
855
|
}
|
|
856
|
+
};
|
|
857
|
+
__name(_Customers, "Customers");
|
|
858
|
+
var Customers = _Customers;
|
|
993
859
|
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
class Consents {
|
|
860
|
+
// src/Consents.ts
|
|
861
|
+
var _Consents = class _Consents {
|
|
997
862
|
constructor(client) {
|
|
998
|
-
this.client = void 0;
|
|
999
863
|
this.client = client;
|
|
1000
864
|
}
|
|
1001
|
-
/**
|
|
1002
|
-
* @deprecated This method is deprecated. We’re removing this method in next major version.
|
|
865
|
+
/**
|
|
866
|
+
* @deprecated This method is deprecated. We’re removing this method in next major version.
|
|
1003
867
|
*/
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
868
|
list() {
|
|
1007
|
-
return this.client.get(
|
|
869
|
+
return this.client.get("/consents");
|
|
1008
870
|
}
|
|
871
|
+
};
|
|
872
|
+
__name(_Consents, "Consents");
|
|
873
|
+
var Consents = _Consents;
|
|
1009
874
|
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
class Orders {
|
|
875
|
+
// src/Orders.ts
|
|
876
|
+
var _Orders = class _Orders {
|
|
1013
877
|
constructor(client) {
|
|
1014
|
-
this.client = void 0;
|
|
1015
878
|
this.client = client;
|
|
1016
879
|
}
|
|
1017
|
-
/**
|
|
1018
|
-
* @see https://docs.voucherify.io/reference/create-order
|
|
880
|
+
/**
|
|
881
|
+
* @see https://docs.voucherify.io/reference/create-order
|
|
1019
882
|
*/
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
883
|
create(order) {
|
|
1023
|
-
return this.client.post(
|
|
884
|
+
return this.client.post("/orders", order);
|
|
1024
885
|
}
|
|
1025
|
-
/**
|
|
1026
|
-
* @see https://docs.voucherify.io/reference/get-order
|
|
886
|
+
/**
|
|
887
|
+
* @see https://docs.voucherify.io/reference/get-order
|
|
1027
888
|
*/
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
889
|
get(orderId) {
|
|
1031
890
|
return this.client.get(`/orders/${encode(orderId)}`);
|
|
1032
891
|
}
|
|
1033
|
-
/**
|
|
1034
|
-
* @see https://docs.voucherify.io/reference/update-order
|
|
892
|
+
/**
|
|
893
|
+
* @see https://docs.voucherify.io/reference/update-order
|
|
1035
894
|
*/
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
895
|
update(order) {
|
|
1039
|
-
return this.client.put(
|
|
896
|
+
return this.client.put(
|
|
897
|
+
`/orders/${encode(order.id || order.source_id)}`,
|
|
898
|
+
omit(order, ["id"])
|
|
899
|
+
);
|
|
1040
900
|
}
|
|
1041
|
-
/**
|
|
1042
|
-
* @see https://docs.voucherify.io/reference/list-orders
|
|
901
|
+
/**
|
|
902
|
+
* @see https://docs.voucherify.io/reference/list-orders
|
|
1043
903
|
*/
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
904
|
list(params = {}) {
|
|
1047
|
-
return this.client.get(
|
|
905
|
+
return this.client.get("/orders", params);
|
|
1048
906
|
}
|
|
1049
|
-
/**
|
|
1050
|
-
* @see https://docs.voucherify.io/reference/import-orders
|
|
907
|
+
/**
|
|
908
|
+
* @see https://docs.voucherify.io/reference/import-orders
|
|
1051
909
|
*/
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
910
|
import(orders) {
|
|
1055
|
-
return this.client.post(
|
|
911
|
+
return this.client.post("/orders/import", orders);
|
|
1056
912
|
}
|
|
913
|
+
};
|
|
914
|
+
__name(_Orders, "Orders");
|
|
915
|
+
var Orders = _Orders;
|
|
1057
916
|
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
class
|
|
917
|
+
// src/Products.ts
|
|
918
|
+
import FormData4 from "form-data";
|
|
919
|
+
var _Products = class _Products {
|
|
1061
920
|
constructor(client) {
|
|
1062
|
-
this.client = void 0;
|
|
1063
921
|
this.client = client;
|
|
1064
922
|
}
|
|
1065
|
-
/**
|
|
1066
|
-
* @see https://docs.voucherify.io/reference/create-product
|
|
923
|
+
/**
|
|
924
|
+
* @see https://docs.voucherify.io/reference/create-product
|
|
1067
925
|
*/
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
926
|
create(product) {
|
|
1071
|
-
return this.client.post(
|
|
927
|
+
return this.client.post("/products", product);
|
|
1072
928
|
}
|
|
1073
|
-
/**
|
|
1074
|
-
* @see https://docs.voucherify.io/reference/get-product
|
|
929
|
+
/**
|
|
930
|
+
* @see https://docs.voucherify.io/reference/get-product
|
|
1075
931
|
*/
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
932
|
get(productId) {
|
|
1079
933
|
return this.client.get(`/products/${encode(productId)}`);
|
|
1080
934
|
}
|
|
1081
|
-
/**
|
|
1082
|
-
* @see https://docs.voucherify.io/reference/update-product
|
|
935
|
+
/**
|
|
936
|
+
* @see https://docs.voucherify.io/reference/update-product
|
|
1083
937
|
*/
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
938
|
update(product) {
|
|
1087
|
-
return this.client.put(
|
|
939
|
+
return this.client.put(
|
|
940
|
+
`/products/${encode(product.id || product.source_id)}`,
|
|
941
|
+
omit(product, ["id"])
|
|
942
|
+
);
|
|
1088
943
|
}
|
|
1089
|
-
/**
|
|
1090
|
-
* @see https://docs.voucherify.io/reference/async-update-products-metadata-in-bulk
|
|
944
|
+
/**
|
|
945
|
+
* @see https://docs.voucherify.io/reference/async-update-products-metadata-in-bulk
|
|
1091
946
|
*/
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
947
|
bulkUpdateMetadata(products) {
|
|
1095
|
-
return this.client.post(
|
|
948
|
+
return this.client.post("/products/metadata/async", products);
|
|
1096
949
|
}
|
|
1097
|
-
/**
|
|
1098
|
-
* @see https://docs.voucherify.io/reference/post-products-in-bulk
|
|
950
|
+
/**
|
|
951
|
+
* @see https://docs.voucherify.io/reference/post-products-in-bulk
|
|
1099
952
|
*/
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
953
|
bulkUpdate(products) {
|
|
1103
|
-
return this.client.post(
|
|
954
|
+
return this.client.post("/products/bulk/async", products);
|
|
1104
955
|
}
|
|
1105
|
-
/**
|
|
1106
|
-
* @see https://docs.voucherify.io/reference/delete-product
|
|
956
|
+
/**
|
|
957
|
+
* @see https://docs.voucherify.io/reference/delete-product
|
|
1107
958
|
*/
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
959
|
delete(productId, params) {
|
|
1111
960
|
return this.client.delete(`/products/${encode(productId)}`, params);
|
|
1112
961
|
}
|
|
1113
|
-
/**
|
|
1114
|
-
* @see https://docs.voucherify.io/reference/list-products
|
|
962
|
+
/**
|
|
963
|
+
* @see https://docs.voucherify.io/reference/list-products
|
|
1115
964
|
*/
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
965
|
list(params) {
|
|
1119
|
-
return this.client.get(
|
|
966
|
+
return this.client.get("/products", params);
|
|
1120
967
|
}
|
|
1121
|
-
/**
|
|
1122
|
-
* @see https://docs.voucherify.io/reference/create-sku
|
|
968
|
+
/**
|
|
969
|
+
* @see https://docs.voucherify.io/reference/create-sku
|
|
1123
970
|
*/
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
971
|
createSku(productId, sku) {
|
|
1127
972
|
return this.client.post(`/products/${encode(productId)}/skus`, sku);
|
|
1128
973
|
}
|
|
1129
|
-
/**
|
|
1130
|
-
* @see https://docs.voucherify.io/reference/get-sku-v20210726
|
|
974
|
+
/**
|
|
975
|
+
* @see https://docs.voucherify.io/reference/get-sku-v20210726
|
|
1131
976
|
*/
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
977
|
getSku(skuId) {
|
|
1135
978
|
return this.client.get(`/skus/${encode(skuId)}`);
|
|
1136
979
|
}
|
|
1137
|
-
/**
|
|
1138
|
-
* @see https://docs.voucherify.io/reference/update-sku
|
|
980
|
+
/**
|
|
981
|
+
* @see https://docs.voucherify.io/reference/update-sku
|
|
1139
982
|
*/
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
983
|
updateSku(productId, sku) {
|
|
1143
|
-
return this.client.put(
|
|
984
|
+
return this.client.put(
|
|
985
|
+
`/products/${encode(productId)}/skus/${encode(sku.id || sku.source_id)}`,
|
|
986
|
+
omit(sku, ["id"])
|
|
987
|
+
);
|
|
1144
988
|
}
|
|
1145
|
-
/**
|
|
1146
|
-
* @see https://docs.voucherify.io/reference/delete-sku
|
|
989
|
+
/**
|
|
990
|
+
* @see https://docs.voucherify.io/reference/delete-sku
|
|
1147
991
|
*/
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
992
|
deleteSku(productId, skuId, params) {
|
|
1151
993
|
return this.client.delete(`/products/${encode(productId)}/skus/${encode(skuId)}`, params);
|
|
1152
994
|
}
|
|
1153
|
-
/**
|
|
1154
|
-
* @see https://docs.voucherify.io/reference/list-skus
|
|
995
|
+
/**
|
|
996
|
+
* @see https://docs.voucherify.io/reference/list-skus
|
|
1155
997
|
*/
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
998
|
listSkus(productId) {
|
|
1159
999
|
return this.client.get(`/products/${encode(productId)}/skus`);
|
|
1160
1000
|
}
|
|
1161
|
-
/**
|
|
1162
|
-
* @see https://docs.voucherify.io/reference/import-skus-using-csv
|
|
1001
|
+
/**
|
|
1002
|
+
* @see https://docs.voucherify.io/reference/import-skus-using-csv
|
|
1163
1003
|
*/
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
1004
|
async importSkusCSV(filePath) {
|
|
1167
|
-
assert(
|
|
1168
|
-
|
|
1005
|
+
assert(
|
|
1006
|
+
environment().startsWith("Node"),
|
|
1007
|
+
`Method "client.products.importSkusCSV(filePath)" is only for Node environment`
|
|
1008
|
+
);
|
|
1009
|
+
const fs = (await import("fs")).default;
|
|
1169
1010
|
const fileStream = fs.createReadStream(filePath);
|
|
1170
|
-
const form = new
|
|
1171
|
-
form.append(
|
|
1172
|
-
const headers = {
|
|
1173
|
-
|
|
1174
|
-
};
|
|
1175
|
-
return this.client.post(`/skus/importCSV`, form, undefined, headers);
|
|
1011
|
+
const form = new FormData4();
|
|
1012
|
+
form.append("file", fileStream);
|
|
1013
|
+
const headers = { "Content-Type": "multipart/form-data" };
|
|
1014
|
+
return this.client.post(`/skus/importCSV`, form, void 0, headers);
|
|
1176
1015
|
}
|
|
1177
|
-
/**
|
|
1178
|
-
* @see https://docs.voucherify.io/reference/import-products-using-csv
|
|
1016
|
+
/**
|
|
1017
|
+
* @see https://docs.voucherify.io/reference/import-products-using-csv
|
|
1179
1018
|
*/
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
1019
|
async importCSV(filePath) {
|
|
1183
|
-
assert(
|
|
1184
|
-
|
|
1020
|
+
assert(
|
|
1021
|
+
environment().startsWith("Node"),
|
|
1022
|
+
`Method "client.products.importCSV(filePath)" is only for Node environment`
|
|
1023
|
+
);
|
|
1024
|
+
const fs = (await import("fs")).default;
|
|
1185
1025
|
const fileStream = fs.createReadStream(filePath);
|
|
1186
|
-
const form = new
|
|
1187
|
-
form.append(
|
|
1188
|
-
const headers = {
|
|
1189
|
-
|
|
1190
|
-
};
|
|
1191
|
-
return this.client.post(`/products/importCSV`, form, undefined, headers);
|
|
1026
|
+
const form = new FormData4();
|
|
1027
|
+
form.append("file", fileStream);
|
|
1028
|
+
const headers = { "Content-Type": "multipart/form-data" };
|
|
1029
|
+
return this.client.post(`/products/importCSV`, form, void 0, headers);
|
|
1192
1030
|
}
|
|
1031
|
+
};
|
|
1032
|
+
__name(_Products, "Products");
|
|
1033
|
+
var Products = _Products;
|
|
1193
1034
|
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
class Rewards {
|
|
1035
|
+
// src/Rewards.ts
|
|
1036
|
+
var _Rewards = class _Rewards {
|
|
1197
1037
|
constructor(client) {
|
|
1198
|
-
this.client = void 0;
|
|
1199
1038
|
this.client = client;
|
|
1200
1039
|
}
|
|
1201
|
-
/**
|
|
1202
|
-
* @see https://docs.voucherify.io/reference/list-rewards
|
|
1040
|
+
/**
|
|
1041
|
+
* @see https://docs.voucherify.io/reference/list-rewards
|
|
1203
1042
|
*/
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
1043
|
list(params = {}) {
|
|
1207
|
-
return this.client.get(
|
|
1044
|
+
return this.client.get("/rewards", params);
|
|
1208
1045
|
}
|
|
1209
|
-
/**
|
|
1210
|
-
* @see https://docs.voucherify.io/reference/create-reward
|
|
1046
|
+
/**
|
|
1047
|
+
* @see https://docs.voucherify.io/reference/create-reward
|
|
1211
1048
|
*/
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
1049
|
create(reward) {
|
|
1215
|
-
return this.client.post(
|
|
1050
|
+
return this.client.post("/rewards", reward);
|
|
1216
1051
|
}
|
|
1217
|
-
/**
|
|
1218
|
-
* @see https://docs.voucherify.io/reference/get-reward
|
|
1052
|
+
/**
|
|
1053
|
+
* @see https://docs.voucherify.io/reference/get-reward
|
|
1219
1054
|
*/
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
1055
|
get(rewardId) {
|
|
1223
1056
|
return this.client.get(`/rewards/${encode(rewardId)}`);
|
|
1224
1057
|
}
|
|
1225
|
-
/**
|
|
1226
|
-
* @see https://docs.voucherify.io/reference/update-reward
|
|
1058
|
+
/**
|
|
1059
|
+
* @see https://docs.voucherify.io/reference/update-reward
|
|
1227
1060
|
*/
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
1061
|
update(reward) {
|
|
1231
|
-
return this.client.put(`/rewards/${encode(reward.id)}`, omit(reward, [
|
|
1062
|
+
return this.client.put(`/rewards/${encode(reward.id)}`, omit(reward, ["id"]));
|
|
1232
1063
|
}
|
|
1233
|
-
/**
|
|
1234
|
-
* @see https://docs.voucherify.io/reference/delete-reward
|
|
1064
|
+
/**
|
|
1065
|
+
* @see https://docs.voucherify.io/reference/delete-reward
|
|
1235
1066
|
*/
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
1067
|
delete(rewardId) {
|
|
1239
1068
|
return this.client.delete(`/rewards/${encode(rewardId)}`);
|
|
1240
1069
|
}
|
|
1241
|
-
/**
|
|
1242
|
-
* @see https://docs.voucherify.io/reference/get-reward-assignment
|
|
1070
|
+
/**
|
|
1071
|
+
* @see https://docs.voucherify.io/reference/get-reward-assignment
|
|
1243
1072
|
*/
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
1073
|
getAssignment(rewardId, assignmentId) {
|
|
1247
|
-
return this.client.get(
|
|
1074
|
+
return this.client.get(
|
|
1075
|
+
`/rewards/${encode(rewardId)}/assignments/${encode(assignmentId)}`
|
|
1076
|
+
);
|
|
1248
1077
|
}
|
|
1249
|
-
/**
|
|
1250
|
-
* @see https://docs.voucherify.io/reference/list-reward-assignments
|
|
1078
|
+
/**
|
|
1079
|
+
* @see https://docs.voucherify.io/reference/list-reward-assignments
|
|
1251
1080
|
*/
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
1081
|
listAssignments(rewardId, params = {}) {
|
|
1255
1082
|
return this.client.get(`/rewards/${encode(rewardId)}/assignments`, params);
|
|
1256
1083
|
}
|
|
1257
|
-
/**
|
|
1258
|
-
* @see https://docs.voucherify.io/reference/create-reward-assignment
|
|
1084
|
+
/**
|
|
1085
|
+
* @see https://docs.voucherify.io/reference/create-reward-assignment
|
|
1259
1086
|
*/
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
1087
|
createAssignment(rewardId, assignment) {
|
|
1263
|
-
return this.client.post(
|
|
1088
|
+
return this.client.post(
|
|
1089
|
+
`/rewards/${encode(rewardId)}/assignments`,
|
|
1090
|
+
assignment
|
|
1091
|
+
);
|
|
1264
1092
|
}
|
|
1265
|
-
/**
|
|
1266
|
-
* @see https://docs.voucherify.io/reference/update-reward-assignment
|
|
1093
|
+
/**
|
|
1094
|
+
* @see https://docs.voucherify.io/reference/update-reward-assignment
|
|
1267
1095
|
*/
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
1096
|
updateAssignment(rewardId, assignment) {
|
|
1271
|
-
return this.client.put(
|
|
1097
|
+
return this.client.put(
|
|
1098
|
+
`/rewards/${encode(rewardId)}/assignments/${encode(assignment.id)}`,
|
|
1099
|
+
omit(assignment, ["id"])
|
|
1100
|
+
);
|
|
1272
1101
|
}
|
|
1273
|
-
|
|
1274
1102
|
deleteAssignment(rewardId, assignmentId) {
|
|
1275
1103
|
return this.client.delete(`/rewards/${encode(rewardId)}/assignments/${encode(assignmentId)}`);
|
|
1276
1104
|
}
|
|
1105
|
+
};
|
|
1106
|
+
__name(_Rewards, "Rewards");
|
|
1107
|
+
var Rewards = _Rewards;
|
|
1277
1108
|
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
class Loyalties {
|
|
1109
|
+
// src/Loyalties.ts
|
|
1110
|
+
var _Loyalties = class _Loyalties {
|
|
1281
1111
|
constructor(client) {
|
|
1282
|
-
this.client = void 0;
|
|
1283
1112
|
this.client = client;
|
|
1284
1113
|
}
|
|
1285
|
-
/**
|
|
1286
|
-
* @see https://docs.voucherify.io/reference/list-loyalty-programs
|
|
1114
|
+
/**
|
|
1115
|
+
* @see https://docs.voucherify.io/reference/list-loyalty-programs
|
|
1287
1116
|
*/
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
1117
|
list(params = {}) {
|
|
1291
|
-
return this.client.get(
|
|
1118
|
+
return this.client.get("/loyalties", params);
|
|
1292
1119
|
}
|
|
1293
|
-
/**
|
|
1294
|
-
* @see https://docs.voucherify.io/reference/create-loyalty-program
|
|
1120
|
+
/**
|
|
1121
|
+
* @see https://docs.voucherify.io/reference/create-loyalty-program
|
|
1295
1122
|
*/
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
1123
|
create(campaign) {
|
|
1299
|
-
return this.client.post(
|
|
1124
|
+
return this.client.post("/loyalties", campaign);
|
|
1300
1125
|
}
|
|
1301
|
-
/**
|
|
1302
|
-
* @see https://docs.voucherify.io/reference/get-loyalty-program
|
|
1126
|
+
/**
|
|
1127
|
+
* @see https://docs.voucherify.io/reference/get-loyalty-program
|
|
1303
1128
|
*/
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
1129
|
get(campaignId) {
|
|
1307
1130
|
return this.client.get(`/loyalties/${encode(campaignId)}`);
|
|
1308
1131
|
}
|
|
1309
|
-
/**
|
|
1310
|
-
* @see https://docs.voucherify.io/reference/update-loyalty-program
|
|
1132
|
+
/**
|
|
1133
|
+
* @see https://docs.voucherify.io/reference/update-loyalty-program
|
|
1311
1134
|
*/
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
1135
|
update(campaign) {
|
|
1315
|
-
return this.client.put(
|
|
1136
|
+
return this.client.put(
|
|
1137
|
+
`/loyalties/${encode(campaign.id)}`,
|
|
1138
|
+
omit(campaign, ["id"])
|
|
1139
|
+
);
|
|
1316
1140
|
}
|
|
1317
|
-
/**
|
|
1318
|
-
* @see https://docs.voucherify.io/reference/delete-loyalty-program
|
|
1141
|
+
/**
|
|
1142
|
+
* @see https://docs.voucherify.io/reference/delete-loyalty-program
|
|
1319
1143
|
*/
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
1144
|
delete(campaignId, params) {
|
|
1323
1145
|
return this.client.delete(`/loyalties/${encode(campaignId)}`, params);
|
|
1324
1146
|
}
|
|
1325
|
-
/**
|
|
1326
|
-
* @see https://docs.voucherify.io/reference/list-reward-assignments-1
|
|
1147
|
+
/**
|
|
1148
|
+
* @see https://docs.voucherify.io/reference/list-reward-assignments-1
|
|
1327
1149
|
*/
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
1150
|
listRewardAssignments(campaignId, params = {}) {
|
|
1331
1151
|
return this.client.get(`/loyalties/${encode(campaignId)}/rewards`, params);
|
|
1332
1152
|
}
|
|
1333
|
-
/**
|
|
1334
|
-
* @see https://docs.voucherify.io/reference/create-reward-assignment-1
|
|
1153
|
+
/**
|
|
1154
|
+
* @see https://docs.voucherify.io/reference/create-reward-assignment-1
|
|
1335
1155
|
*/
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
1156
|
createRewardAssignments(campaignId, assignment) {
|
|
1339
|
-
return this.client.post(
|
|
1157
|
+
return this.client.post(
|
|
1158
|
+
`/loyalties/${encode(campaignId)}/rewards`,
|
|
1159
|
+
assignment
|
|
1160
|
+
);
|
|
1340
1161
|
}
|
|
1341
|
-
/**
|
|
1342
|
-
* @see https://docs.voucherify.io/reference/update-reward-assignment-1
|
|
1162
|
+
/**
|
|
1163
|
+
* @see https://docs.voucherify.io/reference/update-reward-assignment-1
|
|
1343
1164
|
*/
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
1165
|
updateRewardAssignment(campaignId, assignment) {
|
|
1347
|
-
return this.client.put(
|
|
1166
|
+
return this.client.put(
|
|
1167
|
+
`/loyalties/${encode(campaignId)}/rewards/${assignment.id}`,
|
|
1168
|
+
omit(assignment, ["id"])
|
|
1169
|
+
);
|
|
1348
1170
|
}
|
|
1349
|
-
/**
|
|
1350
|
-
* @see https://docs.voucherify.io/reference/delete-reward-assignment-1
|
|
1171
|
+
/**
|
|
1172
|
+
* @see https://docs.voucherify.io/reference/delete-reward-assignment-1
|
|
1351
1173
|
*/
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
1174
|
deleteRewardAssignment(campaignId, assignmentId) {
|
|
1355
1175
|
return this.client.delete(`/loyalties/${encode(campaignId)}/rewards/${assignmentId}`);
|
|
1356
1176
|
}
|
|
1357
|
-
/**
|
|
1358
|
-
* @see https://docs.voucherify.io/reference/get-reward-assignment-2
|
|
1177
|
+
/**
|
|
1178
|
+
* @see https://docs.voucherify.io/reference/get-reward-assignment-2
|
|
1359
1179
|
*/
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
1180
|
getRewardAssignment(campaignId, assignmentId) {
|
|
1363
|
-
return this.client.get(
|
|
1181
|
+
return this.client.get(
|
|
1182
|
+
`/loyalties/${encode(campaignId)}/rewards/${encode(assignmentId)}`
|
|
1183
|
+
);
|
|
1364
1184
|
}
|
|
1365
|
-
/**
|
|
1366
|
-
* @see https://docs.voucherify.io/reference/list-earning-rules
|
|
1185
|
+
/**
|
|
1186
|
+
* @see https://docs.voucherify.io/reference/list-earning-rules
|
|
1367
1187
|
*/
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
1188
|
listEarningRules(campaignId, params = {}) {
|
|
1371
|
-
return this.client.get(
|
|
1189
|
+
return this.client.get(
|
|
1190
|
+
`/loyalties/${encode(campaignId)}/earning-rules`,
|
|
1191
|
+
params
|
|
1192
|
+
);
|
|
1372
1193
|
}
|
|
1373
|
-
/**
|
|
1374
|
-
* @see https://docs.voucherify.io/reference/create-earning-rule
|
|
1194
|
+
/**
|
|
1195
|
+
* @see https://docs.voucherify.io/reference/create-earning-rule
|
|
1375
1196
|
*/
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
1197
|
createEarningRule(campaignId, earningRules) {
|
|
1379
|
-
return this.client.post(
|
|
1198
|
+
return this.client.post(
|
|
1199
|
+
`/loyalties/${encode(campaignId)}/earning-rules`,
|
|
1200
|
+
earningRules
|
|
1201
|
+
);
|
|
1380
1202
|
}
|
|
1381
|
-
/**
|
|
1382
|
-
* @see https://docs.voucherify.io/reference/update-earning-rule
|
|
1203
|
+
/**
|
|
1204
|
+
* @see https://docs.voucherify.io/reference/update-earning-rule
|
|
1383
1205
|
*/
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
1206
|
updateEarningRule(campaignId, earningRule) {
|
|
1387
|
-
return this.client.put(
|
|
1207
|
+
return this.client.put(
|
|
1208
|
+
`/loyalties/${encode(campaignId)}/earning-rules/${earningRule.id}`,
|
|
1209
|
+
omit(earningRule, ["id"])
|
|
1210
|
+
);
|
|
1388
1211
|
}
|
|
1389
|
-
/**
|
|
1390
|
-
* @see https://docs.voucherify.io/reference/delete-earning-rule
|
|
1212
|
+
/**
|
|
1213
|
+
* @see https://docs.voucherify.io/reference/delete-earning-rule
|
|
1391
1214
|
*/
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
1215
|
deleteEarningRule(campaignId, earningRuleId) {
|
|
1395
1216
|
return this.client.delete(`/loyalties/${encode(campaignId)}/earning-rules/${earningRuleId}`);
|
|
1396
1217
|
}
|
|
1397
|
-
/**
|
|
1398
|
-
* @see https://docs.voucherify.io/reference/get-earning-rule
|
|
1218
|
+
/**
|
|
1219
|
+
* @see https://docs.voucherify.io/reference/get-earning-rule
|
|
1399
1220
|
*/
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
1221
|
getEarningRule(campaignId, earningRuleId) {
|
|
1403
|
-
return this.client.get(
|
|
1222
|
+
return this.client.get(
|
|
1223
|
+
`/loyalties/${encode(campaignId)}/earning-rules/${encode(earningRuleId)}`
|
|
1224
|
+
);
|
|
1404
1225
|
}
|
|
1405
|
-
/**
|
|
1406
|
-
* @see https://docs.voucherify.io/reference/enable-earning-rule
|
|
1226
|
+
/**
|
|
1227
|
+
* @see https://docs.voucherify.io/reference/enable-earning-rule
|
|
1407
1228
|
*/
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
1229
|
enableEarningRule(campaignId, earningRuleId) {
|
|
1411
|
-
return this.client.post(
|
|
1230
|
+
return this.client.post(
|
|
1231
|
+
`/loyalties/${encode(campaignId)}/earning-rules/${earningRuleId}/enable`,
|
|
1232
|
+
{}
|
|
1233
|
+
);
|
|
1412
1234
|
}
|
|
1413
|
-
/**
|
|
1414
|
-
* @see https://docs.voucherify.io/reference/disable-earning-rule
|
|
1235
|
+
/**
|
|
1236
|
+
* @see https://docs.voucherify.io/reference/disable-earning-rule
|
|
1415
1237
|
*/
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
1238
|
disableEarningRule(campaignId, earningRuleId) {
|
|
1419
|
-
return this.client.post(
|
|
1239
|
+
return this.client.post(
|
|
1240
|
+
`/loyalties/${encode(campaignId)}/earning-rules/${earningRuleId}/disable`,
|
|
1241
|
+
{}
|
|
1242
|
+
);
|
|
1420
1243
|
}
|
|
1421
|
-
/**
|
|
1422
|
-
* @see https://docs.voucherify.io/reference/list-members
|
|
1244
|
+
/**
|
|
1245
|
+
* @see https://docs.voucherify.io/reference/list-members
|
|
1423
1246
|
*/
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
1247
|
listMembers(campaignId, params) {
|
|
1427
1248
|
return this.client.get(`/loyalties/${encode(campaignId)}/members`, params);
|
|
1428
1249
|
}
|
|
1429
|
-
/**
|
|
1430
|
-
* @see https://docs.voucherify.io/reference/create-member
|
|
1250
|
+
/**
|
|
1251
|
+
* @see https://docs.voucherify.io/reference/create-member
|
|
1431
1252
|
*/
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
1253
|
createMember(campaignId, member) {
|
|
1435
1254
|
return this.client.post(`/loyalties/${encode(campaignId)}/members`, member);
|
|
1436
1255
|
}
|
|
1437
|
-
/**
|
|
1438
|
-
* @see https://docs.voucherify.io/reference/get-member
|
|
1439
|
-
* @see https://docs.voucherify.io/reference/get-member-1
|
|
1256
|
+
/**
|
|
1257
|
+
* @see https://docs.voucherify.io/reference/get-member
|
|
1258
|
+
* @see https://docs.voucherify.io/reference/get-member-1
|
|
1440
1259
|
*/
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
1260
|
getMember(campaignId, memberId) {
|
|
1444
|
-
return this.client.get(
|
|
1261
|
+
return this.client.get(
|
|
1262
|
+
campaignId ? `/loyalties/${encode(campaignId)}/members/${memberId}` : `/loyalties/members/${memberId}`
|
|
1263
|
+
);
|
|
1445
1264
|
}
|
|
1446
|
-
/**
|
|
1447
|
-
* @see https://docs.voucherify.io/reference/list-member-activity
|
|
1448
|
-
* @see https://docs.voucherify.io/reference/list-member-activity-1
|
|
1265
|
+
/**
|
|
1266
|
+
* @see https://docs.voucherify.io/reference/list-member-activity
|
|
1267
|
+
* @see https://docs.voucherify.io/reference/list-member-activity-1
|
|
1449
1268
|
*/
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
1269
|
listMemberActivity(campaignId, memberId, params) {
|
|
1453
|
-
return this.client.get(
|
|
1270
|
+
return this.client.get(
|
|
1271
|
+
campaignId ? `/loyalties/${encode(campaignId)}/members/${memberId}/activity` : `/loyalties/members/${memberId}/activity`,
|
|
1272
|
+
params
|
|
1273
|
+
);
|
|
1454
1274
|
}
|
|
1455
|
-
/**
|
|
1456
|
-
* @deprecated This method is deprecated in favor of the `listMemberActivity` method. We’re removing this method in next major version.
|
|
1275
|
+
/**
|
|
1276
|
+
* @deprecated This method is deprecated in favor of the `listMemberActivity` method. We’re removing this method in next major version.
|
|
1457
1277
|
*/
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
1278
|
getMemberActivities(campaignId, memberId) {
|
|
1461
|
-
return this.client.get(
|
|
1279
|
+
return this.client.get(
|
|
1280
|
+
campaignId ? `/loyalties/${encode(campaignId)}/members/${memberId}/activities` : `/loyalties/members/${memberId}/activities`
|
|
1281
|
+
);
|
|
1462
1282
|
}
|
|
1463
|
-
/**
|
|
1464
|
-
* @see https://docs.voucherify.io/reference/list-member-rewards
|
|
1283
|
+
/**
|
|
1284
|
+
* @see https://docs.voucherify.io/reference/list-member-rewards
|
|
1465
1285
|
*/
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
1286
|
listMemberRewards(memberId, params) {
|
|
1469
|
-
return this.client.get(
|
|
1287
|
+
return this.client.get(
|
|
1288
|
+
`/loyalties/members/${encode(memberId)}/rewards`,
|
|
1289
|
+
params
|
|
1290
|
+
);
|
|
1470
1291
|
}
|
|
1471
|
-
/**
|
|
1472
|
-
* @see https://docs.voucherify.io/reference/add-remove-loyalty-card-balance
|
|
1473
|
-
* @see https://docs.voucherify.io/reference/add-remove-loyalty-card-balance-1
|
|
1292
|
+
/**
|
|
1293
|
+
* @see https://docs.voucherify.io/reference/add-remove-loyalty-card-balance
|
|
1294
|
+
* @see https://docs.voucherify.io/reference/add-remove-loyalty-card-balance-1
|
|
1474
1295
|
*/
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
1296
|
addOrRemoveCardBalance(memberId, balance, campaignId) {
|
|
1478
|
-
return this.client.post(
|
|
1297
|
+
return this.client.post(
|
|
1298
|
+
campaignId ? `/loyalties/${encode(campaignId)}/members/${memberId}/balance` : `/loyalties/members/${memberId}/balance`,
|
|
1299
|
+
balance
|
|
1300
|
+
);
|
|
1479
1301
|
}
|
|
1480
|
-
/**
|
|
1481
|
-
* @see https://docs.voucherify.io/reference/add-remove-loyalty-card-balance-1
|
|
1302
|
+
/**
|
|
1303
|
+
* @see https://docs.voucherify.io/reference/add-remove-loyalty-card-balance-1
|
|
1482
1304
|
*/
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
1305
|
addPoints(campaignId, memberId, balance) {
|
|
1486
|
-
return this.client.post(
|
|
1306
|
+
return this.client.post(
|
|
1307
|
+
`/loyalties/${encode(campaignId)}/members/${memberId}/balance`,
|
|
1308
|
+
balance
|
|
1309
|
+
);
|
|
1487
1310
|
}
|
|
1488
|
-
/**
|
|
1489
|
-
* @see https://docs.voucherify.io/reference/transfer-points
|
|
1311
|
+
/**
|
|
1312
|
+
* @see https://docs.voucherify.io/reference/transfer-points
|
|
1490
1313
|
*/
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
1314
|
transferPoints(campaignId, memberId, loyaltiesTransferPoints) {
|
|
1494
|
-
return this.client.post(
|
|
1315
|
+
return this.client.post(
|
|
1316
|
+
`/loyalties/${encode(campaignId)}/members/${encode(memberId)}/transfers`,
|
|
1317
|
+
loyaltiesTransferPoints
|
|
1318
|
+
);
|
|
1495
1319
|
}
|
|
1496
|
-
/**
|
|
1497
|
-
* @see https://docs.voucherify.io/reference/get-points-expiration
|
|
1320
|
+
/**
|
|
1321
|
+
* @see https://docs.voucherify.io/reference/get-points-expiration
|
|
1498
1322
|
*/
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
1323
|
getPointsExpiration(campaignId, memberId, params) {
|
|
1502
|
-
return this.client.get(
|
|
1324
|
+
return this.client.get(
|
|
1325
|
+
`/loyalties/${encode(campaignId)}/members/${memberId}/points-expiration`,
|
|
1326
|
+
params
|
|
1327
|
+
);
|
|
1503
1328
|
}
|
|
1504
|
-
/**
|
|
1505
|
-
* @see https://docs.voucherify.io/reference/redeem-loyalty-card
|
|
1329
|
+
/**
|
|
1330
|
+
* @see https://docs.voucherify.io/reference/redeem-loyalty-card
|
|
1506
1331
|
*/
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
1332
|
redeemReward(campaignId, memberId, params) {
|
|
1510
|
-
return this.client.post(
|
|
1333
|
+
return this.client.post(
|
|
1334
|
+
`/loyalties/${encode(campaignId)}/members/${encode(memberId)}/redemption`,
|
|
1335
|
+
params
|
|
1336
|
+
);
|
|
1511
1337
|
}
|
|
1512
|
-
/**
|
|
1513
|
-
* @see https://docs.voucherify.io/reference/list-loyalty-tier-rewards
|
|
1338
|
+
/**
|
|
1339
|
+
* @see https://docs.voucherify.io/reference/list-loyalty-tier-rewards
|
|
1514
1340
|
*/
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
1341
|
listLoyaltyTierRewards(campaignId, tierId) {
|
|
1518
|
-
return this.client.get(
|
|
1342
|
+
return this.client.get(
|
|
1343
|
+
`/loyalties/${encode(campaignId)}/tiers/${encode(tierId)}/rewards`
|
|
1344
|
+
);
|
|
1519
1345
|
}
|
|
1520
|
-
/**
|
|
1521
|
-
* @see https://docs.voucherify.io/reference/list-loyalty-card-transactions
|
|
1522
|
-
* @see https://docs.voucherify.io/reference/list-loyalty-card-transactions-1
|
|
1346
|
+
/**
|
|
1347
|
+
* @see https://docs.voucherify.io/reference/list-loyalty-card-transactions
|
|
1348
|
+
* @see https://docs.voucherify.io/reference/list-loyalty-card-transactions-1
|
|
1523
1349
|
*/
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
1350
|
listCardTransactions(memberId, campaignId, params) {
|
|
1527
|
-
return this.client.get(
|
|
1351
|
+
return this.client.get(
|
|
1352
|
+
campaignId ? `/loyalties/${encode(campaignId)}/members/${encode(memberId)}/transactions` : `/loyalties/members/${encode(memberId)}/transactions`,
|
|
1353
|
+
params
|
|
1354
|
+
);
|
|
1528
1355
|
}
|
|
1529
|
-
/**
|
|
1530
|
-
* @see https://docs.voucherify.io/reference/export-loyalty-card-transactions
|
|
1531
|
-
* @see https://docs.voucherify.io/reference/export-loyalty-card-transactions-1
|
|
1356
|
+
/**
|
|
1357
|
+
* @see https://docs.voucherify.io/reference/export-loyalty-card-transactions
|
|
1358
|
+
* @see https://docs.voucherify.io/reference/export-loyalty-card-transactions-1
|
|
1532
1359
|
*/
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
1360
|
exportCardTransactions(memberId, campaignId, params = {}) {
|
|
1536
|
-
return this.client.post(
|
|
1361
|
+
return this.client.post(
|
|
1362
|
+
campaignId ? `/loyalties/${encode(campaignId)}/members/${encode(memberId)}/transactions/export` : `/loyalties/members/${encode(memberId)}/transactions/export`,
|
|
1363
|
+
params
|
|
1364
|
+
);
|
|
1537
1365
|
}
|
|
1538
|
-
/**
|
|
1539
|
-
* @see https://docs.voucherify.io/reference/get-reward-details
|
|
1366
|
+
/**
|
|
1367
|
+
* @see https://docs.voucherify.io/reference/get-reward-details
|
|
1540
1368
|
*/
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
1369
|
getRewardDetails(campaignId, assignmentId) {
|
|
1544
|
-
return this.client.get(
|
|
1370
|
+
return this.client.get(
|
|
1371
|
+
`/loyalties/${encode(campaignId)}/reward-assignments/${encode(assignmentId)}/reward`
|
|
1372
|
+
);
|
|
1545
1373
|
}
|
|
1546
|
-
/**
|
|
1547
|
-
* @see https://docs.voucherify.io/reference/list-loyalty-tiers
|
|
1374
|
+
/**
|
|
1375
|
+
* @see https://docs.voucherify.io/reference/list-loyalty-tiers
|
|
1548
1376
|
*/
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
1377
|
listTiers(campaignId, params) {
|
|
1552
1378
|
return this.client.get(`/loyalties/${encode(campaignId)}/tiers`, params);
|
|
1553
1379
|
}
|
|
1554
|
-
/**
|
|
1555
|
-
* @see https://docs.voucherify.io/reference/get-loyalty-tier
|
|
1380
|
+
/**
|
|
1381
|
+
* @see https://docs.voucherify.io/reference/get-loyalty-tier
|
|
1556
1382
|
*/
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
1383
|
getTier(campaignId, tierId) {
|
|
1560
1384
|
return this.client.get(`/loyalties/${encode(campaignId)}/tiers/${encode(tierId)}`);
|
|
1561
1385
|
}
|
|
1562
|
-
/**
|
|
1563
|
-
* @see https://docs.voucherify.io/reference/create-loyalty-tiers
|
|
1386
|
+
/**
|
|
1387
|
+
* @see https://docs.voucherify.io/reference/create-loyalty-tiers
|
|
1564
1388
|
*/
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
1389
|
createTiers(campaignId, tiers) {
|
|
1568
1390
|
return this.client.post(`/loyalties/${encode(campaignId)}/tiers`, tiers);
|
|
1569
1391
|
}
|
|
1570
|
-
/**
|
|
1571
|
-
* @see https://docs.voucherify.io/reference/list-loyalty-tier-earning-rules
|
|
1392
|
+
/**
|
|
1393
|
+
* @see https://docs.voucherify.io/reference/list-loyalty-tier-earning-rules
|
|
1572
1394
|
*/
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
1395
|
listLoyaltyTierEarningRules(campaignId, tierId, params) {
|
|
1576
|
-
return this.client.get(
|
|
1396
|
+
return this.client.get(
|
|
1397
|
+
`/loyalties/${encode(campaignId)}/tiers/${encode(tierId)}/earning-rules`,
|
|
1398
|
+
params
|
|
1399
|
+
);
|
|
1577
1400
|
}
|
|
1578
|
-
/**
|
|
1579
|
-
* @see https://docs.voucherify.io/reference/get-member-loyalty-tier
|
|
1401
|
+
/**
|
|
1402
|
+
* @see https://docs.voucherify.io/reference/get-member-loyalty-tier
|
|
1580
1403
|
*/
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
1404
|
listMemberLoyaltyTiers(memberId) {
|
|
1584
|
-
return this.client.get(
|
|
1405
|
+
return this.client.get(
|
|
1406
|
+
`/loyalties/members/${encode(memberId)}/tiers`
|
|
1407
|
+
);
|
|
1585
1408
|
}
|
|
1409
|
+
};
|
|
1410
|
+
__name(_Loyalties, "Loyalties");
|
|
1411
|
+
var Loyalties = _Loyalties;
|
|
1586
1412
|
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
class ValidationRules {
|
|
1413
|
+
// src/ValidationRules.ts
|
|
1414
|
+
var _ValidationRules = class _ValidationRules {
|
|
1590
1415
|
constructor(client) {
|
|
1591
|
-
this.client = void 0;
|
|
1592
1416
|
this.client = client;
|
|
1593
1417
|
}
|
|
1594
|
-
/**
|
|
1595
|
-
* @see https://docs.voucherify.io/reference/create-validation-rules
|
|
1418
|
+
/**
|
|
1419
|
+
* @see https://docs.voucherify.io/reference/create-validation-rules
|
|
1596
1420
|
*/
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
1421
|
create(validationRule) {
|
|
1600
|
-
return this.client.post(
|
|
1422
|
+
return this.client.post("/validation-rules", validationRule);
|
|
1601
1423
|
}
|
|
1602
|
-
/**
|
|
1603
|
-
* @see https://docs.voucherify.io/reference/get-validation-rules
|
|
1424
|
+
/**
|
|
1425
|
+
* @see https://docs.voucherify.io/reference/get-validation-rules
|
|
1604
1426
|
*/
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
1427
|
get(validationRuleId) {
|
|
1608
1428
|
return this.client.get(`/validation-rules/${encode(validationRuleId)}`);
|
|
1609
1429
|
}
|
|
1610
|
-
/**
|
|
1611
|
-
* @see https://docs.voucherify.io/reference/update-validation-rules
|
|
1430
|
+
/**
|
|
1431
|
+
* @see https://docs.voucherify.io/reference/update-validation-rules
|
|
1612
1432
|
*/
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
1433
|
update(validationRule) {
|
|
1616
|
-
return this.client.put(
|
|
1434
|
+
return this.client.put(
|
|
1435
|
+
`/validation-rules/${encode(validationRule.id)}`,
|
|
1436
|
+
omit(validationRule, ["id"])
|
|
1437
|
+
);
|
|
1617
1438
|
}
|
|
1618
|
-
/**
|
|
1619
|
-
* @see https://docs.voucherify.io/reference/delete-validation-rules
|
|
1439
|
+
/**
|
|
1440
|
+
* @see https://docs.voucherify.io/reference/delete-validation-rules
|
|
1620
1441
|
*/
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
1442
|
delete(validationRuleId) {
|
|
1624
1443
|
return this.client.delete(`/validation-rules/${encode(validationRuleId)}`);
|
|
1625
1444
|
}
|
|
1626
|
-
/**
|
|
1627
|
-
* @see https://docs.voucherify.io/reference/create-validation-rules-assignment
|
|
1445
|
+
/**
|
|
1446
|
+
* @see https://docs.voucherify.io/reference/create-validation-rules-assignment
|
|
1628
1447
|
*/
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
1448
|
createAssignment(validationRuleId, assignment) {
|
|
1632
|
-
return this.client.post(
|
|
1449
|
+
return this.client.post(
|
|
1450
|
+
`/validation-rules/${encode(validationRuleId)}/assignments`,
|
|
1451
|
+
assignment
|
|
1452
|
+
);
|
|
1633
1453
|
}
|
|
1634
|
-
/**
|
|
1635
|
-
* @see https://docs.voucherify.io/reference/delete-validation-rules-assignment
|
|
1454
|
+
/**
|
|
1455
|
+
* @see https://docs.voucherify.io/reference/delete-validation-rules-assignment
|
|
1636
1456
|
*/
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
1457
|
deleteAssignment(validationRuleId, assignmentId) {
|
|
1640
1458
|
return this.client.delete(`/validation-rules/${encode(validationRuleId)}/assignments/${encode(assignmentId)}`);
|
|
1641
1459
|
}
|
|
1642
|
-
|
|
1643
1460
|
validate(validationRuleId, params = {}) {
|
|
1644
|
-
return this.client.post(
|
|
1461
|
+
return this.client.post(
|
|
1462
|
+
`/validation-rules/${encode(validationRuleId)}/validation`,
|
|
1463
|
+
params
|
|
1464
|
+
);
|
|
1645
1465
|
}
|
|
1646
|
-
/**
|
|
1647
|
-
* @see https://docs.voucherify.io/reference/list-validation-rules
|
|
1466
|
+
/**
|
|
1467
|
+
* @see https://docs.voucherify.io/reference/list-validation-rules
|
|
1648
1468
|
*/
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
1469
|
list(params = {}) {
|
|
1652
|
-
return this.client.get(
|
|
1470
|
+
return this.client.get("/validation-rules", params);
|
|
1653
1471
|
}
|
|
1654
|
-
/**
|
|
1655
|
-
* @see https://docs.voucherify.io/reference/list-validation-rules-assignments
|
|
1472
|
+
/**
|
|
1473
|
+
* @see https://docs.voucherify.io/reference/list-validation-rules-assignments
|
|
1656
1474
|
*/
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
1475
|
listRulesAssignments(params = {}) {
|
|
1660
1476
|
return this.client.get(`/validation-rules-assignments`, params);
|
|
1661
1477
|
}
|
|
1662
|
-
/**
|
|
1663
|
-
* @see https://docs.voucherify.io/reference/list-validation-rule-assignments
|
|
1478
|
+
/**
|
|
1479
|
+
* @see https://docs.voucherify.io/reference/list-validation-rule-assignments
|
|
1664
1480
|
*/
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
1481
|
listAssignments(validationRuleId, params = {}) {
|
|
1668
|
-
return this.client.get(
|
|
1482
|
+
return this.client.get(
|
|
1483
|
+
`/validation-rules/${encode(validationRuleId)}/assignments`,
|
|
1484
|
+
params
|
|
1485
|
+
);
|
|
1669
1486
|
}
|
|
1487
|
+
};
|
|
1488
|
+
__name(_ValidationRules, "ValidationRules");
|
|
1489
|
+
var ValidationRules = _ValidationRules;
|
|
1670
1490
|
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
class Segments {
|
|
1491
|
+
// src/Segments.ts
|
|
1492
|
+
var _Segments = class _Segments {
|
|
1674
1493
|
constructor(client) {
|
|
1675
|
-
this.client = void 0;
|
|
1676
1494
|
this.client = client;
|
|
1677
1495
|
}
|
|
1678
|
-
/**
|
|
1679
|
-
* @see https://docs.voucherify.io/reference/create-segment
|
|
1496
|
+
/**
|
|
1497
|
+
* @see https://docs.voucherify.io/reference/create-segment
|
|
1680
1498
|
*/
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
1499
|
create(segment) {
|
|
1684
|
-
return this.client.post(
|
|
1500
|
+
return this.client.post("/segments", segment);
|
|
1685
1501
|
}
|
|
1686
|
-
/**
|
|
1687
|
-
* @see https://docs.voucherify.io/reference/get-segment
|
|
1502
|
+
/**
|
|
1503
|
+
* @see https://docs.voucherify.io/reference/get-segment
|
|
1688
1504
|
*/
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
1505
|
get(segmentId) {
|
|
1692
1506
|
return this.client.get(`/segments/${encode(segmentId)}`);
|
|
1693
1507
|
}
|
|
1694
|
-
/**
|
|
1695
|
-
* @see https://docs.voucherify.io/reference/delete-segment
|
|
1508
|
+
/**
|
|
1509
|
+
* @see https://docs.voucherify.io/reference/delete-segment
|
|
1696
1510
|
*/
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
1511
|
delete(segmentId) {
|
|
1700
1512
|
return this.client.delete(`/segments/${encode(segmentId)}`);
|
|
1701
1513
|
}
|
|
1702
|
-
/**
|
|
1703
|
-
* @see https://docs.voucherify.io/reference/list-segments
|
|
1514
|
+
/**
|
|
1515
|
+
* @see https://docs.voucherify.io/reference/list-segments
|
|
1704
1516
|
*/
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
1517
|
list(customerId) {
|
|
1708
1518
|
return this.client.get(`/customers/${encode(customerId)}/segments`);
|
|
1709
1519
|
}
|
|
1520
|
+
};
|
|
1521
|
+
__name(_Segments, "Segments");
|
|
1522
|
+
var Segments = _Segments;
|
|
1710
1523
|
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
class ApiLimitsHandler {
|
|
1524
|
+
// src/ApiLimitsHandler.ts
|
|
1525
|
+
var _ApiLimitsHandler = class _ApiLimitsHandler {
|
|
1714
1526
|
constructor(requestController) {
|
|
1715
|
-
this.requestController = void 0;
|
|
1716
1527
|
this.requestController = requestController;
|
|
1717
1528
|
}
|
|
1718
|
-
|
|
1719
1529
|
getLastResponseHeadersFromController() {
|
|
1720
1530
|
return this.requestController.getLastResponseHeaders();
|
|
1721
1531
|
}
|
|
1722
|
-
|
|
1723
1532
|
areLimitsAvailable() {
|
|
1724
1533
|
return this.requestController.isLastReponseHeadersSet();
|
|
1725
1534
|
}
|
|
1726
|
-
|
|
1727
1535
|
getRateLimit() {
|
|
1728
|
-
var
|
|
1729
|
-
|
|
1730
|
-
const rateLimit = (_this$getLastResponse = this.getLastResponseHeadersFromController()['x-rate-limit-limit']) != null ? _this$getLastResponse : 0;
|
|
1536
|
+
var _a;
|
|
1537
|
+
const rateLimit = (_a = this.getLastResponseHeadersFromController()["x-rate-limit-limit"]) != null ? _a : 0;
|
|
1731
1538
|
return parseInt(rateLimit, 10);
|
|
1732
1539
|
}
|
|
1733
|
-
|
|
1734
1540
|
getRateLimitRemaining() {
|
|
1735
|
-
var
|
|
1736
|
-
|
|
1737
|
-
const rateLimitRemaining = (_this$getLastResponse2 = this.getLastResponseHeadersFromController()['x-rate-limit-remaining']) != null ? _this$getLastResponse2 : 0;
|
|
1541
|
+
var _a;
|
|
1542
|
+
const rateLimitRemaining = (_a = this.getLastResponseHeadersFromController()["x-rate-limit-remaining"]) != null ? _a : 0;
|
|
1738
1543
|
return parseInt(rateLimitRemaining, 10);
|
|
1739
1544
|
}
|
|
1740
|
-
|
|
1741
1545
|
getRetryAfter() {
|
|
1742
|
-
var
|
|
1743
|
-
|
|
1744
|
-
const retryAfter = (_this$getLastResponse3 = this.getLastResponseHeadersFromController()['retry-after']) != null ? _this$getLastResponse3 : 0;
|
|
1546
|
+
var _a;
|
|
1547
|
+
const retryAfter = (_a = this.getLastResponseHeadersFromController()["retry-after"]) != null ? _a : 0;
|
|
1745
1548
|
return parseInt(retryAfter, 10);
|
|
1746
1549
|
}
|
|
1550
|
+
};
|
|
1551
|
+
__name(_ApiLimitsHandler, "ApiLimitsHandler");
|
|
1552
|
+
var ApiLimitsHandler = _ApiLimitsHandler;
|
|
1747
1553
|
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
class MetadataSchemas {
|
|
1554
|
+
// src/MetadataSchemas.ts
|
|
1555
|
+
var _MetadataSchemas = class _MetadataSchemas {
|
|
1751
1556
|
constructor(client) {
|
|
1752
|
-
this.client = void 0;
|
|
1753
1557
|
this.client = client;
|
|
1754
1558
|
}
|
|
1755
|
-
/**
|
|
1756
|
-
* @see https://docs.voucherify.io/reference/list-metadata-schemas
|
|
1559
|
+
/**
|
|
1560
|
+
* @see https://docs.voucherify.io/reference/list-metadata-schemas
|
|
1757
1561
|
*/
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
1562
|
list() {
|
|
1761
|
-
return this.client.get(
|
|
1563
|
+
return this.client.get("/metadata-schemas");
|
|
1762
1564
|
}
|
|
1763
|
-
/**
|
|
1764
|
-
* @see https://docs.voucherify.io/reference/get-metadata-schema
|
|
1565
|
+
/**
|
|
1566
|
+
* @see https://docs.voucherify.io/reference/get-metadata-schema
|
|
1765
1567
|
*/
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
1568
|
get(schemaName) {
|
|
1769
1569
|
return this.client.get(`/metadata-schemas/${encode(schemaName)}`);
|
|
1770
1570
|
}
|
|
1571
|
+
};
|
|
1572
|
+
__name(_MetadataSchemas, "MetadataSchemas");
|
|
1573
|
+
var MetadataSchemas = _MetadataSchemas;
|
|
1771
1574
|
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
class Categories {
|
|
1575
|
+
// src/Categories.ts
|
|
1576
|
+
var _Categories = class _Categories {
|
|
1775
1577
|
constructor(client) {
|
|
1776
|
-
this.client = void 0;
|
|
1777
1578
|
this.client = client;
|
|
1778
1579
|
}
|
|
1779
|
-
/**
|
|
1780
|
-
* @see https://docs.voucherify.io/reference/list-categories
|
|
1580
|
+
/**
|
|
1581
|
+
* @see https://docs.voucherify.io/reference/list-categories
|
|
1781
1582
|
*/
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
1583
|
list(params = {}) {
|
|
1785
|
-
return this.client.get(
|
|
1584
|
+
return this.client.get("/categories", params);
|
|
1786
1585
|
}
|
|
1787
|
-
/**
|
|
1788
|
-
* @see https://docs.voucherify.io/reference/create-category
|
|
1586
|
+
/**
|
|
1587
|
+
* @see https://docs.voucherify.io/reference/create-category
|
|
1789
1588
|
*/
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
1589
|
create(createCategory) {
|
|
1793
|
-
return this.client.post(
|
|
1590
|
+
return this.client.post("/categories", createCategory);
|
|
1794
1591
|
}
|
|
1795
|
-
/**
|
|
1796
|
-
* @see https://docs.voucherify.io/reference/get-category
|
|
1592
|
+
/**
|
|
1593
|
+
* @see https://docs.voucherify.io/reference/get-category
|
|
1797
1594
|
*/
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
1595
|
get(categoryId) {
|
|
1801
1596
|
return this.client.get(`/categories/${encode(categoryId)}`);
|
|
1802
1597
|
}
|
|
1803
|
-
/**
|
|
1804
|
-
* @see https://docs.voucherify.io/reference/delete-category
|
|
1598
|
+
/**
|
|
1599
|
+
* @see https://docs.voucherify.io/reference/delete-category
|
|
1805
1600
|
*/
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
1601
|
delete(categoryId) {
|
|
1809
1602
|
return this.client.delete(`/categories/${encode(categoryId)}`);
|
|
1810
1603
|
}
|
|
1811
|
-
/**
|
|
1812
|
-
* @see https://docs.voucherify.io/reference/update-category
|
|
1604
|
+
/**
|
|
1605
|
+
* @see https://docs.voucherify.io/reference/update-category
|
|
1813
1606
|
*/
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
1607
|
update(categoryId, updateCategory) {
|
|
1817
1608
|
return this.client.put(`/categories/${encode(categoryId)}`, updateCategory);
|
|
1818
1609
|
}
|
|
1610
|
+
};
|
|
1611
|
+
__name(_Categories, "Categories");
|
|
1612
|
+
var Categories = _Categories;
|
|
1819
1613
|
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
class PromotionsStacks {
|
|
1614
|
+
// src/PromotionsStacks.ts
|
|
1615
|
+
var _PromotionsStacks = class _PromotionsStacks {
|
|
1823
1616
|
constructor(client) {
|
|
1824
|
-
this.client = void 0;
|
|
1825
1617
|
this.client = client;
|
|
1826
1618
|
}
|
|
1827
|
-
/**
|
|
1828
|
-
* @see https://docs.voucherify.io/reference/list-promotion-stacks-in-campaign
|
|
1619
|
+
/**
|
|
1620
|
+
* @see https://docs.voucherify.io/reference/list-promotion-stacks-in-campaign
|
|
1829
1621
|
*/
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
1622
|
listInCampaign(campaignId) {
|
|
1833
1623
|
return this.client.get(`/promotions/${campaignId}/stacks`);
|
|
1834
1624
|
}
|
|
1835
|
-
/**
|
|
1836
|
-
* @see https://docs.voucherify.io/reference/list-promotion-stacks-in-campaign
|
|
1625
|
+
/**
|
|
1626
|
+
* @see https://docs.voucherify.io/reference/list-promotion-stacks-in-campaign
|
|
1837
1627
|
*/
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
1628
|
createInCampaign(campaignId, body) {
|
|
1841
1629
|
return this.client.post(`/promotions/${campaignId}/stacks`, body);
|
|
1842
1630
|
}
|
|
1843
|
-
/**
|
|
1844
|
-
* @see https://docs.voucherify.io/reference/delete-promotion-stack
|
|
1631
|
+
/**
|
|
1632
|
+
* @see https://docs.voucherify.io/reference/delete-promotion-stack
|
|
1845
1633
|
*/
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
1634
|
delete(campaignId, stackId) {
|
|
1849
1635
|
return this.client.delete(`/promotions/${campaignId}/stacks/${stackId}`);
|
|
1850
1636
|
}
|
|
1851
|
-
/**
|
|
1852
|
-
* @see https://docs.voucherify.io/reference/get-promotion-stack
|
|
1637
|
+
/**
|
|
1638
|
+
* @see https://docs.voucherify.io/reference/get-promotion-stack
|
|
1853
1639
|
*/
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
1640
|
get(campaignId, stackId) {
|
|
1857
1641
|
return this.client.get(`/promotions/${campaignId}/stacks/${stackId}`);
|
|
1858
1642
|
}
|
|
1859
|
-
/**
|
|
1860
|
-
* @see https://docs.voucherify.io/reference/update-promotion-stack
|
|
1643
|
+
/**
|
|
1644
|
+
* @see https://docs.voucherify.io/reference/update-promotion-stack
|
|
1861
1645
|
*/
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
1646
|
update(campaignId, stackId, body) {
|
|
1865
1647
|
return this.client.put(`/promotions/${campaignId}/stacks/${stackId}`, body);
|
|
1866
1648
|
}
|
|
1867
|
-
/**
|
|
1868
|
-
* @see https://docs.voucherify.io/reference/list-promotion-stacks-in-campaign
|
|
1649
|
+
/**
|
|
1650
|
+
* @see https://docs.voucherify.io/reference/list-promotion-stacks-in-campaign
|
|
1869
1651
|
*/
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
1652
|
list(params) {
|
|
1873
1653
|
return this.client.get(`/promotions/stacks`, params);
|
|
1874
1654
|
}
|
|
1655
|
+
};
|
|
1656
|
+
__name(_PromotionsStacks, "PromotionsStacks");
|
|
1657
|
+
var PromotionsStacks = _PromotionsStacks;
|
|
1875
1658
|
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
class ProductCollections {
|
|
1659
|
+
// src/ProductCollections.ts
|
|
1660
|
+
var _ProductCollections = class _ProductCollections {
|
|
1879
1661
|
constructor(client) {
|
|
1880
|
-
this.client = void 0;
|
|
1881
1662
|
this.client = client;
|
|
1882
1663
|
}
|
|
1883
|
-
/**
|
|
1884
|
-
* @see https://docs.voucherify.io/reference/create-product-collection
|
|
1664
|
+
/**
|
|
1665
|
+
* @see https://docs.voucherify.io/reference/create-product-collection
|
|
1885
1666
|
*/
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
1667
|
create(productCollection) {
|
|
1889
1668
|
return this.client.post(`/product-collections`, productCollection);
|
|
1890
1669
|
}
|
|
1891
|
-
/**
|
|
1892
|
-
* @see https://docs.voucherify.io/reference/list-product-collections
|
|
1670
|
+
/**
|
|
1671
|
+
* @see https://docs.voucherify.io/reference/list-product-collections
|
|
1893
1672
|
*/
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
1673
|
list(params) {
|
|
1897
1674
|
return this.client.get(`/product-collections`, params);
|
|
1898
1675
|
}
|
|
1899
|
-
/**
|
|
1900
|
-
* @see https://docs.voucherify.io/reference/delete-product-collection
|
|
1676
|
+
/**
|
|
1677
|
+
* @see https://docs.voucherify.io/reference/delete-product-collection
|
|
1901
1678
|
*/
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
1679
|
delete(productCollectionId) {
|
|
1905
1680
|
return this.client.delete(`/product-collections/${encode(productCollectionId)}`);
|
|
1906
1681
|
}
|
|
1907
|
-
/**
|
|
1908
|
-
* @see https://docs.voucherify.io/reference/get-product-collection
|
|
1682
|
+
/**
|
|
1683
|
+
* @see https://docs.voucherify.io/reference/get-product-collection
|
|
1909
1684
|
*/
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
1685
|
get(productCollectionId) {
|
|
1913
1686
|
return this.client.get(`/product-collections/${encode(productCollectionId)}`);
|
|
1914
1687
|
}
|
|
1915
|
-
/**
|
|
1916
|
-
* @see https://docs.voucherify.io/reference/list-products-in-collection
|
|
1688
|
+
/**
|
|
1689
|
+
* @see https://docs.voucherify.io/reference/list-products-in-collection
|
|
1917
1690
|
*/
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
1691
|
listProducts(productCollectionId, params) {
|
|
1921
|
-
return this.client.get(
|
|
1692
|
+
return this.client.get(
|
|
1693
|
+
`/product-collections/${encode(productCollectionId)}/products`,
|
|
1694
|
+
params
|
|
1695
|
+
);
|
|
1922
1696
|
}
|
|
1697
|
+
};
|
|
1698
|
+
__name(_ProductCollections, "ProductCollections");
|
|
1699
|
+
var ProductCollections = _ProductCollections;
|
|
1923
1700
|
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
class Qualifications {
|
|
1701
|
+
// src/Qualifications.ts
|
|
1702
|
+
var _Qualifications = class _Qualifications {
|
|
1927
1703
|
constructor(client) {
|
|
1928
|
-
this.client = void 0;
|
|
1929
1704
|
this.client = client;
|
|
1930
1705
|
}
|
|
1931
|
-
/**
|
|
1932
|
-
* @see https://docs.voucherify.io/reference/check-eligibility
|
|
1706
|
+
/**
|
|
1707
|
+
* @see https://docs.voucherify.io/reference/check-eligibility
|
|
1933
1708
|
*/
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
1709
|
checkEligibility(body) {
|
|
1937
|
-
return this.client.post(
|
|
1710
|
+
return this.client.post("/qualifications", body);
|
|
1938
1711
|
}
|
|
1712
|
+
};
|
|
1713
|
+
__name(_Qualifications, "Qualifications");
|
|
1714
|
+
var Qualifications = _Qualifications;
|
|
1939
1715
|
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
// apiLimitsHandler: ApiLimitsHandler
|
|
1943
|
-
// campaigns: Campaigns
|
|
1944
|
-
// consents: Consents
|
|
1945
|
-
// customers: Customers
|
|
1946
|
-
// distributions: Distributions
|
|
1947
|
-
// events: Events
|
|
1948
|
-
// loyalties: Loyalties
|
|
1949
|
-
// metadataSchemas: MetadataSchemas
|
|
1950
|
-
// orders: Orders
|
|
1951
|
-
// products: Products
|
|
1952
|
-
// promotions: Promotions
|
|
1953
|
-
// redemptions: Redemptions
|
|
1954
|
-
// rewards: Rewards
|
|
1955
|
-
// segments: Segments
|
|
1956
|
-
// validationRules: ValidationRules
|
|
1957
|
-
// validations: Validations
|
|
1958
|
-
// vouchers: Vouchers
|
|
1959
|
-
// }
|
|
1960
|
-
|
|
1716
|
+
// src/VoucherifyServerSide.ts
|
|
1961
1717
|
function VoucherifyServerSide(options) {
|
|
1962
|
-
var
|
|
1963
|
-
|
|
1718
|
+
var _a, _b, _c;
|
|
1964
1719
|
assert(isObject(options), 'VoucherifyServerSide: the "options" argument must be an object');
|
|
1965
1720
|
assert(isString(options.applicationId), 'VoucherifyServerSide: "options.applicationId" is required');
|
|
1966
1721
|
assert(isString(options.secretKey), 'VoucherifyServerSide: "options.secretKey" is required');
|
|
1967
1722
|
assert(isOptionalString(options.apiVersion), 'VoucherifyServerSide: expected "options.apiVersion" to be a string');
|
|
1968
1723
|
assert(isOptionalString(options.channel), 'VoucherifyServerSide: expected "options.channel" to be a string');
|
|
1969
1724
|
let headers = {
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1725
|
+
"X-App-Id": options.applicationId,
|
|
1726
|
+
"X-App-Token": options.secretKey,
|
|
1727
|
+
"X-Voucherify-Channel": options.channel || `${environment()}-SDK-v${"2.9.4"}`,
|
|
1728
|
+
"Content-Type": "application/json"
|
|
1974
1729
|
};
|
|
1975
|
-
|
|
1976
1730
|
if (options.apiVersion) {
|
|
1977
|
-
headers[
|
|
1731
|
+
headers["X-Voucherify-API-Version"] = options.apiVersion;
|
|
1978
1732
|
}
|
|
1979
|
-
|
|
1980
1733
|
if (isObject(options.customHeaders)) {
|
|
1981
1734
|
headers = Object.assign({}, headers, options.customHeaders);
|
|
1982
1735
|
}
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
if (!environment().startsWith('Node')) {
|
|
1991
|
-
assert(options.dangerouslySetSecretKeyInBrowser === true, `VoucherifyServerSide: you're exposing your secretKey to a ${environment().toLowerCase()} environment. This is generally considered a bad practice. Did you mean to use 'VoucherifyClientSide'?`);
|
|
1736
|
+
if (!environment().startsWith("Node")) {
|
|
1737
|
+
assert(
|
|
1738
|
+
options.dangerouslySetSecretKeyInBrowser === true,
|
|
1739
|
+
`VoucherifyServerSide: you're exposing your secretKey to a ${environment().toLowerCase()} environment. This is generally considered a bad practice. Did you mean to use 'VoucherifyClientSide'?`
|
|
1740
|
+
);
|
|
1992
1741
|
}
|
|
1993
|
-
|
|
1994
1742
|
const client = new RequestController({
|
|
1995
|
-
basePath:
|
|
1996
|
-
baseURL: (
|
|
1743
|
+
basePath: "v1",
|
|
1744
|
+
baseURL: (_a = options.apiUrl) != null ? _a : "https://api.voucherify.io",
|
|
1997
1745
|
headers,
|
|
1998
|
-
exposeErrorCause: (
|
|
1999
|
-
timeoutMs: (
|
|
1746
|
+
exposeErrorCause: (_b = options.exposeErrorCause) != null ? _b : false,
|
|
1747
|
+
timeoutMs: (_c = options.timeoutMs) != null ? _c : 0
|
|
2000
1748
|
});
|
|
2001
1749
|
const asyncActions = new AsyncActions(client);
|
|
2002
1750
|
const balance = new Balance(client);
|
|
@@ -2047,29 +1795,27 @@ function VoucherifyServerSide(options) {
|
|
|
2047
1795
|
metadataSchemas
|
|
2048
1796
|
};
|
|
2049
1797
|
}
|
|
1798
|
+
__name(VoucherifyServerSide, "VoucherifyServerSide");
|
|
2050
1799
|
|
|
2051
|
-
|
|
1800
|
+
// src/ClientSide.ts
|
|
1801
|
+
var _ClientSide = class _ClientSide {
|
|
2052
1802
|
constructor(client, trackingId) {
|
|
2053
|
-
this.client = void 0;
|
|
2054
|
-
this.trackingId = void 0;
|
|
2055
1803
|
this.client = client;
|
|
2056
1804
|
this.trackingId = trackingId;
|
|
2057
1805
|
}
|
|
2058
|
-
|
|
2059
1806
|
setIdentity(identity) {
|
|
2060
1807
|
this.trackingId = identity;
|
|
2061
1808
|
}
|
|
2062
|
-
/**
|
|
2063
|
-
* @see https://docs.voucherify.io/reference/vouchers-validate
|
|
1809
|
+
/**
|
|
1810
|
+
* @see https://docs.voucherify.io/reference/vouchers-validate
|
|
2064
1811
|
*/
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
1812
|
validate(params) {
|
|
2068
|
-
var
|
|
2069
|
-
|
|
2070
|
-
|
|
1813
|
+
var _a, _b;
|
|
1814
|
+
assert(
|
|
1815
|
+
isObject(params) || isString(params),
|
|
1816
|
+
'client.validate: expected "params" argument to be an object or a string'
|
|
1817
|
+
);
|
|
2071
1818
|
const query = {};
|
|
2072
|
-
|
|
2073
1819
|
if (isString(params)) {
|
|
2074
1820
|
query.code = params;
|
|
2075
1821
|
} else {
|
|
@@ -2077,9 +1823,7 @@ class ClientSide {
|
|
|
2077
1823
|
query.item = params.items;
|
|
2078
1824
|
query.amount = params.amount;
|
|
2079
1825
|
query.metadata = params.metadata;
|
|
2080
|
-
query.order = {
|
|
2081
|
-
metadata: params.orderMetadata
|
|
2082
|
-
};
|
|
1826
|
+
query.order = { metadata: params.orderMetadata };
|
|
2083
1827
|
query.customer = params.customer;
|
|
2084
1828
|
query.tracking_id = params.tracking_id || this.trackingId;
|
|
2085
1829
|
query.session_type = params.session_type;
|
|
@@ -2087,79 +1831,67 @@ class ClientSide {
|
|
|
2087
1831
|
query.session_ttl = params.session_ttl;
|
|
2088
1832
|
query.session_ttl_unit = params.session_ttl_unit;
|
|
2089
1833
|
}
|
|
2090
|
-
|
|
2091
1834
|
if (!!query.code) {
|
|
2092
|
-
query.code = query.code.replace(/[\r\n\t\f\v]/g,
|
|
1835
|
+
query.code = query.code.replace(/[\r\n\t\f\v]/g, "").trim();
|
|
2093
1836
|
}
|
|
2094
|
-
|
|
2095
1837
|
assert(isOptionalObject(query == null ? void 0 : query.customer), 'client.validate: expected "params.customer" to be an object');
|
|
2096
|
-
assert(isOptionalString(query == null ? void 0 :
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
const path = query.code ? '/validate' : '/promotions/validation';
|
|
1838
|
+
assert(isOptionalString((_a = query == null ? void 0 : query.customer) == null ? void 0 : _a.source_id), 'client.validate: expected "params.customer.source_id" to be a string');
|
|
1839
|
+
assert(isOptionalObject((_b = query == null ? void 0 : query.customer) == null ? void 0 : _b.metadata), 'client.validate: expected "params.customer.metadata" to be an object');
|
|
1840
|
+
const path = query.code ? "/validate" : "/promotions/validation";
|
|
2101
1841
|
return this.client.get(path, query);
|
|
2102
1842
|
}
|
|
2103
|
-
/**
|
|
2104
|
-
* @see https://docs.voucherify.io/reference/redeem-voucher-client-side
|
|
1843
|
+
/**
|
|
1844
|
+
* @see https://docs.voucherify.io/reference/redeem-voucher-client-side
|
|
2105
1845
|
*/
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
1846
|
redeem(code, payload = {}) {
|
|
2109
|
-
var
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
payload.customer = (
|
|
2114
|
-
|
|
2115
|
-
return this.client.post('/redeem', payload, {
|
|
2116
|
-
code
|
|
2117
|
-
});
|
|
1847
|
+
var _a, _b;
|
|
1848
|
+
assert(isString(code), "client.redeem - please provide a valid Voucher code");
|
|
1849
|
+
code = code.replace(/[\r\n\t\f\v]/g, "").trim();
|
|
1850
|
+
payload.customer = (_a = payload.customer) != null ? _a : {};
|
|
1851
|
+
payload.customer.source_id = (_b = payload.customer.source_id) != null ? _b : this.trackingId;
|
|
1852
|
+
return this.client.post("/redeem", payload, { code });
|
|
2118
1853
|
}
|
|
2119
|
-
/**
|
|
2120
|
-
* @see https://docs.voucherify.io/reference/create-publication
|
|
1854
|
+
/**
|
|
1855
|
+
* @see https://docs.voucherify.io/reference/create-publication
|
|
2121
1856
|
*/
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
1857
|
publish(campaign, payload = {}, queryParams = {}) {
|
|
2125
|
-
var
|
|
2126
|
-
|
|
2127
|
-
assert(isObject(payload), 'client.publish - expected payload to be an object');
|
|
1858
|
+
var _a, _b, _c, _d, _e;
|
|
1859
|
+
assert(isObject(payload), "client.publish - expected payload to be an object");
|
|
2128
1860
|
const preparedPayload = {};
|
|
2129
|
-
preparedPayload.customer = (
|
|
2130
|
-
preparedPayload.customer.source_id = (
|
|
2131
|
-
preparedPayload.channel = (
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
1861
|
+
preparedPayload.customer = (_a = payload.customer) != null ? _a : {};
|
|
1862
|
+
preparedPayload.customer.source_id = (_c = (_b = payload.customer) == null ? void 0 : _b.source_id) != null ? _c : this.trackingId;
|
|
1863
|
+
preparedPayload.channel = (_d = payload.channel) != null ? _d : "Voucherify.js";
|
|
1864
|
+
assert(
|
|
1865
|
+
isString((_e = preparedPayload.customer) == null ? void 0 : _e.source_id),
|
|
1866
|
+
"client.publish - expected payload to contain customer source id or to have tracking id set up by Voucherify client"
|
|
1867
|
+
);
|
|
1868
|
+
queryParams.campaign = campaign.replace(/[\r\n\t\f\v]/g, "").trim();
|
|
1869
|
+
return this.client.post("/publish", preparedPayload, queryParams);
|
|
1870
|
+
}
|
|
1871
|
+
/**
|
|
1872
|
+
* @see https://docs.voucherify.io/reference/track-custom-event-client-side
|
|
2139
1873
|
*/
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
1874
|
track(event_name, customer, metadata, referral, loyalty) {
|
|
2143
|
-
var
|
|
2144
|
-
|
|
2145
|
-
assert(
|
|
2146
|
-
assert(isObject(customer), 'client.track - expected customer to be an object');
|
|
1875
|
+
var _a, _b;
|
|
1876
|
+
assert(isString(event_name), "client.track - expected event name to be an string");
|
|
1877
|
+
assert(isObject(customer), "client.track - expected customer to be an object");
|
|
2147
1878
|
const payload = {
|
|
2148
1879
|
event: event_name,
|
|
2149
1880
|
metadata: metadata != null ? metadata : {},
|
|
2150
|
-
customer
|
|
2151
|
-
referral: referral != null ? referral :
|
|
2152
|
-
loyalty: loyalty != null ? loyalty :
|
|
1881
|
+
customer,
|
|
1882
|
+
referral: referral != null ? referral : void 0,
|
|
1883
|
+
loyalty: loyalty != null ? loyalty : void 0
|
|
2153
1884
|
};
|
|
2154
|
-
payload.customer.source_id = (
|
|
2155
|
-
assert(
|
|
2156
|
-
|
|
1885
|
+
payload.customer.source_id = (_a = customer.source_id) != null ? _a : this.trackingId;
|
|
1886
|
+
assert(
|
|
1887
|
+
isString((_b = payload.customer) == null ? void 0 : _b.source_id),
|
|
1888
|
+
"client.track - expected payload to contain customer source id or to have tracking id set up by Voucherify client"
|
|
1889
|
+
);
|
|
1890
|
+
return this.client.post("/events", payload);
|
|
2157
1891
|
}
|
|
2158
|
-
/**
|
|
2159
|
-
* @see https://docs.voucherify.io/reference/list-vouchers
|
|
1892
|
+
/**
|
|
1893
|
+
* @see https://docs.voucherify.io/reference/list-vouchers
|
|
2160
1894
|
*/
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
1895
|
listVouchers(params = {}) {
|
|
2164
1896
|
const query = {};
|
|
2165
1897
|
query.campaign = params.campaign;
|
|
@@ -2169,93 +1901,86 @@ class ClientSide {
|
|
|
2169
1901
|
query.customer = params.customer;
|
|
2170
1902
|
query.created_at = params.created_at;
|
|
2171
1903
|
query.updated_at = params.updated_at;
|
|
2172
|
-
return this.client.get(
|
|
1904
|
+
return this.client.get("/vouchers", query);
|
|
2173
1905
|
}
|
|
2174
|
-
/**
|
|
2175
|
-
* @see https://docs.voucherify.io/reference/create-customer
|
|
1906
|
+
/**
|
|
1907
|
+
* @see https://docs.voucherify.io/reference/create-customer
|
|
2176
1908
|
*/
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
1909
|
createCustomer(customer, enableDoubleOptIn) {
|
|
2180
|
-
return this.client.post(
|
|
2181
|
-
|
|
2182
|
-
|
|
1910
|
+
return this.client.post(
|
|
1911
|
+
"/customers",
|
|
1912
|
+
customer,
|
|
1913
|
+
{},
|
|
1914
|
+
enableDoubleOptIn ? { "X-Voucherify-Double-Opt-In": true } : {}
|
|
1915
|
+
);
|
|
2183
1916
|
}
|
|
2184
|
-
/**
|
|
2185
|
-
* @see https://docs.voucherify.io/reference/get-consent-client-side
|
|
1917
|
+
/**
|
|
1918
|
+
* @see https://docs.voucherify.io/reference/get-consent-client-side
|
|
2186
1919
|
*/
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
1920
|
listConsents() {
|
|
2190
|
-
return this.client.get(
|
|
1921
|
+
return this.client.get("/consents");
|
|
2191
1922
|
}
|
|
2192
|
-
/**
|
|
2193
|
-
* @see https://docs.voucherify.io/reference/update-customers-consents-client
|
|
1923
|
+
/**
|
|
1924
|
+
* @see https://docs.voucherify.io/reference/update-customers-consents-client
|
|
2194
1925
|
*/
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
1926
|
updateConsents(idOrSourceId, consents) {
|
|
2198
1927
|
return this.client.put(`/customers/${encode(idOrSourceId)}/consents`, consents);
|
|
2199
1928
|
}
|
|
2200
|
-
/**
|
|
2201
|
-
* @see https://docs.voucherify.io/reference/validate-stackable-discounts-client-side
|
|
1929
|
+
/**
|
|
1930
|
+
* @see https://docs.voucherify.io/reference/validate-stackable-discounts-client-side
|
|
2202
1931
|
*/
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
1932
|
validateStackable(params) {
|
|
2206
1933
|
return this.client.post(`/validations`, params);
|
|
2207
1934
|
}
|
|
2208
|
-
/**
|
|
2209
|
-
* @see https://docs.voucherify.io/reference/redeem-stackable-discounts-client-side
|
|
1935
|
+
/**
|
|
1936
|
+
* @see https://docs.voucherify.io/reference/redeem-stackable-discounts-client-side
|
|
2210
1937
|
*/
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
1938
|
redeemStackable(params) {
|
|
2214
1939
|
return this.client.post(`/redemptions`, params);
|
|
2215
1940
|
}
|
|
2216
|
-
/**
|
|
2217
|
-
* @see https://docs.voucherify.io/reference/check-eligibility
|
|
1941
|
+
/**
|
|
1942
|
+
* @see https://docs.voucherify.io/reference/check-eligibility
|
|
2218
1943
|
*/
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
1944
|
qualifications(body) {
|
|
2222
|
-
return this.client.post(
|
|
1945
|
+
return this.client.post("/qualifications", body);
|
|
2223
1946
|
}
|
|
1947
|
+
};
|
|
1948
|
+
__name(_ClientSide, "ClientSide");
|
|
1949
|
+
var ClientSide = _ClientSide;
|
|
2224
1950
|
|
|
2225
|
-
|
|
2226
|
-
|
|
1951
|
+
// src/VoucherifyClientSide.ts
|
|
2227
1952
|
function VoucherifyClientSide(options) {
|
|
2228
|
-
var
|
|
2229
|
-
|
|
1953
|
+
var _a, _b, _c;
|
|
2230
1954
|
assert(isObject(options), 'VoucherifyCustomer: expected "options" argument to be an object');
|
|
2231
1955
|
assert(isString(options.clientApplicationId), 'VoucherifyCustomer: "options.clientApplicationId" is required');
|
|
2232
1956
|
assert(isString(options.clientSecretKey), 'VoucherifyCustomer: "options.clientSecretKey" is required');
|
|
2233
1957
|
assert(isOptionalString(options.apiUrl), 'VoucherifyCustomer: expected "options.baseUrl" to be a string');
|
|
2234
1958
|
assert(isOptionalString(options.trackingId), 'VoucherifyCustomer: expected "options.trackingId" to be a string');
|
|
2235
1959
|
let headers = {
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
1960
|
+
"X-Client-Application-Id": options.clientApplicationId,
|
|
1961
|
+
"X-Client-Token": options.clientSecretKey,
|
|
1962
|
+
"X-Voucherify-Channel": `${environment()}-ClientSide-SDK-v${"2.9.4"}`
|
|
2239
1963
|
};
|
|
2240
|
-
|
|
2241
|
-
if (environment().startsWith('Node')) {
|
|
1964
|
+
if (environment().startsWith("Node")) {
|
|
2242
1965
|
assert(isString(options.origin), 'VoucherifyCustomer: "options.origin" is required in Node.js');
|
|
2243
|
-
headers[
|
|
1966
|
+
headers["origin"] = options.origin;
|
|
2244
1967
|
}
|
|
2245
|
-
|
|
2246
1968
|
if (isObject(options.customHeaders)) {
|
|
2247
1969
|
headers = Object.assign({}, headers, options.customHeaders);
|
|
2248
1970
|
}
|
|
2249
|
-
|
|
2250
1971
|
const client = new RequestController({
|
|
2251
|
-
basePath:
|
|
2252
|
-
baseURL: (
|
|
1972
|
+
basePath: "client/v1",
|
|
1973
|
+
baseURL: (_a = options.apiUrl) != null ? _a : "https://api.voucherify.io",
|
|
2253
1974
|
headers,
|
|
2254
|
-
exposeErrorCause: (
|
|
2255
|
-
timeoutMs: (
|
|
1975
|
+
exposeErrorCause: (_b = options.exposeErrorCause) != null ? _b : false,
|
|
1976
|
+
timeoutMs: (_c = options.timeoutMs) != null ? _c : 0
|
|
2256
1977
|
});
|
|
2257
1978
|
return new ClientSide(client, options.trackingId);
|
|
2258
1979
|
}
|
|
2259
|
-
|
|
2260
|
-
export {
|
|
2261
|
-
|
|
1980
|
+
__name(VoucherifyClientSide, "VoucherifyClientSide");
|
|
1981
|
+
export {
|
|
1982
|
+
DiscountVouchersTypesEnum,
|
|
1983
|
+
VoucherifyClientSide,
|
|
1984
|
+
VoucherifyServerSide
|
|
1985
|
+
};
|
|
1986
|
+
//# sourceMappingURL=voucherifysdk.esm.js.map
|