@voucherify/sdk 2.0.8 → 2.0.9

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.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [`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
8
+
3
9
  ## 2.0.8
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -1155,13 +1155,14 @@ Methods are provided within `client.apiLimitsHandler.*` namespace.
1155
1155
  - [Are Limits Available](#are-limits-available)
1156
1156
  - [Get Rate Limit](#get-rate-limit)
1157
1157
  - [Get Rate Limit Remaining](#get-rate-limit-remaining)
1158
+ - [Get Retry After](#get-retry-after)
1158
1159
 
1159
1160
  #### Are Limits Available
1160
1161
  ```javascript
1161
1162
  client.apiLimitsHandler.areLimitsAvailable()
1162
1163
  ```
1163
1164
 
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.
1165
+ 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
1166
 
1166
1167
  #### Get Rate Limit
1167
1168
  ```javascript
@@ -1177,6 +1178,13 @@ if(client.apiLimitsHandler.areLimitsAvailable()){
1177
1178
  }
1178
1179
  ```
1179
1180
 
1181
+ #### Get Retry After
1182
+ ```javascript
1183
+ if(client.apiLimitsHandler.areLimitsAvailable()){
1184
+ client.apiLimitsHandler.getRetryAfter()
1185
+ }
1186
+ ```
1187
+
1180
1188
  ---
1181
1189
 
1182
1190
  # 💅 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
  }
@@ -1356,6 +1356,13 @@ class ApiLimitsHandler {
1356
1356
  return parseInt(rateLimitRemaining, 10);
1357
1357
  }
1358
1358
 
1359
+ getRetryAfter() {
1360
+ var _this$getLastResponse3;
1361
+
1362
+ const retryAfter = (_this$getLastResponse3 = this.getLastResponseHeadersFromController()['retry-after']) != null ? _this$getLastResponse3 : 0;
1363
+ return parseInt(retryAfter, 10);
1364
+ }
1365
+
1359
1366
  }
1360
1367
 
1361
1368
  class MetadataSchemas {
@@ -1404,7 +1411,7 @@ function VoucherifyServerSide(options) {
1404
1411
  let headers = {
1405
1412
  'X-App-Id': options.applicationId,
1406
1413
  'X-App-Token': options.secretKey,
1407
- 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.0.8"}`,
1414
+ 'X-Voucherify-Channel': options.channel || `${environment()}-SDK-v${"2.0.9"}`,
1408
1415
  'Content-Type': 'application/json'
1409
1416
  };
1410
1417
 
@@ -1653,7 +1660,7 @@ function VoucherifyClientSide(options) {
1653
1660
  let headers = {
1654
1661
  'X-Client-Application-Id': options.clientApplicationId,
1655
1662
  'X-Client-Token': options.clientSecretKey,
1656
- 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.0.8"}`
1663
+ 'X-Voucherify-Channel': `${environment()}-ClientSide-SDK-v${"2.0.9"}`
1657
1664
  };
1658
1665
 
1659
1666
  if (environment().startsWith('Node')) {