@voucherify/sdk 2.5.0 → 2.6.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.
@@ -158,18 +158,62 @@ export interface RewardTypeMaterial {
158
158
  };
159
159
  }
160
160
  export declare type RewardType = RewardTypeCampaign | RewardTypeCoin | RewardTypeMaterial;
161
- export interface RewardAssignment {
161
+ export declare type RewardAssignment = RewardsAssignmentCoinReward | RewardsAssignmentCampaignOrMaterialReward;
162
+ export interface RewardsAssignmentCoinReward {
162
163
  id: string;
163
164
  reward_id: string;
164
- related_object_id?: string;
165
- related_object_type?: string;
165
+ related_object_id: string;
166
+ related_object_type: 'campaign';
167
+ created_at: string;
168
+ updated_at: string | null;
169
+ object: 'reward-assignment';
170
+ }
171
+ export interface RewardsAssignmentCampaignOrMaterialReward {
172
+ id: string;
173
+ reward_id: string;
174
+ related_object_id: string;
175
+ related_object_type: 'campaign';
176
+ created_at: string;
177
+ updated_at: string | null;
178
+ object: 'reward-assignment';
179
+ parameters: {
180
+ loyalty: {
181
+ points?: number;
182
+ };
183
+ };
184
+ }
185
+ export declare type RewardsGetAssignmentResponseBody = RewardAssignment;
186
+ export interface RewardsListAssignmentsRequestQuery {
187
+ limit?: number;
188
+ page?: number;
189
+ }
190
+ export interface RewardsListAssignmentsResponseBody {
191
+ object: 'list';
192
+ data_ref: 'data';
193
+ data: RewardAssignment[];
194
+ total: number;
195
+ }
196
+ export declare type RewardsCreateAssignmentRequestBody = RewardsCreateAssignmentCoinRewardRequestBody | RewardsCreateAssignmentCampaignOrMaterialRewardRequestBody;
197
+ export interface RewardsCreateAssignmentCoinRewardRequestBody {
198
+ campaign: string;
199
+ validation_rules?: string[];
200
+ }
201
+ export interface RewardsCreateAssignmentCampaignOrMaterialRewardRequestBody {
202
+ campaign: string;
203
+ parameters: {
204
+ loyalty: {
205
+ points?: number;
206
+ };
207
+ };
208
+ }
209
+ export declare type RewardsCreateAssignmentResponseBody = RewardAssignment;
210
+ export interface RewardsUpdateAssignmentRequestBody {
166
211
  parameters?: {
167
212
  loyalty?: {
168
- points: number;
213
+ points?: number;
169
214
  };
170
215
  };
171
- created_at: string;
172
- updated_at?: string;
173
- object: 'reward_assignment';
216
+ id: string;
174
217
  }
218
+ export declare type RewardsUpdateAssignmentResponseBody = RewardAssignment;
175
219
  export {};
@@ -69,3 +69,24 @@ export interface ValidationRulesListAssignmentsResponse {
69
69
  data_ref: 'data';
70
70
  data: ValidationRulesCreateAssignmentResponse[];
71
71
  }
72
+ export interface ValidationRulesAssignment {
73
+ id: string;
74
+ rule_id: string;
75
+ related_object_id: string;
76
+ related_object_type: string;
77
+ created_at: string;
78
+ object: 'validation_rules_assignment';
79
+ }
80
+ export interface ValidationRulesListRulesAssignmentsRequestQuery {
81
+ related_object_id?: string;
82
+ rule?: string;
83
+ page?: number;
84
+ limit?: number;
85
+ order?: 'created_at' | '-created_at';
86
+ }
87
+ export interface ValidationRulesListRulesAssignmentsResponseBody {
88
+ object: 'list';
89
+ data_ref: 'data';
90
+ total: number;
91
+ data: ValidationRulesAssignment[];
92
+ }
@@ -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
+ }
@@ -586,6 +586,22 @@ class Vouchers {
586
586
  form.append('file', fileStream);
587
587
  return this.client.post('/vouchers/importCSV', form);
588
588
  }
