@voucherify/sdk 2.0.5 → 2.0.6

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @voucherify/sdk
2
2
 
3
+ ## 2.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`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
8
+
3
9
  ## 2.0.5
4
10
 
5
11
  ### 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
  };
@@ -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 {};
@@ -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.5"}`,
1407
+ 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.0.6"}`,
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.5"}`
1656
+ 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.0.6"}`
1637
1657
  };
1638
1658
 
1639
1659
  if (environment().startsWith('Node')) {