@voucherify/sdk 2.0.5 → 2.0.8
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 +20 -0
- package/dist/MetadataSchemas.d.ts +8 -0
- package/dist/VoucherifyServerSide.d.ts +2 -0
- package/dist/types/DiscountVoucher.d.ts +2 -0
- package/dist/types/MetadataSchemas.d.ts +33 -0
- package/dist/types/Orders.d.ts +2 -0
- package/dist/types/Validations.d.ts +5 -0
- package/dist/voucherifysdk.esm.js +23 -3
- package/dist/voucherifysdk.esm.js.map +1 -1
- package/dist/voucherifysdk.umd.development.js +23 -3
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @voucherify/sdk
|
|
2
2
|
|
|
3
|
+
## 2.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`e965f61`](https://github.com/voucherifyio/voucherify-js-sdk/commit/e965f615ada65812553a0e5df4409ccf6e02dae1) [#129](https://github.com/voucherifyio/voucherify-js-sdk/pull/129) Thanks [@Irene350](https://github.com/Irene350)! - Adding missing discount amounts on order for validate voucher type response
|
|
8
|
+
|
|
9
|
+
## 2.0.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`7913a06`](https://github.com/voucherifyio/voucherify-js-sdk/commit/7913a06bb3ab6c79bcbfae8ddbff0bcc8329dd73) [#127](https://github.com/voucherifyio/voucherify-js-sdk/pull/127) Thanks [@Irene350](https://github.com/Irene350)! - Improving Validate Voucher response type
|
|
14
|
+
|
|
15
|
+
## 2.0.6
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [`f8241b7`](https://github.com/voucherifyio/voucherify-js-sdk/commit/f8241b709097f53e29427ba4f4260073375ec91c) [#125](https://github.com/voucherifyio/voucherify-js-sdk/pull/125) Thanks [@darekg11](https://github.com/darekg11)! - Added support for metadata-schemas API. Allowing to list all metadata schemas in project or retrieve single one via get method by providing schema name
|
|
20
|
+
|
|
3
21
|
## 2.0.5
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -67,6 +67,8 @@ Server side:
|
|
|
67
67
|
|
|
|
68
68
|
<a href="#async-actions">Async Actions</a>
|
|
69
69
|
|
|
|
70
|
+
<a href="#metadata-schemas">Metadata Schemas</a>
|
|
71
|
+
|
|
|
70
72
|
<a href="#api-limits-handler">Api Limits Handler</a>
|
|
71
73
|
</p>
|
|
72
74
|
|
|
@@ -1110,6 +1112,7 @@ Check [customer object](https://docs.voucherify.io/v1/reference#the-customer-obj
|
|
|
1110
1112
|
|
|
1111
1113
|
|
|
1112
1114
|
### Async Actions
|
|
1115
|
+
|
|
1113
1116
|
Methods are provided within `client.asyncActions.*` namespace.
|
|
1114
1117
|
|
|
1115
1118
|
- [Get Async Action](#get-async-action)
|
|
@@ -1128,6 +1131,23 @@ client.asyncActions.list(params)
|
|
|
1128
1131
|
|
|
1129
1132
|
---
|
|
1130
1133
|
|
|
1134
|
+
### Metadata Schemas
|
|
1135
|
+
|
|
1136
|
+
Methods are provided within `client.metadataSchemas.*` namespace.
|
|
1137
|
+
|
|
1138
|
+
- [List Metadata Schemas](#list-metadata-schemas)
|
|
1139
|
+
- [Get Metadata Schema by schema name](#get-metadata-schema-by-schema-name)
|
|
1140
|
+
|
|
1141
|
+
#### List Metadata Schemas
|
|
1142
|
+
```javascript
|
|
1143
|
+
client.metadataSchemas.list()
|
|
1144
|
+
```
|
|
1145
|
+
|
|
1146
|
+
#### Get Metadata Schema by schema name
|
|
1147
|
+
```javascript
|
|
1148
|
+
client.metadataSchemas.get(schemaName)
|
|
1149
|
+
```
|
|
1150
|
+
|
|
1131
1151
|
### Api Limits Handler
|
|
1132
1152
|
|
|
1133
1153
|
Methods are provided within `client.apiLimitsHandler.*` namespace.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as T from './types/MetadataSchemas';
|
|
2
|
+
import type { RequestController } from './RequestController';
|
|
3
|
+
export declare class MetadataSchemas {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: RequestController);
|
|
6
|
+
list(): Promise<T.MetadataSchemasListResponse>;
|
|
7
|
+
get(schemaName: string): Promise<T.MetadataSchema>;
|
|
8
|
+
}
|
|
@@ -15,6 +15,7 @@ import { Loyalties } from './Loyalties';
|
|
|
15
15
|
import { ValidationRules } from './ValidationRules';
|
|
16
16
|
import { Segments } from './Segments';
|
|
17
17
|
import { ApiLimitsHandler } from './ApiLimitsHandler';
|
|
18
|
+
import { MetadataSchemas } from './MetadataSchemas';
|
|
18
19
|
export interface VoucherifyServerSideOptions {
|
|
19
20
|
/**
|
|
20
21
|
* Optionally, you can add `apiUrl` to the client options if you want to use Voucherify running in a specific region.
|
|
@@ -110,4 +111,5 @@ export declare function VoucherifyServerSide(options: VoucherifyServerSideOption
|
|
|
110
111
|
events: Events;
|
|
111
112
|
asyncActions: AsyncActions;
|
|
112
113
|
apiLimitsHandler: ApiLimitsHandler;
|
|
114
|
+
metadataSchemas: MetadataSchemas;
|
|
113
115
|
};
|
|
@@ -19,9 +19,11 @@ export interface DiscountUnit {
|
|
|
19
19
|
export interface DiscountAmount {
|
|
20
20
|
type?: DiscountVouchersTypesEnum.AMOUNT;
|
|
21
21
|
amount_off?: number;
|
|
22
|
+
effect?: DiscountAmountVouchersEffectTypes;
|
|
22
23
|
}
|
|
23
24
|
export interface DiscountPercent {
|
|
24
25
|
type?: DiscountVouchersTypesEnum.PERCENT;
|
|
25
26
|
percent_off?: number;
|
|
26
27
|
amount_limit?: number;
|
|
28
|
+
effect?: DiscountPercentVouchersEffectTypes;
|
|
27
29
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
interface MetadataSchemaProperty {
|
|
2
|
+
type: string;
|
|
3
|
+
array: boolean;
|
|
4
|
+
deleted?: boolean;
|
|
5
|
+
optional: boolean;
|
|
6
|
+
objectType?: string;
|
|
7
|
+
eq?: (string | number)[];
|
|
8
|
+
ne?: (string | number)[];
|
|
9
|
+
lt?: number;
|
|
10
|
+
lte?: number;
|
|
11
|
+
gt?: number;
|
|
12
|
+
gte?: number;
|
|
13
|
+
minLength?: number;
|
|
14
|
+
maxLength?: number;
|
|
15
|
+
exactLength?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface MetadataSchema {
|
|
18
|
+
id: string;
|
|
19
|
+
related_object: string;
|
|
20
|
+
properties: Record<string, MetadataSchemaProperty>;
|
|
21
|
+
allow_defined_only?: boolean;
|
|
22
|
+
created_at: string;
|
|
23
|
+
updated_at?: string;
|
|
24
|
+
object: 'metadata_schema';
|
|
25
|
+
}
|
|
26
|
+
export interface MetadataSchemasListResponse {
|
|
27
|
+
object: 'list';
|
|
28
|
+
total: number;
|
|
29
|
+
data_ref: 'schemas';
|
|
30
|
+
schemas: MetadataSchema[];
|
|
31
|
+
}
|
|
32
|
+
export declare type MetadataSchemasGetResponse = MetadataSchema;
|
|
33
|
+
export {};
|
package/dist/types/Orders.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export interface ValidationsValidateVoucherParams {
|
|
|
31
31
|
}
|
|
32
32
|
export interface ValidationsValidateVoucherResponse {
|
|
33
33
|
applicable_to?: ApplicableToResultList;
|
|
34
|
+
inapplicable_to?: ApplicableToResultList;
|
|
34
35
|
campaign?: string;
|
|
35
36
|
campaign_id?: string;
|
|
36
37
|
metadata?: Record<string, any>;
|
|
@@ -49,8 +50,12 @@ export interface ValidationsValidateVoucherResponse {
|
|
|
49
50
|
discount_amount: number;
|
|
50
51
|
total_discount_amount: number;
|
|
51
52
|
total_amount: number;
|
|
53
|
+
applied_discount_amount?: number;
|
|
54
|
+
total_applied_discount_amount?: number;
|
|
52
55
|
items?: OrdersItem[];
|
|
53
56
|
};
|
|
57
|
+
start_date?: string;
|
|
58
|
+
expiration_date?: string;
|
|
54
59
|
tracking_id: string;
|
|
55
60
|
}
|
|
56
61
|
export interface ValidationsValidateStackableParams {
|
|
@@ -1358,12 +1358,30 @@ class ApiLimitsHandler {
|
|
|
1358
1358
|
|
|
1359
1359
|
}
|
|
1360
1360
|
|
|
1361
|
+
class MetadataSchemas {
|
|
1362
|
+
constructor(client) {
|
|
1363
|
+
this.client = void 0;
|
|
1364
|
+
this.client = client;
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
list() {
|
|
1368
|
+
return this.client.get('/metadata-schemas');
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
get(schemaName) {
|
|
1372
|
+
return this.client.get(`/metadata-schemas/${encode(schemaName)}`);
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
// apiLimitsHandler: ApiLimitsHandler
|
|
1361
1378
|
// campaigns: Campaigns
|
|
1362
1379
|
// consents: Consents
|
|
1363
1380
|
// customers: Customers
|
|
1364
1381
|
// distributions: Distributions
|
|
1365
1382
|
// events: Events
|
|
1366
1383
|
// loyalties: Loyalties
|
|
1384
|
+
// metadataSchemas: MetadataSchemas
|
|
1367
1385
|
// orders: Orders
|
|
1368
1386
|
// products: Products
|
|
1369
1387
|
// promotions: Promotions
|
|
@@ -1386,7 +1404,7 @@ function VoucherifyServerSide(options) {
|
|
|
1386
1404
|
let headers = {
|
|
1387
1405
|
'X-App-Id': options.applicationId,
|
|
1388
1406
|
'X-App-Token': options.secretKey,
|
|
1389
|
-
'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.0.
|
|
1407
|
+
'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.0.8"}`,
|
|
1390
1408
|
'Content-Type': 'application/json'
|
|
1391
1409
|
};
|
|
1392
1410
|
|
|
@@ -1433,6 +1451,7 @@ function VoucherifyServerSide(options) {
|
|
|
1433
1451
|
const segments = new Segments(client);
|
|
1434
1452
|
const validationRules = new ValidationRules(client);
|
|
1435
1453
|
const apiLimitsHandler = new ApiLimitsHandler(client);
|
|
1454
|
+
const metadataSchemas = new MetadataSchemas(client);
|
|
1436
1455
|
return {
|
|
1437
1456
|
vouchers,
|
|
1438
1457
|
campaigns,
|
|
@@ -1450,7 +1469,8 @@ function VoucherifyServerSide(options) {
|
|
|
1450
1469
|
validationRules,
|
|
1451
1470
|
events,
|
|
1452
1471
|
asyncActions,
|
|
1453
|
-
apiLimitsHandler
|
|
1472
|
+
apiLimitsHandler,
|
|
1473
|
+
metadataSchemas
|
|
1454
1474
|
};
|
|
1455
1475
|
}
|
|
1456
1476
|
|
|
@@ -1633,7 +1653,7 @@ function VoucherifyClientSide(options) {
|
|
|
1633
1653
|
let headers = {
|
|
1634
1654
|
'X-Client-Application-Id': options.clientApplicationId,
|
|
1635
1655
|
'X-Client-Token': options.clientSecretKey,
|
|
1636
|
-
'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.0.
|
|
1656
|
+
'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.0.8"}`
|
|
1637
1657
|
};
|
|
1638
1658
|
|
|
1639
1659
|
if (environment().startsWith('Node')) {
|