@voucherify/sdk 2.5.0 → 2.7.0

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.
@@ -1,6 +1,7 @@
1
1
  import { OrdersGetResponse } from './Orders';
2
2
  import { SimpleCustomer } from './Customers';
3
3
  import { DiscountUnit, DiscountAmount, DiscountPercent, DiscountFixed } from './DiscountVoucher';
4
+ import { LoyaltyCardTransaction } from './Loyalties';
4
5
  export declare type VoucherType = 'GIFT_VOUCHER' | 'DISCOUNT_VOUCHER' | 'LOYALTY_CARD' | 'LUCKY_DRAW';
5
6
  export interface SimpleVoucher {
6
7
  code_config?: {
@@ -214,3 +215,140 @@ export declare type VouchersBulkUpdateMetadataResponse = {
214
215
  export declare type VouchersBulkUpdateResponse = {
215
216
  async_action_id: string;
216
217
  };
218
+ export declare type GiftCardTransaction = GiftCardTransactionBase & GiftCardTransactionDetails;
219
+ export interface GiftCardTransactionBase {
220
+ id: string;
221
+ source_id: string | null;
222
+ voucher_id: string;
223
+ campaign_id: string | null;
224
+ related_transaction_id: string | null;
225
+ reason: string | null;
226
+ created_at: string;
227
+ }
228
+ export declare type GiftCardTransactionDetails = GiftCardTransactionRedemptionDetails | GiftCardTransactionRefundDetails | GiftCardTransactionAdditionDetails | GiftCardTransactionRemovalDetails;
229
+ export interface GiftCardTransactionRedemptionDetails {
230
+ source: null;
231
+ type: 'CREDITS_REDEMPTION';
232
+ details: {
233
+ balance: {
234
+ type: 'gift_voucher';
235
+ total: number;
236
+ amount: number;
237
+ object: 'balance';
238
+ balance: number;
239
+ related_object: {
240
+ id: string;
241
+ type: 'voucher';
242
+ };
243
+ };
244
+ order: {
245
+ id: string;
246
+ source_id: string | null;
247
+ };
248
+ redemption: {
249
+ id: string;
250
+ };
251
+ };
252
+ }
253
+ export interface GiftCardTransactionRefundDetails {
254
+ source: null;
255
+ type: 'CREDITS_REFUND';
256
+ details: {
257
+ balance: {
258
+ type: 'gift_voucher';
259
+ total: number;
260
+ amount: number;
261
+ object: 'balance';
262
+ balance: number;
263
+ related_object: {
264
+ id: string;
265
+ type: 'voucher';
266
+ };
267
+ };
268
+ order: {
269
+ id: string;
270
+ source_id: string | null;
271
+ };
272
+ redemption: {
273
+ id: string;
274
+ };
275
+ rollback: {
276
+ id: string;
277
+ };
278
+ };
279
+ }
280
+ export interface GiftCardTransactionAdditionDetails {
281
+ source: 'voucherify-web-ui' | 'API';
282
+ type: 'CREDITS_ADDITION';
283
+ details: {
284
+ balance: {
285
+ type: 'gift_voucher';
286
+ total: number;
287
+ amount: number;
288
+ object: 'balance';
289
+ balance: number;
290
+ operation_type: 'MANUAL' | 'AUTOMATIC';
291
+ related_object: {
292
+ id: string;
293
+ type: 'voucher';
294
+ };
295
+ };
296
+ };
297
+ }
298
+ export interface GiftCardTransactionRemovalDetails {
299
+ source: 'voucherify-web-ui' | 'API';
300
+ type: 'CREDITS_REMOVAL';
301
+ details: {
302
+ balance: {
303
+ type: 'gift_voucher';
304
+ total: number;
305
+ amount: number;
306
+ object: 'balance';
307
+ balance: number;
308
+ operation_type: 'MANUAL' | 'AUTOMATIC';
309
+ related_object: {
310
+ id: string;
311
+ type: 'voucher';
312
+ };
313
+ };
314
+ };
315
+ }
316
+ export declare type VoucherTransaction = GiftCardTransaction | LoyaltyCardTransaction;
317
+ export declare type VoucherTransactionsExportFields = 'id' | 'campaign_id' | 'voucher_id' | 'type' | 'source_id' | 'reason' | 'source' | 'balance' | 'amount' | 'related_transaction_id' | 'created_at' | 'details';
318
+ export interface VouchersListTransactionsRequestQuery {
319
+ limit?: number;
320
+ page?: number;
321
+ }
322
+ export interface VouchersListTransactionsResponseBody {
323
+ object: 'list';
324
+ data_ref: 'data';
325
+ data: VoucherTransaction[];
326
+ has_more: boolean;
327
+ }
328
+ export interface VouchersExportTransactionsRequestBody {
329
+ parameters?: {
330
+ order?: '-created_at' | 'created_at';
331
+ fields?: VoucherTransactionsExportFields[];
332
+ };
333
+ }
334
+ export interface VouchersExportTransactionsResponseBody {
335
+ id: string;
336
+ status: 'SCHEDULED';
337
+ channel: string;
338
+ parameters: {
339
+ order?: string;
340
+ fields?: VoucherTransactionsExportFields[];
341
+ filters: {
342
+ voucher_id: {
343
+ conditions: {
344
+ $in: [string];
345
+ };
346
+ };
347
+ };
348
+ };
349
+ result: null;
350
+ user_id: string | null;
351
+ exported_object: 'voucher_transactions';
352
+ object: 'export';
353
+ created_at: string;
354
+ }
@@ -22,3 +22,4 @@ export * from './Gift';
22
22
  export * from './ValidateSession';
23
23
  export * from './ApplicableTo';
24
24
  export * from './DiscountVoucher';
25
+ export * from './Qualifications';
@@ -105,7 +105,13 @@ class RequestController {
105
105
  }
106
106
 
107
107
  setLastResponseHeaders(headers) {
108
- this.lastResponseHeaders = headers;
108
+ const result = {};
109
+
110
+ for (const key in headers) {
111
+ result[key] = String(headers[key]);
112
+ }
113
+
114
+ this.lastResponseHeaders = result;
109
115
  this.isLastResponseHeadersSet = true;
110
116
  }
111
117
 
@@ -323,7 +329,10 @@ class Campaigns {
323
329
  const fileStream = fs.createReadStream(filePath);
324
330
  const form = new FormData();
325
331
  form.append('file', fileStream);
326
- return this.client.post(`/campaigns/${campaignId}/importCSV`, form);
332
+ const headers = {
333
+ 'Content-Type': 'multipart/form-data'
334
+ };
335
+ return this.client.post(`/campaigns/${campaignId}/importCSV`, form, undefined, headers);
327
336
  }
328
337
  /**
329
338
  * @see https://docs.voucherify.io/reference/enable-campaign
@@ -584,7 +593,26 @@ class Vouchers {
584
593
  const fileStream = fs.createReadStream(filePath);
585
594
  const form = new FormData();
586
595
  form.append('file', fileStream);
587
- return this.client.post('/vouchers/importCSV', form);
596
+ const headers = {
597
+ 'Content-Type': 'multipart/form-data'
598
+ };
599
+ return this.client.post('/vouchers/importCSV', form, undefined, headers);
600
+ }
601
+ /**
602
+ * @see https://docs.voucherify.io/reference/list-voucher-transactions
603
+ */
604
+
605
+
606
+ listTransactions(code, params) {
607
+ return this.client.get(`/vouchers/${encode(code)}/transactions`, params);
608
+ }
609
+ /**
610
+ * @see https://docs.voucherify.io/reference/export-voucher-transactions
611
+ */
612
+
613
+
614
+ exportTransactions(code, body) {
615
+ return this.client.post(`/vouchers/${encode(code)}/transactions/export`, body);
588
616
  }
589
617
 
590
618
  }
@@ -773,11 +801,13 @@ class PromotionTiers {
773
801
  }
774
802
 
775
803
  class Promotions {
776
- constructor(client, tiers) {
804
+ constructor(client, tiers, stack) {
777
805
  this.client = void 0;
778
806
  this.tiers = void 0;
807
+ this.stack = void 0;
779
808
  this.client = client;
780
809
  this.tiers = tiers;
810
+ this.stack = stack;
781
811
  }
782
812
  /**
783
813
  * @see https://docs.voucherify.io/reference/create-promotion-campaign
@@ -936,7 +966,10 @@ class Customers {
936
966
  const fileStream = fs.createReadStream(filePath);
937
967
  const form = new FormData();
938
968
  form.append('file', fileStream);
939
- return this.client.post(`/customers/importCSV`, form);
969
+ const headers = {
970
+ 'Content-Type': 'multipart/form-data'
971
+ };
972
+ return this.client.post(`/customers/importCSV`, form, undefined, headers);
940
973
  }
941
974
 
942
975
  }
@@ -1117,7 +1150,10 @@ class Products {
1117
1150
  const fileStream = fs.createReadStream(filePath);
1118
1151
  const form = new FormData();
1119
1152
  form.append('file', fileStream);
1120
- return this.client.post(`/skus/importCSV`, form);
1153
+ const headers = {
1154
+ 'Content-Type': 'multipart/form-data'
1155
+ };
1156
+ return this.client.post(`/skus/importCSV`, form, undefined, headers);
1121
1157
  }
1122
1158
  /**
1123
1159
  * @see https://docs.voucherify.io/reference/import-products-using-csv
@@ -1130,7 +1166,10 @@ class Products {
1130
1166
  const fileStream = fs.createReadStream(filePath);
1131
1167
  const form = new FormData();
1132
1168
  form.append('file', fileStream);
1133
- return this.client.post(`/products/importCSV`, form);
1169
+ const headers = {
1170
+ 'Content-Type': 'multipart/form-data'
1171
+ };
1172
+ return this.client.post(`/products/importCSV`, form, undefined, headers);
1134
1173
  }
1135
1174
 
1136
1175
  }
@@ -1180,6 +1219,14 @@ class Rewards {
1180
1219
  delete(rewardId) {
1181
1220
  return this.client.delete(`/rewards/${encode(rewardId)}`);
1182
1221
  }
1222
+ /**
1223
+ * @see https://docs.voucherify.io/reference/get-reward-assignment
1224
+ */
1225
+
1226
+
1227
+ getAssignment(rewardId, assignmentId) {
1228
+ return this.client.get(`/rewards/${encode(rewardId)}/assignments/${encode(assignmentId)}`);
1229
+ }
1183
1230
  /**
1184
1231
  * @see https://docs.voucherify.io/reference/list-reward-assignments
1185
1232
  */
@@ -1288,6 +1335,14 @@ class Loyalties {
1288
1335
  deleteRewardAssignment(campaignId, assignmentId) {
1289
1336
  return this.client.delete(`/loyalties/${encode(campaignId)}/rewards/${assignmentId}`);
1290
1337
  }
1338
+ /**
1339
+ * @see https://docs.voucherify.io/reference/get-reward-assignment-2
1340
+ */
1341
+
1342
+
1343
+ getRewardAssignment(campaignId, assignmentId) {
1344
+ return this.client.get(`/loyalties/${encode(campaignId)}/rewards/${encode(assignmentId)}`);
1345
+ }
1291
1346
  /**
1292
1347
  * @see https://docs.voucherify.io/reference/list-earning-rules
1293
1348
  */
@@ -1427,6 +1482,14 @@ class Loyalties {
1427
1482
  redeemReward(campaignId, memberId, params) {
1428
1483
  return this.client.post(`/loyalties/${encode(campaignId)}/members/${encode(memberId)}/redemption`, params);
1429
1484
  }
1485
+ /**
1486
+ * @see https://docs.voucherify.io/reference/list-loyalty-tier-rewards
1487
+ */
1488
+
1489
+
1490
+ listLoyaltyTierRewards(campaignId, tierId) {
1491
+ return this.client.get(`/loyalties/${encode(campaignId)}/tiers/${encode(tierId)}/rewards`);
1492
+ }
1430
1493
  /**
1431
1494
  * @see https://docs.voucherify.io/reference/list-loyalty-card-transactions
1432
1495
  * @see https://docs.voucherify.io/reference/list-loyalty-card-transactions-1
@@ -1445,14 +1508,6 @@ class Loyalties {
1445
1508
  exportCardTransactions(memberId, campaignId, params = {}) {
1446
1509
  return this.client.post(campaignId ? `/loyalties/${encode(campaignId)}/members/${encode(memberId)}/transactions/export` : `/loyalties/members/${encode(memberId)}/transactions/export`, params);
1447
1510
  }
1448
- /**
1449
- * @see https://docs.voucherify.io/reference/get-reward-assignment-1
1450
- */
1451
-
1452
-
1453
- getRewardAssignment(campaignId, assignmentId) {
1454
- return this.client.get(`/loyalties/${encode(campaignId)}/reward-assignments/${encode(assignmentId)}`);
1455
- }
1456
1511
  /**
1457
1512
  * @see https://docs.voucherify.io/reference/get-reward-details
1458
1513
  */
@@ -1569,6 +1624,14 @@ class ValidationRules {
1569
1624
  list(params = {}) {
1570
1625
  return this.client.get('/validation-rules', params);
1571
1626
  }
1627
+ /**
1628
+ * @see https://docs.voucherify.io/reference/list-validation-rules-assignments
1629
+ */
1630
+
1631
+
1632
+ listRulesAssignments(params = {}) {
1633
+ return this.client.get(`/validation-rules-assignments`, params);
1634
+ }
1572
1635
  /**
1573
1636
  * @see https://docs.voucherify.io/reference/list-validation-rule-assignments
1574
1637
  */
@@ -1691,8 +1754,8 @@ class Categories {
1691
1754
  */
1692
1755
 
1693
1756
 
1694
- list() {
1695
- return this.client.get('/categories');
1757
+ list(params = {}) {
1758
+ return this.client.get('/categories', params);
1696
1759
  }
1697
1760
  /**
1698
1761
  * @see https://docs.voucherify.io/reference/create-category
@@ -1729,6 +1792,62 @@ class Categories {
1729
1792
 
1730
1793
  }
1731
1794
 
1795
+ class PromotionsStacks {
1796
+ constructor(client) {
1797
+ this.client = void 0;
1798
+ this.client = client;
1799
+ }
1800
+ /**
1801
+ * @see https://docs.voucherify.io/reference/list-promotion-stacks-in-campaign
1802
+ */
1803
+
1804
+
1805
+ listInCampaign(campaignId) {
1806
+ return this.client.get(`/promotions/${campaignId}/stacks`);
1807
+ }
1808
+ /**
1809
+ * @see https://docs.voucherify.io/reference/list-promotion-stacks-in-campaign
1810
+ */
1811
+
1812
+
1813
+ createInCampaign(campaignId, body) {
1814
+ return this.client.post(`/promotions/${campaignId}/stacks`, body);
1815
+ }
1816
+ /**
1817
+ * @see https://docs.voucherify.io/reference/delete-promotion-stack
1818
+ */
1819
+
1820
+
1821
+ delete(campaignId, stackId) {
1822
+ return this.client.delete(`/promotions/${campaignId}/stacks/${stackId}`);
1823
+ }
1824
+ /**
1825
+ * @see https://docs.voucherify.io/reference/get-promotion-stack
1826
+ */
1827
+
1828
+
1829
+ get(campaignId, stackId) {
1830
+ return this.client.get(`/promotions/${campaignId}/stacks/${stackId}`);
1831
+ }
1832
+ /**
1833
+ * @see https://docs.voucherify.io/reference/update-promotion-stack
1834
+ */
1835
+
1836
+
1837
+ update(campaignId, stackId, body) {
1838
+ return this.client.put(`/promotions/${campaignId}/stacks/${stackId}`, body);
1839
+ }
1840
+ /**
1841
+ * @see https://docs.voucherify.io/reference/list-promotion-stacks-in-campaign
1842
+ */
1843
+
1844
+
1845
+ list(params) {
1846
+ return this.client.get(`/promotions/stacks`, params);
1847
+ }
1848
+
1849
+ }
1850
+
1732
1851
  class ProductCollections {
1733
1852
  constructor(client) {
1734
1853
  this.client = void 0;
@@ -1777,6 +1896,22 @@ class ProductCollections {
1777
1896
 
1778
1897
  }
1779
1898
 
1899
+ class Qualifications {
1900
+ constructor(client) {
1901
+ this.client = void 0;
1902
+ this.client = client;
1903
+ }
1904
+ /**
1905
+ * @see https://docs.voucherify.io/reference/check-eligibility
1906
+ */
1907
+
1908
+
1909
+ checkEligibility(body) {
1910
+ return this.client.post('/qualifications', body);
1911
+ }
1912
+
1913
+ }
1914
+
1780
1915
  // apiLimitsHandler: ApiLimitsHandler
1781
1916
  // campaigns: Campaigns
1782
1917
  // consents: Consents
@@ -1807,7 +1942,7 @@ function VoucherifyServerSide(options) {
1807
1942
  let headers = {
1808
1943
  'X-App-Id': options.applicationId,
1809
1944
  'X-App-Token': options.secretKey,
1810
- 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.5.0"}`,
1945
+ 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.7.0"}`,
1811
1946
  'Content-Type': 'application/json'
1812
1947
  };
1813
1948
 
@@ -1845,9 +1980,11 @@ function VoucherifyServerSide(options) {
1845
1980
  const events = new Events(client);
1846
1981
  const distributions = new Distributions(client, exportsNamespace);
1847
1982
  const promotionTiers = new PromotionTiers(client);
1848
- const promotions = new Promotions(client, promotionTiers);
1983
+ const promotionStack = new PromotionsStacks(client);
1984
+ const promotions = new Promotions(client, promotionTiers, promotionStack);
1849
1985
  const validations = new Validations(client, promotions);
1850
1986
  const redemptions = new Redemptions(client);
1987
+ const qualifications = new Qualifications(client);
1851
1988
  const customers = new Customers(client);
1852
1989
  const consents = new Consents(client);
1853
1990
  const orders = new Orders(client);
@@ -1872,6 +2009,7 @@ function VoucherifyServerSide(options) {
1872
2009
  orders,
1873
2010
  products,
1874
2011
  productCollections,
2012
+ qualifications,
1875
2013
  rewards,
1876
2014
  loyalties,
1877
2015
  segments,
@@ -2048,6 +2186,14 @@ class ClientSide {
2048
2186
  redeemStackable(params) {
2049
2187
  return this.client.post(`/redemptions`, params);
2050
2188
  }
2189
+ /**
2190
+ * @see https://docs.voucherify.io/reference/check-eligibility
2191
+ */
2192
+
2193
+
2194
+ qualifications(body) {
2195
+ return this.client.post('/qualifications', body);
2196
+ }
2051
2197
 
2052
2198
  }
2053
2199
 
@@ -2062,7 +2208,7 @@ function VoucherifyClientSide(options) {
2062
2208
  let headers = {
2063
2209
  'X-Client-Application-Id': options.clientApplicationId,
2064
2210
  'X-Client-Token': options.clientSecretKey,
2065
- 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.5.0"}`
2211
+ 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.7.0"}`
2066
2212
  };
2067
2213
 
2068
2214
  if (environment().startsWith('Node')) {