@voucherify/sdk 2.0.8 → 2.0.11

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,25 @@
1
1
  # @voucherify/sdk
2
2
 
3
+ ## 2.0.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [`ae6110b`](https://github.com/voucherifyio/voucherify-js-sdk/commit/ae6110b1ec8022c80a8f05f16e5c9de0e6cae180) [#137](https://github.com/voucherifyio/voucherify-js-sdk/pull/137) Thanks [@darekg11](https://github.com/darekg11)! - Added support for orders import API
8
+
9
+ ## 2.0.10
10
+
11
+ ### Patch Changes
12
+
13
+ - [`e03db27`](https://github.com/voucherifyio/voucherify-js-sdk/commit/e03db276226a579e7d886a8acb5db58b703a6989) [#136](https://github.com/voucherifyio/voucherify-js-sdk/pull/136) Thanks [@darekg11](https://github.com/darekg11)! - Added documentation links to MetadataSchemas API methods
14
+
15
+ * [`a8557d1`](https://github.com/voucherifyio/voucherify-js-sdk/commit/a8557d1c70f0732c6996175d3b1e917c29986cee) [#134](https://github.com/voucherifyio/voucherify-js-sdk/pull/134) Thanks [@salzhrani](https://github.com/salzhrani)! - add metadata property to ProductsCreateResponse
16
+
17
+ ## 2.0.9
18
+
19
+ ### Patch Changes
20
+
21
+ - [`e52b787`](https://github.com/voucherifyio/voucherify-js-sdk/commit/e52b787f48a5aa763d2aaa61b3d28a701548d3cc) [#131](https://github.com/voucherifyio/voucherify-js-sdk/pull/131) Thanks [@tomek-lochmanczyk-rspective](https://github.com/tomek-lochmanczyk-rspective)! - Add function which return "Retry-After" header from response. The purpose is to get information how long it's needed to wait until new requests can be made, when api limits are reached. This ddition is backward compatible so no changes are needed to be made in older code
22
+
3
23
  ## 2.0.8
4
24
 
5
25
  ### Patch Changes
package/README.md CHANGED
@@ -645,6 +645,7 @@ Methods are provided within `client.orders.*` namespace.
645
645
  - [Get Order](#get-order)
646
646
  - [Update Order](#update-order)
647
647
  - [List Orders](#list-orders)
648
+ - [Import Orders](#import-orders)
648
649
 
649
650
  #### [Create Order](https://docs.voucherify.io/reference/create-order)
650
651
 
@@ -675,6 +676,11 @@ client.orders.list()
675
676
  client.orders.list(params)
676
677
  ```
677
678
 
679
+ #### [Import Orders](https://docs.voucherify.io/reference/import-orders)
680
+ ```javascript
681
+ client.orders.import(orders)
682
+ ```
683
+
678
684
  ---
679
685
 
680
686
  ### Products
@@ -1155,13 +1161,14 @@ Methods are provided within `client.apiLimitsHandler.*` namespace.
1155
1161
  - [Are Limits Available](#are-limits-available)
1156
1162
  - [Get Rate Limit](#get-rate-limit)
1157
1163
  - [Get Rate Limit Remaining](#get-rate-limit-remaining)
1164
+ - [Get Retry After](#get-retry-after)
1158
1165
 
1159
1166
  #### Are Limits Available
1160
1167
  ```javascript
1161
1168
  client.apiLimitsHandler.areLimitsAvailable()
1162
1169
  ```
1163
1170
 
1164
- This method should be called each time beforehand [Get Rate Limit](#get-rate-limit) or [Get Rate Limit Remaining](#get-rate-limit-remaining) to ensure limit data are available.
1171
+ This method should be called each time beforehand [Get Rate Limit](#get-rate-limit) or [Get Rate Limit Remaining](#get-rate-limit-remaining) or [Get Retry After](#get-retry-after) to ensure limit data are available.
1165
1172
 
1166
1173
  #### Get Rate Limit
1167
1174
  ```javascript
@@ -1177,6 +1184,13 @@ if(client.apiLimitsHandler.areLimitsAvailable()){
1177
1184
  }
1178
1185
  ```
1179
1186
 
1187
+ #### Get Retry After
1188
+ ```javascript
1189
+ if(client.apiLimitsHandler.areLimitsAvailable()){
1190
+ client.apiLimitsHandler.getRetryAfter()
1191
+ }
1192
+ ```
1193
+
1180
1194
  ---
1181
1195
 
1182
1196
  # 💅 Client Side
@@ -6,4 +6,5 @@ export declare class ApiLimitsHandler {
6
6
  areLimitsAvailable(): boolean;
7
7
  getRateLimit(): number;
8
8
  getRateLimitRemaining(): number;
9
+ getRetryAfter(): number;
9
10
  }
@@ -3,6 +3,12 @@ import type { RequestController } from './RequestController';
3
3
  export declare class MetadataSchemas {
4
4
  private client;
5
5
  constructor(client: RequestController);
6
+ /**
7
+ * @see https://docs.voucherify.io/reference/list-metadata-schemas
8
+ */
6
9
  list(): Promise<T.MetadataSchemasListResponse>;
10
+ /**
11
+ * @see https://docs.voucherify.io/reference/get-metadata-schema
12
+ */
7
13
  get(schemaName: string): Promise<T.MetadataSchema>;
8
14
  }
package/dist/Orders.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as T from './types/Orders';
2
+ import * as AAT from './types/AsyncActions';
2
3
  import type { RequestController } from './RequestController';
3
4
  export declare class Orders {
4
5
  private client;
@@ -19,4 +20,8 @@ export declare class Orders {
19
20
  * @see https://docs.voucherify.io/reference/list-orders
20
21
  */
21
22
  list(params?: T.OrdersListParams): Promise<T.OrdersListResponse>;
23
+ /**
24
+ * @see https://docs.voucherify.io/reference/import-orders
25
+ */
26
+ import(orders: T.OrdersCreate[]): Promise<AAT.AsyncActionCreateResponse>;
22
27
  }
@@ -15,4 +15,7 @@ export interface AsyncActionsListResponse {
15
15
  data_ref: 'async_actions';
16
16
  async_actions: Omit<AsyncActionsResponse, 'result'>[];
17
17
  }
18
+ export interface AsyncActionCreateResponse {
19
+ async_action_id: string;
20
+ }
18
21
  export declare type AsyncActionsGetResponse = AsyncActionsResponse;
@@ -22,6 +22,7 @@ export interface ProductsCreateResponse {
22
22
  attributes?: string[];
23
23
  created_at: string;
24
24
  image_url?: string;
25
+ metadata?: Record<string, any>;
25
26
  }
26
27
  export declare type ProductsGetResponse = ProductsCreateResponse & ProductsGetResponseSkus;
27
28
  export declare type ProductsUpdate = {
@@ -869,6 +869,14 @@ class Orders {
869
869
  list(params = {}) {
870
870
  return this.client.get('/orders', params);
871
871
  }
872
+ /**
873
+ * @see https://docs.voucherify.io/reference/import-orders
874
+ */
875
+
876
+
877
+ import(orders) {
878
+ return this.client.post('/orders/import', orders);
879
+ }
872
880
 
873
881
  }
874
882
 
@@ -1356,6 +1364,13 @@ class ApiLimitsHandler {
1356
1364
  return parseInt(rateLimitRemaining, 10);
1357
1365
  }
1358
1366
 
1367
+ getRetryAfter() {
1368
+ var _this$getLastResponse3;
1369
+
1370
+ const retryAfter = (_this$getLastResponse3 = this.getLastResponseHeadersFromController()['retry-after']) != null ? _this$getLastResponse3 : 0;
1371
+ return parseInt(retryAfter, 10);
1372
+ }
1373
+
1359
1374
  }
1360
1375
 
1361
1376
  class MetadataSchemas {
@@ -1363,10 +1378,18 @@ class MetadataSchemas {
1363
1378
  this.client = void 0;
1364
1379
  this.client = client;
1365
1380
  }
1381
+ /**
1382
+ * @see https://docs.voucherify.io/reference/list-metadata-schemas
1383
+ */
1384
+
1366
1385
 
1367
1386
  list() {
1368
1387
  return this.client.get('/metadata-schemas');
1369
1388
  }
1389
+ /**
1390
+ * @see https://docs.voucherify.io/reference/get-metadata-schema
1391
+ */
1392
+
1370
1393
 
1371
1394
  get(schemaName) {
1372
1395
  return this.client.get(`/metadata-schemas/${encode(schemaName)}`);
@@ -1404,7 +1427,7 @@ function VoucherifyServerSide(options) {
1404
1427
  let headers = {
1405
1428
  'X-App-Id': options.applicationId,
1406
1429
  'X-App-Token': options.secretKey,
1407
- 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.0.8"}`,
1430
+ 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.0.11"}`,
1408
1431
  'Content-Type': 'application/json'
1409
1432
  };
1410
1433
 
@@ -1653,7 +1676,7 @@ function VoucherifyClientSide(options) {
1653
1676
  let headers = {
1654
1677
  'X-Client-Application-Id': options.clientApplicationId,
1655
1678
  'X-Client-Token': options.clientSecretKey,
1656
- 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.0.8"}`
1679
+ 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.0.11"}`
1657
1680
  };
1658
1681
 
1659
1682
  if (environment().startsWith('Node')) {