@djust-b2b/djust-front-sdk 2.5.6 → 2.6.0
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/lib/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare const DjustSDK: {
|
|
|
27
27
|
updateCommercialOrderBillingInformation({ orderId, billingAddressId, }: import("./interfaces").UpdateCommercialOrderBillingInformationParameters): Promise<void>;
|
|
28
28
|
setCommercialOrderStatusAsCreated({ orderId, paymentInfo, }: import("./interfaces").SetCommercialOrderStatusAsCreatedParameters): Promise<void>;
|
|
29
29
|
setCommercialOrderStatusAsOnHold({ orderId, }: import("./interfaces").SetCommercialOrderStatusAsOnHoldParameters): Promise<void>;
|
|
30
|
+
syncCommercialOrder(orderId: string): Promise<void>;
|
|
30
31
|
getCommercialOrderPaymentPageUrl({ orderId, paymentOption, paymentProvider, }: import("./interfaces").GetCommercialOrderPaymentPageUrlParameters): Promise<string>;
|
|
31
32
|
createCommercialOrderPreauthorization({ orderId, paymentProvider, authorId, browserInfo, ipAddress, paymentCardInfo, }: import("./interfaces").CreateCommercialOrderPreauthorizationParameters): Promise<import("./interfaces").CreateCommercialOrderPreauthorizationResponse>;
|
|
32
33
|
updateCommercialOrderShippingAddress({ orderId, shippingAddressId, }: import("./interfaces").UpdateCommercialOrderShippingAddressParameters): Promise<void>;
|
|
@@ -303,6 +303,30 @@ export declare function setCommercialOrderStatusAsCreated({ orderId, paymentInfo
|
|
|
303
303
|
* @returns {Promise<void>} A promise resolving when the commercial order is set to ON HOLD.
|
|
304
304
|
*/
|
|
305
305
|
export declare function setCommercialOrderStatusAsOnHold({ orderId, }: SetCommercialOrderStatusAsOnHoldParameters): Promise<void>;
|
|
306
|
+
/**
|
|
307
|
+
* 🚚 Sync commercial order (Real-Time Pricing).
|
|
308
|
+
*
|
|
309
|
+
* This endpoint triggers the synchronization of a commercial order for
|
|
310
|
+
* real time pricing calculation. The `orderId` parameter is required.
|
|
311
|
+
*
|
|
312
|
+
* 🛠 Endpoint: `PUT /v1/shop/commercial-orders/${orderId}/sync`
|
|
313
|
+
*
|
|
314
|
+
* | Parameter | Type | Required | Description |
|
|
315
|
+
* |-----------|----------|----------|-----------------------------------------|
|
|
316
|
+
* | `orderId` | `string` | ✅ | The commercial order identifier to sync |
|
|
317
|
+
*
|
|
318
|
+
* 📤 Returns:
|
|
319
|
+
* A `Promise<void>` resolving when the sync has been triggered. No body is expected in the request.
|
|
320
|
+
*
|
|
321
|
+
* 🛠 Example usage:
|
|
322
|
+
* ```ts
|
|
323
|
+
* await syncCommercialOrder("commercialOrder1");
|
|
324
|
+
* ```
|
|
325
|
+
*
|
|
326
|
+
* @param {string} orderId - The ID of the commercial order to synchronize
|
|
327
|
+
* @returns {Promise<void>} A promise resolving when the synchronization is triggered
|
|
328
|
+
*/
|
|
329
|
+
export declare function syncCommercialOrder(orderId: string): Promise<void>;
|
|
306
330
|
/**
|
|
307
331
|
* 🚚 Gets payment page url for a specific order.
|
|
308
332
|
*
|
|
@@ -9,6 +9,7 @@ exports.createCommercialOrderCardRegistration = createCommercialOrderCardRegistr
|
|
|
9
9
|
exports.updateCommercialOrderBillingInformation = updateCommercialOrderBillingInformation;
|
|
10
10
|
exports.setCommercialOrderStatusAsCreated = setCommercialOrderStatusAsCreated;
|
|
11
11
|
exports.setCommercialOrderStatusAsOnHold = setCommercialOrderStatusAsOnHold;
|
|
12
|
+
exports.syncCommercialOrder = syncCommercialOrder;
|
|
12
13
|
exports.getCommercialOrderPaymentPageUrl = getCommercialOrderPaymentPageUrl;
|
|
13
14
|
exports.createCommercialOrderPreauthorization = createCommercialOrderPreauthorization;
|
|
14
15
|
exports.updateCommercialOrderShippingAddress = updateCommercialOrderShippingAddress;
|
|
@@ -426,6 +427,36 @@ async function setCommercialOrderStatusAsOnHold({ orderId, }) {
|
|
|
426
427
|
path: `/v1/shop/commercial-orders/${orderId}/hold`,
|
|
427
428
|
});
|
|
428
429
|
}
|
|
430
|
+
/**
|
|
431
|
+
* 🚚 Sync commercial order (Real-Time Pricing).
|
|
432
|
+
*
|
|
433
|
+
* This endpoint triggers the synchronization of a commercial order for
|
|
434
|
+
* real time pricing calculation. The `orderId` parameter is required.
|
|
435
|
+
*
|
|
436
|
+
* 🛠 Endpoint: `PUT /v1/shop/commercial-orders/${orderId}/sync`
|
|
437
|
+
*
|
|
438
|
+
* | Parameter | Type | Required | Description |
|
|
439
|
+
* |-----------|----------|----------|-----------------------------------------|
|
|
440
|
+
* | `orderId` | `string` | ✅ | The commercial order identifier to sync |
|
|
441
|
+
*
|
|
442
|
+
* 📤 Returns:
|
|
443
|
+
* A `Promise<void>` resolving when the sync has been triggered. No body is expected in the request.
|
|
444
|
+
*
|
|
445
|
+
* 🛠 Example usage:
|
|
446
|
+
* ```ts
|
|
447
|
+
* await syncCommercialOrder("commercialOrder1");
|
|
448
|
+
* ```
|
|
449
|
+
*
|
|
450
|
+
* @param {string} orderId - The ID of the commercial order to synchronize
|
|
451
|
+
* @returns {Promise<void>} A promise resolving when the synchronization is triggered
|
|
452
|
+
*/
|
|
453
|
+
async function syncCommercialOrder(orderId) {
|
|
454
|
+
(0, parameters_validation_1.required)({ orderId });
|
|
455
|
+
await (0, fetch_instance_1.enhancedFetch)({
|
|
456
|
+
method: "PUT",
|
|
457
|
+
path: `/v1/shop/commercial-orders/${orderId}/sync`,
|
|
458
|
+
});
|
|
459
|
+
}
|
|
429
460
|
/**
|
|
430
461
|
* 🚚 Gets payment page url for a specific order.
|
|
431
462
|
*
|
|
@@ -91,6 +91,7 @@ async function postMediaCustomField(params) {
|
|
|
91
91
|
const { data } = await (0, fetch_instance_1.enhancedFetch)({
|
|
92
92
|
method: "POST",
|
|
93
93
|
path: `/v1/shop/custom-fields/${id}/media`,
|
|
94
|
+
body: "",
|
|
94
95
|
params: { customFieldIdType, sealedTarget, fileName, fileSize },
|
|
95
96
|
});
|
|
96
97
|
return data;
|
|
@@ -187,32 +187,23 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
|
|
|
187
187
|
}
|
|
188
188
|
const isJsonResponse = (_d = headers
|
|
189
189
|
.get("content-type")) === null || _d === void 0 ? void 0 : _d.includes("application/json");
|
|
190
|
-
//
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
190
|
+
// Always read raw text; parse only if JSON
|
|
191
|
+
const responseText = await response.text();
|
|
192
|
+
let data;
|
|
193
|
+
if (isJsonResponse && responseText) {
|
|
194
|
+
data = JSON.parse(responseText);
|
|
195
|
+
// Check if response data contains new accessToken and update configuration
|
|
196
|
+
if (data && ((_e = data === null || data === void 0 ? void 0 : data.token) === null || _e === void 0 ? void 0 : _e.accessToken)) {
|
|
197
|
+
(0, exports.updateConfiguration)({
|
|
198
|
+
accessToken: (_f = data === null || data === void 0 ? void 0 : data.token) === null || _f === void 0 ? void 0 : _f.accessToken,
|
|
199
|
+
});
|
|
198
200
|
}
|
|
199
|
-
catch (_a) {
|
|
200
|
-
return false;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
if (!isJsonString(responseText)) {
|
|
204
|
-
responseText = `{"data":"${responseText}"}`;
|
|
205
201
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
// Check if response data contains new accessToken and update configuration
|
|
210
|
-
if (data && ((_e = data === null || data === void 0 ? void 0 : data.token) === null || _e === void 0 ? void 0 : _e.accessToken)) {
|
|
211
|
-
(0, exports.updateConfiguration)({
|
|
212
|
-
accessToken: (_f = data === null || data === void 0 ? void 0 : data.token) === null || _f === void 0 ? void 0 : _f.accessToken,
|
|
213
|
-
});
|
|
202
|
+
else {
|
|
203
|
+
// Non-JSON responses should return raw text
|
|
204
|
+
data = responseText;
|
|
214
205
|
}
|
|
215
|
-
return { data, headers, status };
|
|
206
|
+
return { data: data, headers, status };
|
|
216
207
|
}
|
|
217
208
|
catch (error) {
|
|
218
209
|
Sentry.captureException(error, { tags: { env: clientConfig.env } });
|