@voucherify/sdk 2.0.1 → 2.0.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/CHANGELOG.md +18 -0
- package/README.md +41 -0
- package/dist/ClientSide.d.ts +8 -0
- package/dist/Customers.d.ts +4 -0
- package/dist/Promotions.d.ts +1 -1
- package/dist/Redemptions.d.ts +9 -0
- package/dist/Validations.d.ts +4 -0
- package/dist/types/ApplicableTo.d.ts +15 -0
- package/dist/types/ClientSide.d.ts +12 -13
- package/dist/types/Customers.d.ts +14 -0
- package/dist/types/DiscountVoucher.d.ts +27 -0
- package/dist/types/Gift.d.ts +3 -0
- package/dist/types/Loyalties.d.ts +4 -0
- package/dist/types/Orders.d.ts +10 -0
- package/dist/types/Products.d.ts +10 -0
- package/dist/types/PromotionTiers.d.ts +3 -4
- package/dist/types/Promotions.d.ts +5 -1
- package/dist/types/Redemptions.d.ts +63 -13
- package/dist/types/Rewards.d.ts +5 -0
- package/dist/types/Stackable.d.ts +63 -0
- package/dist/types/ValidateSession.d.ts +17 -0
- package/dist/types/ValidationRules.d.ts +2 -5
- package/dist/types/Validations.d.ts +23 -17
- package/dist/types/Vouchers.d.ts +1 -15
- package/dist/types/index.d.ts +5 -0
- package/dist/voucherifysdk.esm.js +66 -5
- package/dist/voucherifysdk.esm.js.map +1 -1
- package/dist/voucherifysdk.umd.development.js +63 -4
- package/dist/voucherifysdk.umd.development.js.map +1 -1
- package/dist/voucherifysdk.umd.production.min.js +1 -1
- package/dist/voucherifysdk.umd.production.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { DiscountAmount, DiscountPercent, DiscountUnit } from './
|
|
2
|
-
import {
|
|
1
|
+
import { DiscountAmount, DiscountPercent, DiscountUnit } from './DiscountVoucher';
|
|
2
|
+
import { CustomersCreateBody } from './Customers';
|
|
3
|
+
import { StackableOptions, StackableRedeemableParams, StackableRedeemableResponse } from './Stackable';
|
|
4
|
+
import { ValidationSessionParams, ValidationSessionResponse } from './ValidateSession';
|
|
5
|
+
import { ApplicableToResultList } from './ApplicableTo';
|
|
6
|
+
import { OrdersItem, OrdersCreate, OrdersCreateResponse } from './Orders';
|
|
3
7
|
import { PromotionsValidateParams } from './Promotions';
|
|
4
8
|
export interface ValidationsValidateVoucherParams {
|
|
5
9
|
customer?: {
|
|
@@ -23,23 +27,10 @@ export interface ValidationsValidateVoucherParams {
|
|
|
23
27
|
reward?: {
|
|
24
28
|
id: string;
|
|
25
29
|
};
|
|
26
|
-
session?:
|
|
27
|
-
type: 'LOCK';
|
|
28
|
-
key?: string;
|
|
29
|
-
ttl?: number;
|
|
30
|
-
ttl_unit?: 'MILLISECONDS' | 'SECONDS' | 'MINUTES' | 'HOURS' | 'DAYS';
|
|
31
|
-
};
|
|
30
|
+
session?: ValidationSessionParams;
|
|
32
31
|
}
|
|
33
32
|
export interface ValidationsValidateVoucherResponse {
|
|
34
|
-
applicable_to?:
|
|
35
|
-
object: 'list';
|
|
36
|
-
total: number;
|
|
37
|
-
data?: {
|
|
38
|
-
id: string;
|
|
39
|
-
object: 'product';
|
|
40
|
-
source_id?: string;
|
|
41
|
-
}[];
|
|
42
|
-
};
|
|
33
|
+
applicable_to?: ApplicableToResultList;
|
|
43
34
|
campaign?: string;
|
|
44
35
|
campaign_id?: string;
|
|
45
36
|
metadata?: Record<string, any>;
|
|
@@ -62,5 +53,20 @@ export interface ValidationsValidateVoucherResponse {
|
|
|
62
53
|
};
|
|
63
54
|
tracking_id: string;
|
|
64
55
|
}
|
|
56
|
+
export interface ValidationsValidateStackableParams {
|
|
57
|
+
options?: StackableOptions;
|
|
58
|
+
redeemables: StackableRedeemableParams[];
|
|
59
|
+
session?: ValidationSessionParams;
|
|
60
|
+
order?: OrdersCreate;
|
|
61
|
+
customer?: CustomersCreateBody;
|
|
62
|
+
metadata?: Record<string, any>;
|
|
63
|
+
}
|
|
64
|
+
export interface ValidationValidateStackableResponse {
|
|
65
|
+
valid: boolean;
|
|
66
|
+
tracking_id?: string;
|
|
67
|
+
session?: ValidationSessionResponse;
|
|
68
|
+
order?: OrdersCreateResponse;
|
|
69
|
+
redeemables?: StackableRedeemableResponse[];
|
|
70
|
+
}
|
|
65
71
|
export declare type ValidationsValidateCode = PromotionsValidateParams;
|
|
66
72
|
export declare type ValidationsValidateContext = ValidationsValidateVoucherParams;
|
package/dist/types/Vouchers.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OrdersGetResponse } from './Orders';
|
|
2
2
|
import { SimpleCustomer } from './Customers';
|
|
3
|
+
import { DiscountUnit, DiscountAmount, DiscountPercent } from './DiscountVoucher';
|
|
3
4
|
export declare type VoucherType = 'GIFT' | 'DISCOUNT' | 'LOYALTY_CARD' | 'LUCKY_DRAW';
|
|
4
5
|
export interface SimpleVoucher {
|
|
5
6
|
code_config?: {
|
|
@@ -20,21 +21,6 @@ export interface SimpleVoucher {
|
|
|
20
21
|
quantity: number;
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
|
-
export interface DiscountUnit {
|
|
24
|
-
type?: 'UNIT';
|
|
25
|
-
unit_off?: number;
|
|
26
|
-
effect?: 'ADD_MISSING_ITEMS' | 'ADD_NEW_ITEMS';
|
|
27
|
-
unit_type?: string;
|
|
28
|
-
}
|
|
29
|
-
export interface DiscountAmount {
|
|
30
|
-
type?: 'AMOUNT';
|
|
31
|
-
amount_off?: number;
|
|
32
|
-
}
|
|
33
|
-
export interface DiscountPercent {
|
|
34
|
-
type?: 'PERCENT';
|
|
35
|
-
percent_off?: number;
|
|
36
|
-
amount_limit?: number;
|
|
37
|
-
}
|
|
38
24
|
export interface VouchersResponse {
|
|
39
25
|
id: string;
|
|
40
26
|
code: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -17,3 +17,8 @@ export * from './Exports';
|
|
|
17
17
|
export * from './Orders';
|
|
18
18
|
export * from './Consents';
|
|
19
19
|
export * from './Events';
|
|
20
|
+
export * from './Stackable';
|
|
21
|
+
export * from './Gift';
|
|
22
|
+
export * from './ValidateSession';
|
|
23
|
+
export * from './ApplicableTo';
|
|
24
|
+
export * from './DiscountVoucher';
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import Qs from 'qs';
|
|
3
3
|
|
|
4
|
+
var DiscountVouchersTypesEnum;
|
|
5
|
+
|
|
6
|
+
(function (DiscountVouchersTypesEnum) {
|
|
7
|
+
DiscountVouchersTypesEnum["AMOUNT"] = "AMOUNT";
|
|
8
|
+
DiscountVouchersTypesEnum["PERCENT"] = "PERCENT";
|
|
9
|
+
DiscountVouchersTypesEnum["UNIT"] = "UNIT";
|
|
10
|
+
DiscountVouchersTypesEnum["FIXED"] = "FIXED";
|
|
11
|
+
})(DiscountVouchersTypesEnum || (DiscountVouchersTypesEnum = {}));
|
|
12
|
+
|
|
4
13
|
/**
|
|
5
14
|
* @internal
|
|
6
15
|
*/
|
|
@@ -75,6 +84,9 @@ class RequestController {
|
|
|
75
84
|
async post(path, body, params, headers) {
|
|
76
85
|
const response = await this.request.post(path, body, {
|
|
77
86
|
params,
|
|
87
|
+
paramsSerializer: function (params) {
|
|
88
|
+
return Qs.stringify(params);
|
|
89
|
+
},
|
|
78
90
|
headers
|
|
79
91
|
});
|
|
80
92
|
return response.data;
|
|
@@ -499,6 +511,14 @@ class Validations {
|
|
|
499
511
|
|
|
500
512
|
return this.validateVoucher(code, context);
|
|
501
513
|
}
|
|
514
|
+
/**
|
|
515
|
+
* @see https://docs.voucherify.io/reference/validate-stacked-discounts-1
|
|
516
|
+
*/
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
validateStackable(params) {
|
|
520
|
+
return this.client.post(`/validations`, params);
|
|
521
|
+
}
|
|
502
522
|
|
|
503
523
|
}
|
|
504
524
|
|
|
@@ -515,6 +535,14 @@ class Redemptions {
|
|
|
515
535
|
redeem(code, body = {}) {
|
|
516
536
|
return this.client.post(`/vouchers/${encode(code)}/redemption`, body);
|
|
517
537
|
}
|
|
538
|
+
/**
|
|
539
|
+
* @see https://docs.voucherify.io/reference/redeem-stacked-discounts
|
|
540
|
+
*/
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
redeemStackable(params) {
|
|
544
|
+
return this.client.post(`/redemptions`, params);
|
|
545
|
+
}
|
|
518
546
|
/**
|
|
519
547
|
* @see https://docs.voucherify.io/reference/get-redemption
|
|
520
548
|
*/
|
|
@@ -567,6 +595,15 @@ class Redemptions {
|
|
|
567
595
|
|
|
568
596
|
return this.client.post(`/redemptions/${encode(redemptionId)}/rollback`, payload, queryParams);
|
|
569
597
|
}
|
|
598
|
+
/**
|
|
599
|
+
* @see https://docs.voucherify.io/reference/rollback-stackable-redemptions
|
|
600
|
+
* Types of params and queryParams WILL be changed in future - please do not depend on it!
|
|
601
|
+
*/
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
rollbackStackable(parentRedemptionId, params, queryParams) {
|
|
605
|
+
return this.client.post(`/redemptions/${encode(parentRedemptionId)}/rollbacks`, params, queryParams);
|
|
606
|
+
}
|
|
570
607
|
|
|
571
608
|
}
|
|
572
609
|
|
|
@@ -646,8 +683,8 @@ class Promotions {
|
|
|
646
683
|
*/
|
|
647
684
|
|
|
648
685
|
|
|
649
|
-
validate(params) {
|
|
650
|
-
return this.client.post('/promotions/validation', params);
|
|
686
|
+
validate(body, params) {
|
|
687
|
+
return this.client.post('/promotions/validation', body, params);
|
|
651
688
|
}
|
|
652
689
|
|
|
653
690
|
}
|
|
@@ -747,6 +784,14 @@ class Customers {
|
|
|
747
784
|
updateConsents(idOrSourceId, consents) {
|
|
748
785
|
return this.client.put(`/customers/${encode(idOrSourceId)}/consents`, consents);
|
|
749
786
|
}
|
|
787
|
+
/**
|
|
788
|
+
* @see https://docs.voucherify.io/reference/get-customer-activities
|
|
789
|
+
*/
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
listActivities(customerId, params) {
|
|
793
|
+
return this.client.get(`/customers/${encode(customerId)}/activities`, params);
|
|
794
|
+
}
|
|
750
795
|
|
|
751
796
|
}
|
|
752
797
|
|
|
@@ -1290,7 +1335,7 @@ function VoucherifyServerSide(options) {
|
|
|
1290
1335
|
let headers = {
|
|
1291
1336
|
'X-App-Id': options.applicationId,
|
|
1292
1337
|
'X-App-Token': options.secretKey,
|
|
1293
|
-
'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.0.
|
|
1338
|
+
'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.0.4"}`,
|
|
1294
1339
|
'Content-Type': 'application/json'
|
|
1295
1340
|
};
|
|
1296
1341
|
|
|
@@ -1505,6 +1550,22 @@ class ClientSide {
|
|
|
1505
1550
|
updateConsents(idOrSourceId, consents) {
|
|
1506
1551
|
return this.client.put(`/customers/${encode(idOrSourceId)}/consents`, consents);
|
|
1507
1552
|
}
|
|
1553
|
+
/**
|
|
1554
|
+
* @see https://docs.voucherify.io/reference/validate-stackable-discounts-client-side
|
|
1555
|
+
*/
|
|
1556
|
+
|
|
1557
|
+
|
|
1558
|
+
validateStackable(params) {
|
|
1559
|
+
return this.client.post(`/validations`, params);
|
|
1560
|
+
}
|
|
1561
|
+
/**
|
|
1562
|
+
* @see https://docs.voucherify.io/reference/redeem-stackable-discounts-client-side
|
|
1563
|
+
*/
|
|
1564
|
+
|
|
1565
|
+
|
|
1566
|
+
redeemStackable(params) {
|
|
1567
|
+
return this.client.post(`/redemptions`, params);
|
|
1568
|
+
}
|
|
1508
1569
|
|
|
1509
1570
|
}
|
|
1510
1571
|
|
|
@@ -1519,7 +1580,7 @@ function VoucherifyClientSide(options) {
|
|
|
1519
1580
|
let headers = {
|
|
1520
1581
|
'X-Client-Application-Id': options.clientApplicationId,
|
|
1521
1582
|
'X-Client-Token': options.clientSecretKey,
|
|
1522
|
-
'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.0.
|
|
1583
|
+
'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.0.4"}`
|
|
1523
1584
|
};
|
|
1524
1585
|
|
|
1525
1586
|
if (environment().startsWith('Node')) {
|
|
@@ -1539,5 +1600,5 @@ function VoucherifyClientSide(options) {
|
|
|
1539
1600
|
return new ClientSide(client, options.trackingId);
|
|
1540
1601
|
}
|
|
1541
1602
|
|
|
1542
|
-
export { VoucherifyClientSide, VoucherifyServerSide };
|
|
1603
|
+
export { DiscountVouchersTypesEnum, VoucherifyClientSide, VoucherifyServerSide };
|
|
1543
1604
|
//# sourceMappingURL=voucherifysdk.esm.js.map
|