octopian-apis 1.0.24 → 1.0.26
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/package.json +1 -1
- package/src/CoreServices/correspondenceServices.js +6 -1
- package/src/darAlBerServices/transactionsServices.js +155 -2
- package/src/darAlBerServices.ts +7 -0
- package/src/index.d.ts +3 -0
- package/src/modals/input-modals/correspondence-modals/CorrespondenceSubmitDraftInput.ts +4 -0
package/package.json
CHANGED
|
@@ -304,6 +304,10 @@ export async function PostCorrespondenceComment(
|
|
|
304
304
|
* @description
|
|
305
305
|
* Submits a draft correspondence with the given details.
|
|
306
306
|
*
|
|
307
|
+
* @param {object} SubmitDraftCorrespondenceDTO
|
|
308
|
+
* Data object containing fields necessary for submitting a draft correspondence.
|
|
309
|
+
* specificRequestIds: CorrespondenceSubmitDraftInput[]
|
|
310
|
+
*
|
|
307
311
|
* @param {string} AuthToken
|
|
308
312
|
* Authentication token for authorization purposes.
|
|
309
313
|
*
|
|
@@ -323,12 +327,13 @@ export async function PostCorrespondenceComment(
|
|
|
323
327
|
* }
|
|
324
328
|
*/
|
|
325
329
|
export async function SubmitDraftCorrespondence(
|
|
330
|
+
SubmitDraftCorrespondenceDTO,
|
|
326
331
|
AuthToken = null,
|
|
327
332
|
Timeout = 30000
|
|
328
333
|
) {
|
|
329
334
|
let APIResponse = await apiHandler.PostMethod(
|
|
330
335
|
RequestsAPIConstants.uriSubmitDraftCorrespondence(),
|
|
331
|
-
|
|
336
|
+
SubmitDraftCorrespondenceDTO,
|
|
332
337
|
AuthToken,
|
|
333
338
|
Timeout
|
|
334
339
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TransactionsAPIConstants } from "../web-services/darAlBerConstants";
|
|
2
2
|
import * as apiHandler from "../web-services/dabAPIHandler";
|
|
3
3
|
import { GetAttributeTypeValueList } from "../CoreServices/transactionsServices";
|
|
4
|
-
import { DABAddRequest } from "./requestsServices";
|
|
4
|
+
import { DABAddRequest, DABSubmitCart } from "./requestsServices";
|
|
5
5
|
|
|
6
6
|
//#region Requester
|
|
7
7
|
|
|
@@ -1286,6 +1286,7 @@ export async function DABGetPaymentURL(
|
|
|
1286
1286
|
) {
|
|
1287
1287
|
try {
|
|
1288
1288
|
let serviceID = getPaymentURLDTO.ServiceID;
|
|
1289
|
+
let isAddToCart = false;
|
|
1289
1290
|
if (serviceID === 0 && getPaymentURLDTO.ServiceAlias) {
|
|
1290
1291
|
// Fetch the list of services
|
|
1291
1292
|
const servicesList = await apiHandler.PostMethod(
|
|
@@ -1326,6 +1327,7 @@ export async function DABGetPaymentURL(
|
|
|
1326
1327
|
};
|
|
1327
1328
|
} else {
|
|
1328
1329
|
serviceID = service.ServiceId;
|
|
1330
|
+
isAddToCart = service.AddToCart;
|
|
1329
1331
|
}
|
|
1330
1332
|
}
|
|
1331
1333
|
|
|
@@ -1405,7 +1407,7 @@ export async function DABGetPaymentURL(
|
|
|
1405
1407
|
(attribute) => attribute.Alias === getPaymentURLDTO.PaymentURLAlias
|
|
1406
1408
|
);
|
|
1407
1409
|
if (paymentURL && paymentURL.Value) {
|
|
1408
|
-
DABAddRequest(
|
|
1410
|
+
let addrequestResult = await DABAddRequest(
|
|
1409
1411
|
{
|
|
1410
1412
|
ServiceId: serviceID,
|
|
1411
1413
|
AssetId: getPaymentURLDTO.AssetId,
|
|
@@ -1417,6 +1419,14 @@ export async function DABGetPaymentURL(
|
|
|
1417
1419
|
Timeout,
|
|
1418
1420
|
RequiredHeaderValue
|
|
1419
1421
|
);
|
|
1422
|
+
if (addrequestResult.StatusCode === 200 && isAddToCart) {
|
|
1423
|
+
DABSubmitCart({
|
|
1424
|
+
RequestId: addrequestResult.Result.RequestId,
|
|
1425
|
+
ShippingAddressId: 0,
|
|
1426
|
+
BillingAddressId: 0,
|
|
1427
|
+
PaymentMethod: "Card",
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1420
1430
|
return {
|
|
1421
1431
|
Message: "Success",
|
|
1422
1432
|
StatusCode: 200,
|
|
@@ -1445,6 +1455,149 @@ export async function DABGetPaymentURL(
|
|
|
1445
1455
|
}
|
|
1446
1456
|
}
|
|
1447
1457
|
|
|
1458
|
+
/**
|
|
1459
|
+
* @description
|
|
1460
|
+
* Adds a service to the cart.
|
|
1461
|
+
*
|
|
1462
|
+
* @param {object} AddToCartDTO
|
|
1463
|
+
* Data object containing fields necessary for adding a service to the cart.
|
|
1464
|
+
* ServiceID: number
|
|
1465
|
+
* ServiceAlias: string
|
|
1466
|
+
* AssetId: number
|
|
1467
|
+
* ParametersValues: ParametersValues[]
|
|
1468
|
+
*
|
|
1469
|
+
* @param {string} AuthToken
|
|
1470
|
+
* Authentication token for authorization purposes.
|
|
1471
|
+
*
|
|
1472
|
+
* @param {number} Timeout
|
|
1473
|
+
* Time in milliseconds to wait before the request times out. Default is 30000.
|
|
1474
|
+
*
|
|
1475
|
+
* @param {string} RequiredHeaderValue
|
|
1476
|
+
* Value for any required header. Default is null.
|
|
1477
|
+
*
|
|
1478
|
+
* @returns
|
|
1479
|
+
* An object containing the response from the Add To Cart API,
|
|
1480
|
+
* including success message, status code, and any additional data returned by the API.
|
|
1481
|
+
* Message: Success,
|
|
1482
|
+
* StatusCode: 200,
|
|
1483
|
+
* Result: RequestId
|
|
1484
|
+
*/
|
|
1485
|
+
export async function DABAddToCart(
|
|
1486
|
+
AddToCartDTO,
|
|
1487
|
+
AuthToken = null,
|
|
1488
|
+
Timeout = 30000,
|
|
1489
|
+
RequiredHeaderValue = null
|
|
1490
|
+
) {
|
|
1491
|
+
try {
|
|
1492
|
+
let serviceID = AddToCartDTO.ServiceID;
|
|
1493
|
+
if (serviceID === 0 && AddToCartDTO.ServiceAlias) {
|
|
1494
|
+
// Fetch the list of services
|
|
1495
|
+
const servicesList = await apiHandler.PostMethod(
|
|
1496
|
+
TransactionsAPIConstants.uriGetServiceList(),
|
|
1497
|
+
{ PageSize: 1000, PageIndex: 0 },
|
|
1498
|
+
AuthToken,
|
|
1499
|
+
Timeout,
|
|
1500
|
+
RequiredHeaderValue,
|
|
1501
|
+
true
|
|
1502
|
+
);
|
|
1503
|
+
|
|
1504
|
+
// Validate the response
|
|
1505
|
+
if (!servicesList || !Array.isArray(servicesList.Result)) {
|
|
1506
|
+
return {
|
|
1507
|
+
Message: "Error",
|
|
1508
|
+
StatusCode: -1,
|
|
1509
|
+
Result: {
|
|
1510
|
+
ErrorMessage: "Could not fetch service list",
|
|
1511
|
+
ErrorRefNo: "-1",
|
|
1512
|
+
},
|
|
1513
|
+
};
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
// Find the service with the matching alias
|
|
1517
|
+
const service = servicesList.Result.find(
|
|
1518
|
+
(service) => service.Alias === AddToCartDTO.ServiceAlias
|
|
1519
|
+
);
|
|
1520
|
+
|
|
1521
|
+
// Check if the service was found
|
|
1522
|
+
if (!service) {
|
|
1523
|
+
return {
|
|
1524
|
+
Message: "Error",
|
|
1525
|
+
StatusCode: -1,
|
|
1526
|
+
Result: {
|
|
1527
|
+
ErrorMessage: `Service with alias ${AddToCartDTO.ServiceAlias} not found`,
|
|
1528
|
+
ErrorRefNo: "-1",
|
|
1529
|
+
},
|
|
1530
|
+
};
|
|
1531
|
+
} else {
|
|
1532
|
+
serviceID = service.ServiceId;
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
// Fetch the service parameters
|
|
1537
|
+
const serviceAttributes = await apiHandler.PostMethod(
|
|
1538
|
+
TransactionsAPIConstants.uriGetServiceRequestAttributeList(),
|
|
1539
|
+
{
|
|
1540
|
+
ServiceId: serviceID,
|
|
1541
|
+
AssetId: AddToCartDTO.AssetId,
|
|
1542
|
+
IsParameters: false,
|
|
1543
|
+
},
|
|
1544
|
+
AuthToken,
|
|
1545
|
+
Timeout,
|
|
1546
|
+
RequiredHeaderValue,
|
|
1547
|
+
true
|
|
1548
|
+
);
|
|
1549
|
+
|
|
1550
|
+
// Validate the service attributes response
|
|
1551
|
+
if (!serviceAttributes || !Array.isArray(serviceAttributes.Result)) {
|
|
1552
|
+
return {
|
|
1553
|
+
Message: "Error",
|
|
1554
|
+
StatusCode: -1,
|
|
1555
|
+
Result: {
|
|
1556
|
+
ErrorMessage: "Invalid response format for service parameters",
|
|
1557
|
+
ErrorRefNo: "-1",
|
|
1558
|
+
},
|
|
1559
|
+
};
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
serviceAttributes.Result.forEach((element) => {
|
|
1563
|
+
if (
|
|
1564
|
+
AddToCartDTO.ParametersValues.find(
|
|
1565
|
+
(param) => param.Alias === element.Alias
|
|
1566
|
+
)
|
|
1567
|
+
) {
|
|
1568
|
+
element.Value = AddToCartDTO.ParametersValues.find(
|
|
1569
|
+
(param) => param.Alias === element.Alias
|
|
1570
|
+
).Value;
|
|
1571
|
+
element.ExtendedValue = AddToCartDTO.ParametersValues.find(
|
|
1572
|
+
(param) => param.Alias === element.Alias
|
|
1573
|
+
).ExtendedValue;
|
|
1574
|
+
}
|
|
1575
|
+
});
|
|
1576
|
+
|
|
1577
|
+
let addrequestResult = await DABAddRequest(
|
|
1578
|
+
{
|
|
1579
|
+
ServiceId: serviceID,
|
|
1580
|
+
AssetId: AddToCartDTO.AssetId,
|
|
1581
|
+
BatchId: 0,
|
|
1582
|
+
ClientRequestAttributeDtos: serviceAttributes.Result,
|
|
1583
|
+
},
|
|
1584
|
+
AuthToken,
|
|
1585
|
+
Timeout,
|
|
1586
|
+
RequiredHeaderValue
|
|
1587
|
+
);
|
|
1588
|
+
return addrequestResult;
|
|
1589
|
+
} catch (error) {
|
|
1590
|
+
// Handle errors
|
|
1591
|
+
return {
|
|
1592
|
+
Message: "Error",
|
|
1593
|
+
StatusCode: -1,
|
|
1594
|
+
Result: {
|
|
1595
|
+
ErrorMessage: "Error fetching Payment URL",
|
|
1596
|
+
ErrorRefNo: "-1",
|
|
1597
|
+
},
|
|
1598
|
+
};
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1448
1601
|
/**
|
|
1449
1602
|
* @description
|
|
1450
1603
|
* Fetches the payment invoice details for a given invoice ID.
|
package/src/darAlBerServices.ts
CHANGED
|
@@ -1586,6 +1586,13 @@ interface DarAlBerServices {
|
|
|
1586
1586
|
Timeout?: number | null,
|
|
1587
1587
|
RequiredHeaderValue?: string
|
|
1588
1588
|
) => BaseResponse<string | BaseErrorResponse>;
|
|
1589
|
+
|
|
1590
|
+
DABAddToCart: (
|
|
1591
|
+
Input: GetPaymentURLInput,
|
|
1592
|
+
AuthToken?: string | null,
|
|
1593
|
+
Timeout?: number | null,
|
|
1594
|
+
RequiredHeaderValue?: string
|
|
1595
|
+
) => BaseResponse<AddRequestOutput | BaseErrorResponse>;
|
|
1589
1596
|
/**
|
|
1590
1597
|
* @description
|
|
1591
1598
|
* Fetches the payment invoice for a given invoice ID.
|
package/src/index.d.ts
CHANGED
|
@@ -255,6 +255,7 @@ import {
|
|
|
255
255
|
PaymentDetailsOutput,
|
|
256
256
|
} from "./modals/output-modals/transaction-catalog-modals/PaymentInvoiceOutput";
|
|
257
257
|
import { GetMyCorrespondenceListDTO } from "./modals/input-modals/correspondence-modals/GetMyCorrespondenceListDTO";
|
|
258
|
+
import { CorrespondenceSubmitDraftInput } from "./modals/input-modals/correspondence-modals/CorrespondenceSubmitDraftInput";
|
|
258
259
|
// Define each module with its specific functions
|
|
259
260
|
|
|
260
261
|
interface AuthenticationServices {
|
|
@@ -6391,6 +6392,7 @@ interface CorrespondenceServices {
|
|
|
6391
6392
|
* }
|
|
6392
6393
|
*/
|
|
6393
6394
|
SubmitDraftCorrespondence: (
|
|
6395
|
+
Input: CorrespondenceSubmitDraftInput,
|
|
6394
6396
|
AuthToken?: string | null,
|
|
6395
6397
|
Timeout?: number | null
|
|
6396
6398
|
) => BaseResponse<SubmitCartOrderOutput | BaseErrorResponse>;
|
|
@@ -6680,4 +6682,5 @@ export {
|
|
|
6680
6682
|
DonatorDetailsOutput,
|
|
6681
6683
|
PaymentDetailsOutput,
|
|
6682
6684
|
GetMyCorrespondenceListDTO,
|
|
6685
|
+
CorrespondenceSubmitDraftInput
|
|
6683
6686
|
};
|