doboxa-js 1.0.2 → 1.0.3
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/README.md +79 -72
- package/dist/{chunk-36DDSV5T.mjs → chunk-WGEOQ35B.mjs} +43 -23
- package/dist/chunk-WGEOQ35B.mjs.map +1 -0
- package/dist/client-BfIS6ja2.d.mts +2759 -0
- package/dist/client-BfIS6ja2.d.ts +2759 -0
- package/dist/client.d.mts +1 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +42 -22
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +1 -1
- package/dist/errors-CtijMwu-.d.mts +161 -0
- package/dist/errors-CtijMwu-.d.ts +161 -0
- package/dist/errors.d.mts +1 -0
- package/dist/errors.d.ts +1 -0
- package/dist/index.d.mts +153 -0
- package/dist/index.d.ts +153 -0
- package/dist/index.js +42 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/models.d.mts +2 -0
- package/dist/models.d.ts +2 -0
- package/package.json +1 -1
- package/dist/chunk-36DDSV5T.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -638,26 +638,24 @@ var HTTPClient = class {
|
|
|
638
638
|
if (!accessToken || this.tokenManager.isTokenExpired()) {
|
|
639
639
|
if (this.onTokenRefresh) {
|
|
640
640
|
const refreshToken = this.tokenManager.getRefreshToken();
|
|
641
|
-
if (
|
|
642
|
-
|
|
641
|
+
if (refreshToken) {
|
|
642
|
+
let refreshPromise = this.tokenManager.getRefreshPromise();
|
|
643
|
+
if (!refreshPromise) {
|
|
644
|
+
refreshPromise = this.onTokenRefresh(refreshToken);
|
|
645
|
+
this.tokenManager.setRefreshPromise(refreshPromise);
|
|
646
|
+
}
|
|
647
|
+
try {
|
|
648
|
+
accessToken = yield refreshPromise;
|
|
649
|
+
} finally {
|
|
650
|
+
this.tokenManager.setRefreshPromise(null);
|
|
651
|
+
}
|
|
643
652
|
}
|
|
644
|
-
let refreshPromise = this.tokenManager.getRefreshPromise();
|
|
645
|
-
if (!refreshPromise) {
|
|
646
|
-
refreshPromise = this.onTokenRefresh(refreshToken);
|
|
647
|
-
this.tokenManager.setRefreshPromise(refreshPromise);
|
|
648
|
-
}
|
|
649
|
-
try {
|
|
650
|
-
accessToken = yield refreshPromise;
|
|
651
|
-
} finally {
|
|
652
|
-
this.tokenManager.setRefreshPromise(null);
|
|
653
|
-
}
|
|
654
|
-
} else {
|
|
655
|
-
throw new DoboxaAuthenticationError("No access token available");
|
|
656
653
|
}
|
|
657
654
|
}
|
|
658
655
|
const headers = new Headers(options.headers);
|
|
659
656
|
headers.set("Content-Type", "application/json");
|
|
660
657
|
headers.set("Authorization", `Bearer ${accessToken}`);
|
|
658
|
+
console.log("url", url);
|
|
661
659
|
const response = yield fetch(url, __spreadProps(__spreadValues({}, options), {
|
|
662
660
|
headers
|
|
663
661
|
}));
|
|
@@ -3414,7 +3412,7 @@ var UsersResource = class {
|
|
|
3414
3412
|
// src/client.ts
|
|
3415
3413
|
var Doboxa = class {
|
|
3416
3414
|
constructor(config = {}) {
|
|
3417
|
-
const baseURL = config.baseURL || getBaseURL() || "
|
|
3415
|
+
const baseURL = config.baseURL || getBaseURL() || "https://pl.doboxa.biz";
|
|
3418
3416
|
this.tokenManager = new TokenManager();
|
|
3419
3417
|
if (config.apiKey) {
|
|
3420
3418
|
this.tokenManager.setTokens(config.apiKey, "", 3600);
|
|
@@ -3440,20 +3438,42 @@ var Doboxa = class {
|
|
|
3440
3438
|
baseURL,
|
|
3441
3439
|
tokenManager: this.tokenManager,
|
|
3442
3440
|
onTokenRefresh: (refreshToken) => __async(this, null, function* () {
|
|
3443
|
-
const tempAuth = new AuthenticationResource(
|
|
3441
|
+
const tempAuth = new AuthenticationResource(
|
|
3442
|
+
tempHttpClient,
|
|
3443
|
+
this.tokenManager
|
|
3444
|
+
);
|
|
3444
3445
|
const response = yield tempAuth.refreshToken(refreshToken);
|
|
3445
|
-
this.tokenManager.setTokens(
|
|
3446
|
+
this.tokenManager.setTokens(
|
|
3447
|
+
response.token,
|
|
3448
|
+
response.refresh_token,
|
|
3449
|
+
3600
|
|
3450
|
+
);
|
|
3446
3451
|
return response.token;
|
|
3447
3452
|
})
|
|
3448
3453
|
});
|
|
3449
|
-
this.authentication = new AuthenticationResource(
|
|
3454
|
+
this.authentication = new AuthenticationResource(
|
|
3455
|
+
this.httpClient,
|
|
3456
|
+
this.tokenManager
|
|
3457
|
+
);
|
|
3450
3458
|
this.orders = new OrdersResource(this.httpClient, this.config);
|
|
3451
3459
|
this.invoices = new InvoicesResource(this.httpClient, this.config);
|
|
3452
3460
|
this.clients = new ClientsResource(this.httpClient, this.config);
|
|
3453
|
-
this.discountCodes = new DiscountCodesResource(
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3461
|
+
this.discountCodes = new DiscountCodesResource(
|
|
3462
|
+
this.httpClient,
|
|
3463
|
+
this.config
|
|
3464
|
+
);
|
|
3465
|
+
this.trackingNumbers = new TrackingNumbersResource(
|
|
3466
|
+
this.httpClient,
|
|
3467
|
+
this.config
|
|
3468
|
+
);
|
|
3469
|
+
this.orderComments = new OrderCommentsResource(
|
|
3470
|
+
this.httpClient,
|
|
3471
|
+
this.config
|
|
3472
|
+
);
|
|
3473
|
+
this.orderStatusChanges = new OrderStatusChangesResource(
|
|
3474
|
+
this.httpClient,
|
|
3475
|
+
this.config
|
|
3476
|
+
);
|
|
3457
3477
|
this.users = new UsersResource(this.httpClient, this.config);
|
|
3458
3478
|
}
|
|
3459
3479
|
};
|