octopian-apis 1.0.25 → 1.0.27

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 CHANGED
@@ -73,7 +73,7 @@ OctopianSDKConfig.Init('Your-API-Key',"Domain-Name")
73
73
 
74
74
  ## 🎈 Usage <a name="usage"></a>
75
75
 
76
- For detailed usage and services available in this SDK download our [documentation](https://in4ma-my.sharepoint.com/:u:/g/personal/mohammad_saeed_in4ma_onmicrosoft_com/Ee62SmLnu0ZIpPVi-Yxji0MBOj4f3TuEp_1vci4T0hDo0g?e=Z3i67j)
76
+ For detailed usage and services available in this SDK download our [documentation](https://in4ma-my.sharepoint.com/:u:/g/personal/mohammad_saeed_in4ma_onmicrosoft_com/EWPwDObJewFFtGjI32P5dWcBGQIVoGblICedbwx-wxmszw?e=ECvvnt)
77
77
 
78
78
  ```typescript
79
79
  import {AuthenticationServices} from 'octopian-apis';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "octopian-apis",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "description": "Transaction APIs SDK that implements Octopian Services which will be used for any node project typescript or javascript",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -170,3 +170,58 @@ export async function UploadAttachments(
170
170
  return attachmentsResponse;
171
171
  } else return writeSASResponse;
172
172
  }
173
+ /**
174
+ * @description
175
+ * Generates a Shared Access Signature (SAS) for reading from the storage.
176
+ *
177
+ * @param {string} AuthToken
178
+ * Authentication token for authorization purposes.
179
+ *
180
+ * @param {number} Timeout
181
+ * Optional timeout in milliseconds for the request.
182
+ *
183
+ * @returns
184
+ * An object containing the generated read SAS, including
185
+ * success message, status code, and any additional data returned by the API.
186
+ * {
187
+ * Message: Success,
188
+ * StatusCode: 200,
189
+ * Result: string
190
+ * }
191
+ */
192
+ export async function GetOnPremiseReadSAS(AuthToken = null, Timeout = 30000) {
193
+ let APIResponse = await apiHandler.GetMethod(
194
+ StorageAPIConstants.uriGetOnPremiseReadSAS(),
195
+ AuthToken,
196
+ Timeout
197
+ );
198
+ return APIResponse;
199
+ }
200
+ /**
201
+ * @description
202
+ * Generates a Shared Access Signature (SAS) for writing to the storage.
203
+ *
204
+ * @param {string} AuthToken
205
+ * Authentication token for authorization purposes.
206
+ *
207
+ * @param {number} Timeout
208
+ * Optional timeout in milliseconds for the request.
209
+ *
210
+ * @returns
211
+ * An object containing the generated write SAS, including
212
+ * success message, status code, and any additional data returned by the API.
213
+ * {
214
+ * Message: Success,
215
+ * StatusCode: 200,
216
+ * Result: string
217
+ * }
218
+ */
219
+ export async function GetOnPremiseWriteSAS(AuthToken = null, Timeout = 30000) {
220
+ let APIResponse = await apiHandler.GetMethod(
221
+ StorageAPIConstants.uriGetOnPremiseWriteSAS(),
222
+ AuthToken,
223
+ Timeout
224
+ );
225
+ return APIResponse;
226
+ }
227
+
@@ -4096,6 +4096,47 @@ export async function GetAssignbleRoleList(
4096
4096
  );
4097
4097
  return APIResponse;
4098
4098
  }
4099
+ /**
4100
+ * @description
4101
+ * Generates a document based on the provided input data.
4102
+ *
4103
+ * @param {object} GenerateDocumentInput
4104
+ * Data object containing fields necessary for generating the document.
4105
+ * ServiceId: number
4106
+ * TemplateAttributeAlias: string
4107
+ * ClientRequestAttributes: ClientRequestAttribute[]
4108
+ *
4109
+ * @param {string} AuthToken
4110
+ * Authentication token for authorization purposes.
4111
+ *
4112
+ * @param {number} Timeout
4113
+ * Time in milliseconds to wait before the request times out. Default is 30000.
4114
+ *
4115
+ * @param {string} RequiredHeaderValue
4116
+ * Value for any required header. Default is null.
4117
+ *
4118
+ * @returns
4119
+ * An object containing the response from the Generate Document API,
4120
+ * including success message, status code, and any additional data returned by the API.
4121
+ * Message: Success,
4122
+ * StatusCode: 200,
4123
+ * Result: string (document id)
4124
+ */
4125
+ export async function GenerateDocument(
4126
+ GenerateDocumentInput,
4127
+ AuthToken = null,
4128
+ Timeout = 30000,
4129
+ RequiredHeaderValue = null
4130
+ ) {
4131
+ let APIResponse = await apiHandler.PostMethod(
4132
+ TransactionsAPIConstants.uriGenerateDocument(),
4133
+ GenerateDocumentInput,
4134
+ AuthToken,
4135
+ Timeout,
4136
+ RequiredHeaderValue
4137
+ );
4138
+ return APIResponse;
4139
+ }
4099
4140
  //#endregion
4100
4141
 
4101
4142
  //#region Provider
@@ -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.
@@ -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
@@ -256,6 +256,7 @@ import {
256
256
  } from "./modals/output-modals/transaction-catalog-modals/PaymentInvoiceOutput";
257
257
  import { GetMyCorrespondenceListDTO } from "./modals/input-modals/correspondence-modals/GetMyCorrespondenceListDTO";
258
258
  import { CorrespondenceSubmitDraftInput } from "./modals/input-modals/correspondence-modals/CorrespondenceSubmitDraftInput";
259
+ import { GenerateDocumentInput } from "./modals/input-modals/transaction-catalog-modals/GenerateDocumentInput";
259
260
  // Define each module with its specific functions
260
261
 
261
262
  interface AuthenticationServices {
@@ -3628,6 +3629,34 @@ interface TransactionCommonServices {
3628
3629
  Timeout?: number | null,
3629
3630
  RequiredHeaderValue?: string
3630
3631
  ) => BaseResponse<DocumentRecordTemplateOutput[] | BaseErrorResponse>;
3632
+
3633
+ /**
3634
+ * @description
3635
+ * Generates a document using the provided data object.
3636
+ *
3637
+ * @param {GenerateDocumentInput} GenerateDocumentDTO
3638
+ * Data object containing fields necessary for generating a document.
3639
+ *
3640
+ * @param {string} AuthToken
3641
+ * Authentication token for authorization purposes.
3642
+ *
3643
+ * @param {number} Timeout
3644
+ * Time in milliseconds to wait before the request times out. Default is 30000.
3645
+ *
3646
+ * @returns
3647
+ * An object containing the response from the Generate Document API,
3648
+ * including success message, status code, and any additional data returned by the API.
3649
+ * Message: Success,
3650
+ * StatusCode: 200,
3651
+ * Result: string (document id)
3652
+ * HeaderValue: string
3653
+ */
3654
+ GenerateDocument: (
3655
+ Input: GenerateDocumentInput,
3656
+ AuthToken?: string | null,
3657
+ Timeout?: number | null,
3658
+ RequiredHeaderValue?: string
3659
+ ) => BaseResponse<string | BaseErrorResponse>;
3631
3660
  }
3632
3661
 
3633
3662
  // Storage Services interface
@@ -3757,6 +3786,54 @@ interface StorageServices {
3757
3786
  AuthToken?: string | null,
3758
3787
  Timeout?: number | null
3759
3788
  ) => BaseResponse<boolean | BaseErrorResponse>;
3789
+
3790
+ /**
3791
+ * @description
3792
+ * Generates a Shared Access Signature (SAS) for reading from the storage.
3793
+ *
3794
+ * @param {string} AuthToken
3795
+ * Authentication token for authorization purposes.
3796
+ *
3797
+ * @param {number} Timeout
3798
+ * Optional Timeout in milliseconds for the request.
3799
+ *
3800
+ * @returns
3801
+ * An object containing the generated read SAS, including
3802
+ * success message, status code, and any additional data returned by the API.
3803
+ * {
3804
+ * Message: Success,
3805
+ * StatusCode: 200,
3806
+ * Result: string
3807
+ * }
3808
+ */
3809
+ GetOnPremiseReadSAS: (
3810
+ AuthToken?: string | null,
3811
+ Timeout?: number | null
3812
+ ) => BaseResponse<string | BaseErrorResponse>;
3813
+
3814
+ /**
3815
+ * @description
3816
+ * Generates a Shared Access Signature (SAS) for writing to the storage.
3817
+ *
3818
+ * @param {string} AuthToken
3819
+ * Authentication token for authorization purposes.
3820
+ *
3821
+ * @param {number} Timeout
3822
+ * Optional Timeout in milliseconds for the request.
3823
+ *
3824
+ * @returns
3825
+ * An object containing the generated write SAS, including
3826
+ * success message, status code, and any additional data returned by the API.
3827
+ * {
3828
+ * Message: Success,
3829
+ * StatusCode: 200,
3830
+ * Result: string
3831
+ * }
3832
+ */
3833
+ GetOnPremiseWriteSAS: (
3834
+ AuthToken?: string | null,
3835
+ Timeout?: number | null
3836
+ ) => BaseResponse<string | BaseErrorResponse>;
3760
3837
  }
3761
3838
 
3762
3839
  // Requests Agent Services interface
@@ -6447,6 +6524,7 @@ export {
6447
6524
  RequestsDispatchServices,
6448
6525
  TaxiServices,
6449
6526
  CorrespondenceServices,
6527
+ GenerateDocumentInput,
6450
6528
  ChangeAccountPasswordInput,
6451
6529
  ExecuteServiceSelectorListIntegrationInput,
6452
6530
  DomainAvailableInput,
package/src/index.js CHANGED
@@ -123,6 +123,7 @@ const {
123
123
  GetInvoiceDetails,
124
124
  ValidateAttributesWithIntegration,
125
125
  GetPaymentBatch,
126
+ GenerateDocument
126
127
  } = require("./CoreServices/transactionsServices");
127
128
  const TransactionRequesterServices = {
128
129
  GetCompanyLanguageList,
@@ -206,6 +207,7 @@ const TransactionCommonServices = {
206
207
  MaintainInteractorRoleDelegationList,
207
208
  GetDocumentRecordTemplate,
208
209
  GetCompanyCustomLabelList,
210
+ GenerateDocument
209
211
  };
210
212
 
211
213
  const {
@@ -213,14 +215,18 @@ const {
213
215
  CreateWriteSAS,
214
216
  DeleteFile,
215
217
  UploadAttachments,
216
- AIVisionCopyFile
218
+ AIVisionCopyFile,
219
+ GetOnPremiseReadSAS,
220
+ GetOnPremiseWriteSAS
217
221
  } = require("./CoreServices/storageServices");
218
222
  const StorageServices = {
219
223
  CreateReadSAS,
220
224
  CreateWriteSAS,
221
225
  DeleteFile,
222
226
  UploadAttachments,
223
- AIVisionCopyFile
227
+ AIVisionCopyFile,
228
+ GetOnPremiseReadSAS,
229
+ GetOnPremiseWriteSAS
224
230
  };
225
231
 
226
232
  const {
@@ -0,0 +1,16 @@
1
+ export interface GenerateDocumentInput {
2
+ serviceId: number
3
+ templateAttributeAlias: string
4
+ clientRequestAttributes: ClientRequestAttribute[]
5
+ }
6
+
7
+ export interface ClientRequestAttribute {
8
+ RequestAttributeId: number
9
+ Name: string
10
+ Value: string
11
+ AttributeGroupId: number
12
+ SourceServiceAttributeId: number
13
+ ExtendedValue: string
14
+ Alias: string
15
+ }
16
+
@@ -360,6 +360,9 @@ export class TransactionsAPIConstants {
360
360
  transactionCatalogURI + "/api/TransactionCommon/GetDocumentRecordTemplate"
361
361
  );
362
362
  }
363
+ static uriGenerateDocument() {
364
+ return transactionCatalogURI + "/api/TransactionCommon/GenerateDocument";
365
+ }
363
366
  //#endregion
364
367
 
365
368
  //#region Agent
@@ -633,6 +636,12 @@ export class StorageAPIConstants {
633
636
  static uriAIVisionCopyFile() {
634
637
  return storageURI + "/api/AIVision/CopyFile";
635
638
  }
639
+ static uriGetOnPremiseReadSAS() {
640
+ return storageURI + "/api/OnPremStorage/GenerateDownloadSas";
641
+ }
642
+ static uriGetOnPremiseWriteSAS() {
643
+ return storageURI + "/api/OnPremStorage/GenerateUploadSas";
644
+ }
636
645
  }
637
646
 
638
647
  export class TaxiAPIConstants {