589
+ /**
590
+ * @see https://docs.voucherify.io/reference/list-voucher-transactions
591
+ */
592
+
593
+
594
+ listTransactions(code, params) {
595
+ return this.client.get(`/vouchers/${encode(code)}/transactions`, params);
596
+ }
597
+ /**
598
+ * @see https://docs.voucherify.io/reference/export-voucher-transactions
599
+ */
600
+
601
+
602
+ exportTransactions(code, body) {
603
+ return this.client.post(`/vouchers/${encode(code)}/transactions/export`, body);
604
+ }
589
605
 
590
606
  }
591
607
 
@@ -773,11 +789,13 @@ class PromotionTiers {
773
789
  }
774
790
 
775
791
  class Promotions {
776
- constructor(client, tiers) {
792
+ constructor(client, tiers, stack) {
777
793
  this.client = void 0;
778
794
  this.tiers = void 0;
795
+ this.stack = void 0;
779
796
  this.client = client;
780
797
  this.tiers = tiers;
798
+ this.stack = stack;
781
799
  }
782
800
  /**
783
801
  * @see https://docs.voucherify.io/reference/create-promotion-campaign
@@ -1180,6 +1198,14 @@ class Rewards {
1180
1198
  delete(rewardId) {
1181
1199
  return this.client.delete(`/rewards/${encode(rewardId)}`);
1182
1200
  }
1201
+ /**
1202
+ * @see https://docs.voucherify.io/reference/get-reward-assignment
1203
+ */
1204
+
1205
+
1206
+ getAssignment(rewardId, assignmentId) {
1207
+ return this.client.get(`/rewards/${encode(rewardId)}/assignments/${encode(assignmentId)}`);
1208
+ }
1183
1209
  /**
1184
1210
  * @see https://docs.voucherify.io/reference/list-reward-assignments
1185
1211
  */
@@ -1288,6 +1314,14 @@ class Loyalties {
1288
1314
  deleteRewardAssignment(campaignId, assignmentId) {
1289
1315
  return this.client.delete(`/loyalties/${encode(campaignId)}/rewards/${assignmentId}`);
1290
1316
  }
1317
+ /**
1318
+ * @see https://docs.voucherify.io/reference/get-reward-assignment-2
1319
+ */
1320
+
1321
+
1322
+ getRewardAssignment(campaignId, assignmentId) {
1323
+ return this.client.get(`/loyalties/${encode(campaignId)}/rewards/${encode(assignmentId)}`);
1324
+ }
1291
1325
  /**
1292
1326
  * @see https://docs.voucherify.io/reference/list-earning-rules
1293
1327
  */
@@ -1427,6 +1461,14 @@ class Loyalties {
1427
1461
  redeemReward(campaignId, memberId, params) {
1428
1462
  return this.client.post(`/loyalties/${encode(campaignId)}/members/${encode(memberId)}/redemption`, params);
1429
1463
  }
1464
+ /**
1465
+ * @see https://docs.voucherify.io/reference/list-loyalty-tier-rewards
1466
+ */
1467
+
1468
+
1469
+ listLoyaltyTierRewards(campaignId, tierId) {
1470
+ return this.client.get(`/loyalties/${encode(campaignId)}/tiers/${encode(tierId)}/rewards`);
1471
+ }
1430
1472
  /**
1431
1473
  * @see https://docs.voucherify.io/reference/list-loyalty-card-transactions
1432
1474
  * @see https://docs.voucherify.io/reference/list-loyalty-card-transactions-1
@@ -1445,14 +1487,6 @@ class Loyalties {
1445
1487
  exportCardTransactions(memberId, campaignId, params = {}) {
1446
1488
  return this.client.post(campaignId ? `/loyalties/${encode(campaignId)}/members/${encode(memberId)}/transactions/export` : `/loyalties/members/${encode(memberId)}/transactions/export`, params);
1447
1489
  }
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
1490
  /**
1457
1491
  * @see https://docs.voucherify.io/reference/get-reward-details
1458
1492
  */
@@ -1569,6 +1603,14 @@ class ValidationRules {
1569
1603
  list(params = {}) {
1570
1604
  return this.client.get('/validation-rules', params);
1571
1605
  }
1606
+ /**
1607
+ * @see https://docs.voucherify.io/reference/list-validation-rules-assignments
1608
+ */
1609
+
1610
+
1611
+ listRulesAssignments(params = {}) {
1612
+ return this.client.get(`/validation-rules-assignments`, params);
1613
+ }
1572
1614
  /**
1573
1615
  * @see https://docs.voucherify.io/reference/list-validation-rule-assignments
1574
1616
  */
@@ -1691,8 +1733,8 @@ class Categories {
1691
1733
  */
1692
1734
 
1693
1735
 
1694
- list() {
1695
- return this.client.get('/categories');
1736
+ list(params = {}) {
1737
+ return this.client.get('/categories', params);
1696
1738
  }
1697
1739
  /**
1698
1740
  * @see https://docs.voucherify.io/reference/create-category
@@ -1729,6 +1771,62 @@ class Categories {
1729
1771
 
1730
1772
  }
1731
1773
 
1774
+ class PromotionsStacks {
1775
+ constructor(client) {
1776
+ this.client = void 0;
1777
+ this.client = client;
1778
+ }
1779
+ /**
1780
+ * @see https://docs.voucherify.io/reference/list-promotion-stacks-in-campaign
1781
+ */
1782
+
1783
+
1784
+ listInCampaign(campaignId) {
1785
+ return this.client.get(`/promotions/${campaignId}/stacks`);
1786
+ }
1787
+ /**
1788
+ * @see https://docs.voucherify.io/reference/list-promotion-stacks-in-campaign
1789
+ */
1790
+
1791
+
1792
+ createInCampaign(campaignId, body) {
1793
+ return this.client.post(`/promotions/${campaignId}/stacks`, body);
1794
+ }
1795
+ /**
1796
+ * @see https://docs.voucherify.io/reference/delete-promotion-stack
1797
+ */
1798
+
1799
+
1800
+ delete(campaignId, stackId) {
1801
+ return this.client.delete(`/promotions/${campaignId}/stacks/${stackId}`);
1802
+ }
1803
+ /**
1804
+ * @see https://docs.voucherify.io/reference/get-promotion-stack
1805
+ */
1806
+
1807
+
1808
+ get(campaignId, stackId) {
1809
+ return this.client.get(`/promotions/${campaignId}/stacks/${stackId}`);
1810
+ }
1811
+ /**
1812
+ * @see https://docs.voucherify.io/reference/update-promotion-stack
1813
+ */
1814
+
1815
+
1816
+ update(campaignId, stackId, body) {
1817
+ return this.client.put(`/promotions/${campaignId}/stacks/${stackId}`, body);
1818
+ }
1819
+ /**
1820
+ * @see https://docs.voucherify.io/reference/list-promotion-stacks-in-campaign
1821
+ */
1822
+
1823
+
1824
+ list(params) {
1825
+ return this.client.get(`/promotions/stacks`, params);
1826
+ }
1827
+
1828
+ }
1829
+
1732
1830
  class ProductCollections {
1733
1831
  constructor(client) {
1734
1832
  this.client = void 0;
@@ -1807,7 +1905,7 @@ function VoucherifyServerSide(options) {
1807
1905
  let headers = {
1808
1906
  'X-App-Id': options.applicationId,
1809
1907
  'X-App-Token': options.secretKey,
1810
- 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.5.0"}`,
1908
+ 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.6.0"}`,
1811
1909
  'Content-Type': 'application/json'
1812
1910
  };
1813
1911
 
@@ -1845,7 +1943,8 @@ function VoucherifyServerSide(options) {
1845
1943
  const events = new Events(client);
1846
1944
  const distributions = new Distributions(client, exportsNamespace);
1847
1945
  const promotionTiers = new PromotionTiers(client);
1848
- const promotions = new Promotions(client, promotionTiers);
1946
+ const promotionStack = new PromotionsStacks(client);
1947
+ const promotions = new Promotions(client, promotionTiers, promotionStack);
1849
1948
  const validations = new Validations(client, promotions);
1850
1949
  const redemptions = new Redemptions(client);
1851
1950
  const customers = new Customers(client);
@@ -2062,7 +2161,7 @@ function VoucherifyClientSide(options) {
2062
2161
  let headers = {
2063
2162
  'X-Client-Application-Id': options.clientApplicationId,
2064
2163
  'X-Client-Token': options.clientSecretKey,
2065
- 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.5.0"}`
2164
+ 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.6.0"}`
2066
2165
  };
2067
2166
 
2068
2167
  if (environment().startsWith('Node')) {