octopian-apis 1.0.32 → 1.0.34

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "octopian-apis",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
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": {
@@ -66,7 +66,10 @@ import { TransactionsAPIConstants } from "../web-services/darAlBerConstants";
66
66
  * BatchRequestAttributeList: BatchRequestAttributeList[]}
67
67
  * }
68
68
  */
69
- export async function DABAgentGetCartDefinition(AuthToken = null, Timeout = 30000) {
69
+ export async function DABAgentGetCartDefinition(
70
+ AuthToken = null,
71
+ Timeout = 30000
72
+ ) {
70
73
  let APIResponse = await apiHandler.GetMethod(
71
74
  RequestsAPIConstants.uriAgentGetCartDefinition(),
72
75
  AuthToken,
@@ -163,7 +166,7 @@ export async function DABAgentAddRequest(
163
166
  * GroupCartParticipantDetailId?: number (Optional),
164
167
  * GroupCartId?: number (Optional),
165
168
  * GroupCartGuid?: guid string (Optional)
166
- *
169
+ *
167
170
  * @param {string} AuthToken
168
171
  * Authentication token for authorization purposes.
169
172
  *
@@ -304,7 +307,7 @@ export async function DABAgentCancelRequest(
304
307
  * IsByAgent: string (Optional),
305
308
  * BatchId: string (Optional),
306
309
  * SpecificRequestIdList: number[] (Optional)
307
- *
310
+ *
308
311
  * @param {string} AuthToken
309
312
  * Authentication token for authorization purposes.
310
313
  *
@@ -663,7 +666,11 @@ export async function DABGetCartDefinition(AuthToken = null, Timeout = 30000) {
663
666
  * }
664
667
  * }
665
668
  */
666
- export async function DABAddRequest(AddRequestDTO, AuthToken = null, Timeout = 30000) {
669
+ export async function DABAddRequest(
670
+ AddRequestDTO,
671
+ AuthToken = null,
672
+ Timeout = 30000
673
+ ) {
667
674
  let APIResponse = await apiHandler.PostMethod(
668
675
  RequestsAPIConstants.uriAddRequest(),
669
676
  AddRequestDTO,
@@ -682,7 +689,7 @@ export async function DABAddRequest(AddRequestDTO, AuthToken = null, Timeout = 3
682
689
  * BillingAddressId: number
683
690
  * PaymentMethod: string
684
691
  * ... other fields as needed
685
- *
692
+ *
686
693
  * @param {string} AuthToken
687
694
  * Authentication token for authorization purposes.
688
695
  *
@@ -698,7 +705,11 @@ export async function DABAddRequest(AddRequestDTO, AuthToken = null, Timeout = 3
698
705
  * Result: number
699
706
  * }
700
707
  */
701
- export async function DABSubmitCart(SubmitCartDTO, AuthToken = null, Timeout = 30000) {
708
+ export async function DABSubmitCart(
709
+ SubmitCartDTO,
710
+ AuthToken = null,
711
+ Timeout = 30000
712
+ ) {
702
713
  let APIResponse = await apiHandler.PostMethod(
703
714
  RequestsAPIConstants.uriSubmitCart(),
704
715
  SubmitCartDTO,
@@ -763,7 +774,7 @@ export async function DABGetMyRequestList(
763
774
  GetMyRequestListDTO,
764
775
  AuthToken = null,
765
776
  Timeout = 30000,
766
- RequiredHeaderValue=null
777
+ RequiredHeaderValue = null
767
778
  ) {
768
779
  let APIResponse = await apiHandler.PostMethod(
769
780
  RequestsAPIConstants.uriGetMyRequestList(),
@@ -779,18 +790,9 @@ export async function DABGetMyDonations(
779
790
  GetMyRequestListDTO,
780
791
  AuthToken = null,
781
792
  Timeout = 30000,
782
- RequiredHeaderValue=null
793
+ RequiredHeaderValue = null
783
794
  ) {
784
- const servicesList = await apiHandler.PostMethod(
785
- TransactionsAPIConstants.uriGetServiceList(),
786
- { PageSize: 1000, PageIndex: 0 },
787
- AuthToken,
788
- Timeout,
789
- RequiredHeaderValue,
790
- true
791
- );
792
-
793
- GetMyRequestListDTO['WithRequestAttribute']=true;
795
+ GetMyRequestListDTO["WithRequestAttribute"] = true;
794
796
  let requestsList = await apiHandler.PostMethod(
795
797
  RequestsAPIConstants.uriGetMyRequestList(),
796
798
  GetMyRequestListDTO,
@@ -798,12 +800,54 @@ export async function DABGetMyDonations(
798
800
  Timeout,
799
801
  RequiredHeaderValue
800
802
  );
801
- if(requestsList.Result.length>0){
802
- requestsList.Result.forEach(request => {
803
- request['ServiceAlias']=servicesList.Result.find(service => service.ServiceId === request.ServiceId)?.Alias;
804
- request['Amount']=request.RequestAttributeList.find(attribute => attribute.Alias=== 'Amount')?.Value;
805
- });
806
- }
803
+ if (requestsList.Result.length > 0) {
804
+ const servicesList = await apiHandler.PostMethod(
805
+ TransactionsAPIConstants.uriGetServiceList(),
806
+ { PageSize: 1000, PageIndex: 0 },
807
+ AuthToken,
808
+ Timeout,
809
+ RequiredHeaderValue,
810
+ true
811
+ );
812
+ for(let request of requestsList.Result){
813
+
814
+ let selectedAsset = null;
815
+ if (request.AssetId && request.AssetId > 0) {
816
+ try
817
+ {
818
+
819
+ let assetList = await apiHandler.PostMethod(
820
+ TransactionsAPIConstants.uriGetServiceAssetList(),
821
+ { PageSize: 100, PageIndex: 0, ServiceId: request.ServiceId, AssetIdList: [request.AssetId] },
822
+ AuthToken,
823
+ Timeout,
824
+ RequiredHeaderValue,
825
+ true
826
+ )
827
+ if(assetList?.StatusCode==200){
828
+ for (let asset of assetList?.Result) {
829
+ selectedAsset = asset?.Assetlist?.find(
830
+ (asset) => asset.AssetId === request.AssetId
831
+ );
832
+ }
833
+ }
834
+ }
835
+ catch(error){
836
+ //console.log(error);
837
+ }
838
+ }
839
+ request["ServiceAlias"] = servicesList?.Result?.find(
840
+ (service) => service.ServiceId === request.ServiceId
841
+ )?.Alias;
842
+ request["Amount"] = request.RequestAttributeList.find(
843
+ (attribute) => attribute.Alias === "Amount"
844
+ )?.Value;
845
+ request["Description"] = request.RequestAttributeList.find(
846
+ (attribute) => attribute.Alias === "Description"
847
+ )?.Value;
848
+ request["AssetImagePath"] = selectedAsset?.FullImagePath || "";
849
+ }
850
+ }
807
851
  return requestsList;
808
852
  }
809
853
  /**
@@ -862,7 +906,7 @@ export async function DABGetServiceOwnerRequestList(
862
906
  ServiceOwnerRequestDTO,
863
907
  AuthToken = null,
864
908
  Timeout = 30000,
865
- RequiredHeaderValue=null
909
+ RequiredHeaderValue = null
866
910
  ) {
867
911
  let APIResponse = await apiHandler.PostMethod(
868
912
  RequestsAPIConstants.uriGetServiceOwnerRequestList(),
@@ -1017,7 +1061,11 @@ export async function DABGetMyRequestCommentList(
1017
1061
  * StatusCode: 200,
1018
1062
  * Result: boolean
1019
1063
  */
1020
- export async function DABPostComment(PostCommentDTO, AuthToken = null, Timeout = 30000) {
1064
+ export async function DABPostComment(
1065
+ PostCommentDTO,
1066
+ AuthToken = null,
1067
+ Timeout = 30000
1068
+ ) {
1021
1069
  let APIResponse = await apiHandler.PostMethod(
1022
1070
  RequestsAPIConstants.uriPostComment(),
1023
1071
  PostCommentDTO,
@@ -1144,10 +1192,7 @@ export async function DABGetLastOrderDetail(
1144
1192
  * }
1145
1193
  * }
1146
1194
  */
1147
- export async function DABDashboardWidget(
1148
- AuthToken = null,
1149
- Timeout = 30000
1150
- ) {
1195
+ export async function DABDashboardWidget(AuthToken = null, Timeout = 30000) {
1151
1196
  let APIResponse = await apiHandler.GetMethod(
1152
1197
  RequestsAPIConstants.uriDashboardWidget(),
1153
1198
  AuthToken,
@@ -1365,7 +1410,11 @@ export async function DABReorderTrackableBatch(
1365
1410
  * Result: TrackableBatchRequestList[]
1366
1411
  * }
1367
1412
  */
1368
- export async function DABTrackBatch(TrackBatchDTO, AuthToken = null, Timeout = 30000) {
1413
+ export async function DABTrackBatch(
1414
+ TrackBatchDTO,
1415
+ AuthToken = null,
1416
+ Timeout = 30000
1417
+ ) {
1369
1418
  let APIResponse = await apiHandler.PostMethod(
1370
1419
  RequestsAPIConstants.uriTrackBatch(),
1371
1420
  TrackBatchDTO,
@@ -1486,7 +1535,11 @@ export async function DABEditBatchHeaders(
1486
1535
  * Result: orderList[]
1487
1536
  * }
1488
1537
  */
1489
- export async function DABGetGroupOrder(GroupOrderDTO, AuthToken = null, Timeout = 30000) {
1538
+ export async function DABGetGroupOrder(
1539
+ GroupOrderDTO,
1540
+ AuthToken = null,
1541
+ Timeout = 30000
1542
+ ) {
1490
1543
  let APIResponse = await apiHandler.PostMethod(
1491
1544
  RequestsAPIConstants.uriGetGroupOrder(),
1492
1545
  GroupOrderDTO,
@@ -1623,7 +1676,10 @@ export async function DABLeaveGroupOrder(
1623
1676
  * Result: ActiveGroupOrderDtoList[]
1624
1677
  * }
1625
1678
  */
1626
- export async function DABGetMyActiveGroupOrderList(AuthToken = null, Timeout = 30000) {
1679
+ export async function DABGetMyActiveGroupOrderList(
1680
+ AuthToken = null,
1681
+ Timeout = 30000
1682
+ ) {
1627
1683
  let APIResponse = await apiHandler.PostMethod(
1628
1684
  RequestsAPIConstants.uriGetMyActiveGroupOrderList(),
1629
1685
  null,
@@ -80,6 +80,7 @@ export interface GetMyRequestOutput {
80
80
  InteractorId: number
81
81
  InteractorName: string
82
82
  Amount: string
83
+ Description: string
83
84
  UnitName: string
84
85
  IsByAgent: boolean
85
86
  RequestAgentId: number
@@ -101,6 +102,7 @@ export interface GetMyRequestOutput {
101
102
  AssetGroupName: string
102
103
  AssetSubGroupName: string
103
104
  AssetName: string
105
+ AssetImagePath: string
104
106
  RequestStatusId: number
105
107
  SubmitDate: string
106
108
  FinishDate: string
@@ -1,771 +0,0 @@
1
- import {
2
- RequestsAPIConstants,
3
- RequestStepsAPIConstants,
4
- } from "../web-services/apiConstants";
5
- import * as apiHandler from "../web-services/apiHandler";
6
- import { CreateReadSAS } from "./storageServices";
7
-
8
- /**
9
- * @description
10
- * Retrieves the list of Correspondences for the current user.
11
- *
12
- * @param {object} getMyCorrespondenceListDTO
13
- * Data object containing fields necessary for retrieving the list of requests.
14
- * PageSize: number
15
- * PageIndex: number
16
- * IsAscendingOrder?: boolean (Optional)
17
- * FromFinishDate?: string (Optional)
18
- * ToFinishDate?: string (Optional)
19
- * FromStartDate?: string (Optional)
20
- * ToStartDate?: string (Optional)
21
- *
22
- * @param {string} AuthToken
23
- * Authentication token for authorization purposes.
24
- *
25
- * @param {number} Timeout
26
- * Time in milliseconds to wait before the request times out. Default is 30000.
27
- *
28
- * @returns
29
- * An object containing the response from the Get My Request List request, including
30
- * success message, status code, and any additional data returned by the API.
31
- * {
32
- * Message: string,
33
- * StatusCode: number,
34
- * Result: {
35
- * -- request data based on selection criteria wether grouped or not--
36
- * }
37
- * }
38
- */
39
- export async function GetMyApprovedCorrespondenceRequests(
40
- GetMyCorrespondenceListDTO,
41
- AuthToken = null,
42
- Timeout = 30000,
43
- RequiredHeaderValue = null
44
- ) {
45
- GetMyCorrespondenceListDTO["RequestStatus"] = "Approved";
46
- GetMyCorrespondenceListDTO["WithRequestStep"] = true;
47
- GetMyCorrespondenceListDTO["WithRequestStepAttribute"] = true;
48
- GetMyCorrespondenceListDTO["WithRequestAttribute"] = true;
49
-
50
- let APIResponse = await apiHandler.PostMethod(
51
- RequestsAPIConstants.uriGetMyRequestList(),
52
- GetMyCorrespondenceListDTO,
53
- AuthToken,
54
- Timeout,
55
- RequiredHeaderValue
56
- );
57
- let MappedResult = [];
58
- let ReadSASResult = await CreateReadSAS(AuthToken, Timeout);
59
- if (APIResponse.StatusCode === 200 && APIResponse.Result?.length > 0) {
60
- APIResponse.Result.forEach((element) => {
61
- let subject = element.ServiceName;
62
- let notes = "";
63
- let ImagePath = "";
64
- let ProcessFlow = [];
65
- let ToName = '';
66
- if (element.RequestAttributeList?.length > 0) {
67
- element.RequestAttributeList.forEach((attribute) => {
68
- if (attribute.Alias === "Subject") {
69
- subject = attribute.Value;
70
- }
71
- if (attribute.Alias === "Notes") {
72
- notes = attribute.Value;
73
- }
74
- if (attribute.Alias === "InteractorImagePath") {
75
- ImagePath = attribute.Value;
76
- }
77
- if (attribute.Alias === "To") {
78
- ToName = attribute.Value;
79
- }
80
- });
81
- }
82
- if (ImagePath && ReadSASResult.StatusCode === 200) {
83
- ImagePath =
84
- ReadSASResult.Result.split("?")[0] +
85
- "/" +
86
- ImagePath +
87
- "?" +
88
- ReadSASResult.Result.split("?")[1];
89
- }
90
- if (element.RequestStepList) {
91
- element.RequestStepList.forEach((step) => {
92
- if (step.IsRequesterVisible) {
93
- let ProviderImagePath = "";
94
- if (step.ProviderImagePath) {
95
- ProviderImagePath = step.ProviderImagePath;
96
- }
97
- if (ProviderImagePath && ReadSASResult.StatusCode === 200) {
98
- ProviderImagePath =
99
- ReadSASResult.Result.split("?")[0] +
100
- "/" +
101
- ProviderImagePath +
102
- "?" +
103
- ReadSASResult.Result.split("?")[1];
104
- }
105
- ProcessFlow.push({
106
- Id: step.RequestStepId,
107
- ImagePath: ProviderImagePath,
108
- Name: step.ProviderName,
109
- Comment: step.ProviderComments,
110
- SubmitDate: step.StartDate,
111
- });
112
- }
113
- });
114
- }
115
- MappedResult.push({
116
- RequestId: element.RequestId,
117
- StepId: 0,
118
- RequesterImagePath: ImagePath,
119
- RequesterName: element.InteractorName,
120
- ToName: ToName,
121
- CategoryColor: element.ExtraLine1 ? element.ExtraLine1 : "#FB4C2F",
122
- CategoryName: element.ServiceSubCategoryName,
123
- SubmitDate: element.SubmitDate,
124
- Subject: subject,
125
- Notes: notes,
126
- IsRead: true,
127
- ProcessFlow: ProcessFlow,
128
- });
129
- });
130
- APIResponse.Result = MappedResult;
131
- }
132
- return APIResponse;
133
- }
134
-
135
- /**
136
- * @description
137
- * Retrieves the list of Correspondences for the current user.
138
- *
139
- * @param {object} getMyCorrespondenceInboxListDTO
140
- * Data object containing fields necessary for retrieving the list of requests.
141
- * PageSize: number
142
- * PageIndex: number
143
- * IsAscendingOrder?: boolean (Optional)
144
- * FromFinishDate?: string (Optional)
145
- * ToFinishDate?: string (Optional)
146
- * FromStartDate?: string (Optional)
147
- * ToStartDate?: string (Optional)
148
- *
149
- * @param {string} AuthToken
150
- * Authentication token for authorization purposes.
151
- *
152
- * @param {number} Timeout
153
- * Time in milliseconds to wait before the request times out. Default is 30000.
154
- *
155
- * @returns
156
- * An object containing the response from the Get My Request List request, including
157
- * success message, status code, and any additional data returned by the API.
158
- * {
159
- * Message: string,
160
- * StatusCode: number,
161
- * Result: {
162
- * -- request data based on selection criteria wether grouped or not--
163
- * }
164
- * }
165
- */
166
- export async function GetMyRejectedCorrespondenceRequests(
167
- GetMyCorrespondenceListDTO,
168
- AuthToken = null,
169
- Timeout = 30000,
170
- RequiredHeaderValue = null
171
- ) {
172
- GetMyCorrespondenceListDTO["RequestStatus"] = "Rejected";
173
- GetMyCorrespondenceListDTO["WithRequestStep"] = true;
174
- GetMyCorrespondenceListDTO["WithRequestStepAttribute"] = true;
175
- GetMyCorrespondenceListDTO["WithRequestAttribute"] = true;
176
-
177
- let APIResponse = await apiHandler.PostMethod(
178
- RequestsAPIConstants.uriGetMyRequestList(),
179
- GetMyCorrespondenceListDTO,
180
- AuthToken,
181
- Timeout,
182
- RequiredHeaderValue
183
- );
184
- let MappedResult = [];
185
- let ReadSASResult = await CreateReadSAS(AuthToken, Timeout);
186
- if (APIResponse.StatusCode === 200 && APIResponse.Result?.length > 0) {
187
- APIResponse.Result.forEach((element) => {
188
- let subject = element.ServiceName;
189
- let notes = "";
190
- let ImagePath = "";
191
- let ProcessFlow = [];
192
- let ToName = '';
193
- if (element.RequestAttributeList?.length > 0) {
194
- element.RequestAttributeList.forEach((attribute) => {
195
- if (attribute.Alias === "Subject") {
196
- subject = attribute.Value;
197
- }
198
- if (attribute.Alias === "Notes") {
199
- notes = attribute.Value;
200
- }
201
- if (attribute.Alias === "InteractorImagePath") {
202
- ImagePath = attribute.Value;
203
- }
204
- if (attribute.Alias === "To") {
205
- ToName = attribute.Value;
206
- }
207
- });
208
- }
209
- if (ImagePath && ReadSASResult.StatusCode === 200) {
210
- ImagePath =
211
- ReadSASResult.Result.split("?")[0] +
212
- "/" +
213
- ImagePath +
214
- "?" +
215
- ReadSASResult.Result.split("?")[1];
216
- }
217
- if (element.RequestStepList) {
218
- element.RequestStepList.forEach((step) => {
219
- if (step.IsRequesterVisible) {
220
- let ProviderImagePath = "";
221
- if (step.ProviderImagePath) {
222
- ProviderImagePath = step.ProviderImagePath;
223
- }
224
- if (ProviderImagePath && ReadSASResult.StatusCode === 200) {
225
- ProviderImagePath =
226
- ReadSASResult.Result.split("?")[0] +
227
- "/" +
228
- ProviderImagePath +
229
- "?" +
230
- ReadSASResult.Result.split("?")[1];
231
- }
232
- ProcessFlow.push({
233
- Id: step.RequestStepId,
234
- ImagePath: ProviderImagePath,
235
- Name: step.ProviderName,
236
- Comment: step.ProviderComments,
237
- SubmitDate: step.StartDate,
238
- });
239
- }
240
- });
241
- }
242
- MappedResult.push({
243
- RequestId: element.RequestId,
244
- StepId: 0,
245
- RequesterImagePath: ImagePath,
246
- RequesterName: element.InteractorName,
247
- ToName: ToName,
248
- CategoryColor: element.ExtraLine1 ? element.ExtraLine1 : "#FB4C2F",
249
- CategoryName: element.ServiceSubCategoryName,
250
- SubmitDate: element.SubmitDate,
251
- Subject: subject,
252
- Notes: notes,
253
- IsRead: true,
254
- ProcessFlow: ProcessFlow,
255
- });
256
- });
257
- APIResponse.Result = MappedResult;
258
- }
259
- return APIResponse;
260
- }
261
-
262
- /**
263
- * @description
264
- * Retrieves the list of Correspondences for the current user.
265
- *
266
- * @param {object} getMyCorrespondenceListDTO
267
- * Data object containing fields necessary for retrieving the list of requests.
268
- * PageSize: number
269
- * PageIndex: number
270
- * IsAscendingOrder?: boolean (Optional)
271
- * FromFinishDate?: string (Optional)
272
- * ToFinishDate?: string (Optional)
273
- * FromStartDate?: string (Optional)
274
- * ToStartDate?: string (Optional)
275
- *
276
- * @param {string} AuthToken
277
- * Authentication token for authorization purposes.
278
- *
279
- * @param {number} Timeout
280
- * Time in milliseconds to wait before the request times out. Default is 30000.
281
- *
282
- * @returns
283
- * An object containing the response from the Get My Request List request, including
284
- * success message, status code, and any additional data returned by the API.
285
- * {
286
- * Message: string,
287
- * StatusCode: number,
288
- * Result: {
289
- * -- request data based on selection criteria wether grouped or not--
290
- * }
291
- * }
292
- */
293
- export async function GetMyDraftCorrespondenceRequests(
294
- GetMyCorrespondenceListDTO,
295
- AuthToken = null,
296
- Timeout = 30000,
297
- RequiredHeaderValue = null
298
- ) {
299
- GetMyCorrespondenceListDTO["RequestStatus"] = "Draft";
300
- GetMyCorrespondenceListDTO["WithRequestStep"] = true;
301
- GetMyCorrespondenceListDTO["WithRequestStepAttribute"] = true;
302
- GetMyCorrespondenceListDTO["WithRequestAttribute"] = true;
303
-
304
- let APIResponse = await apiHandler.PostMethod(
305
- RequestsAPIConstants.uriGetMyRequestList(),
306
- GetMyCorrespondenceListDTO,
307
- AuthToken,
308
- Timeout,
309
- RequiredHeaderValue
310
- );
311
- let MappedResult = [];
312
- let ReadSASResult = await CreateReadSAS(AuthToken, Timeout);
313
- if (APIResponse.StatusCode === 200 && APIResponse.Result?.length > 0) {
314
- APIResponse.Result.forEach((element) => {
315
- let subject = element.ServiceName;
316
- let notes = "";
317
- let ImagePath = "";
318
- let ToName = '';
319
- if (element.RequestAttributeList?.length > 0) {
320
- element.RequestAttributeList.forEach((attribute) => {
321
- if (attribute.Alias === "Subject") {
322
- subject = attribute.Value;
323
- }
324
- if (attribute.Alias === "Notes") {
325
- notes = attribute.Value;
326
- }
327
- if (attribute.Alias === "InteractorImagePath") {
328
- ImagePath = attribute.Value;
329
- }
330
- if (attribute.Alias === "To") {
331
- ToName = attribute.Value;
332
- }
333
- });
334
- }
335
- if (ImagePath && ReadSASResult.StatusCode === 200) {
336
- ImagePath =
337
- ReadSASResult.Result.split("?")[0] +
338
- "/" +
339
- ImagePath +
340
- "?" +
341
- ReadSASResult.Result.split("?")[1];
342
- }
343
- MappedResult.push({
344
- RequestId: element.RequestId,
345
- StepId: 0,
346
- RequesterImagePath: ImagePath,
347
- RequesterName: element.InteractorName,
348
- ToName: ToName,
349
- CategoryColor: element.ExtraLine1 ? element.ExtraLine1 : "#FB4C2F",
350
- CategoryName: element.ServiceSubCategoryName,
351
- SubmitDate: element.SubmitDate,
352
- Subject: subject,
353
- Notes: notes,
354
- IsRead: true,
355
- ProcessFlow: [],
356
- });
357
- });
358
- APIResponse.Result = MappedResult;
359
- }
360
- return APIResponse;
361
- }
362
-
363
- /**
364
- * @description
365
- * Retrieves the list of Correspondences for the current user.
366
- *
367
- * @param {object} GetMyCorrespondenceListDTO
368
- * Data object containing fields necessary for retrieving the list of requests.
369
- * PageSize: number
370
- * PageIndex: number
371
- * IsAscendingOrder?: boolean (Optional)
372
- * FromFinishDate?: string (Optional)
373
- * ToFinishDate?: string (Optional)
374
- * FromStartDate?: string (Optional)
375
- * ToStartDate?: string (Optional)
376
- *
377
- * @param {string} AuthToken
378
- * Authentication token for authorization purposes.
379
- *
380
- * @param {number} Timeout
381
- * Time in milliseconds to wait before the request times out. Default is 30000.
382
- *
383
- * @returns
384
- * An object containing the response from the Get My Request List request, including
385
- * success message, status code, and any additional data returned by the API.
386
- * {
387
- * Message: string,
388
- * StatusCode: number,
389
- * Result: {
390
- * -- request data based on selection criteria wether grouped or not--
391
- * }
392
- * }
393
- */
394
- export async function GetMyClosedCorrespondenceRequests(
395
- GetMyCorrespondenceListDTO,
396
- AuthToken = null,
397
- Timeout = 30000,
398
- RequiredHeaderValue = null
399
- ) {
400
- GetMyCorrespondenceListDTO["RequestStatus"] = "Closed";
401
- GetMyCorrespondenceListDTO["WithRequestStep"] = true;
402
- GetMyCorrespondenceListDTO["WithRequestStepAttribute"] = true;
403
- GetMyCorrespondenceListDTO["WithRequestAttribute"] = true;
404
-
405
- let APIResponse = await apiHandler.PostMethod(
406
- RequestsAPIConstants.uriGetMyRequestList(),
407
- GetMyCorrespondenceListDTO,
408
- AuthToken,
409
- Timeout,
410
- RequiredHeaderValue
411
- );
412
- let MappedResult = [];
413
- let ReadSASResult = await CreateReadSAS(AuthToken, Timeout);
414
- if (APIResponse.StatusCode === 200 && APIResponse.Result?.length > 0) {
415
- APIResponse.Result.forEach((element) => {
416
- let subject = element.ServiceName;
417
- let notes = "";
418
- let ImagePath = "";
419
- let ProcessFlow = [];
420
- let ToName = '';
421
- if (element.RequestAttributeList?.length > 0) {
422
- element.RequestAttributeList.forEach((attribute) => {
423
- if (attribute.Alias === "Subject") {
424
- subject = attribute.Value;
425
- }
426
- if (attribute.Alias === "Notes") {
427
- notes = attribute.Value;
428
- }
429
- if (attribute.Alias === "InteractorImagePath") {
430
- ImagePath = attribute.Value;
431
- }
432
- if (attribute.Alias === "To") {
433
- ToName = attribute.Value;
434
- }
435
- });
436
- }
437
- if (ImagePath && ReadSASResult.StatusCode === 200) {
438
- ImagePath =
439
- ReadSASResult.Result.split("?")[0] +
440
- "/" +
441
- ImagePath +
442
- "?" +
443
- ReadSASResult.Result.split("?")[1];
444
- }
445
- if (element.RequestStepList) {
446
- element.RequestStepList.forEach((step) => {
447
- if (step.IsRequesterVisible) {
448
- let ProviderImagePath = "";
449
- if (step.ProviderImagePath) {
450
- ProviderImagePath = step.ProviderImagePath;
451
- }
452
- if (ProviderImagePath && ReadSASResult.StatusCode === 200) {
453
- ProviderImagePath =
454
- ReadSASResult.Result.split("?")[0] +
455
- "/" +
456
- ProviderImagePath +
457
- "?" +
458
- ReadSASResult.Result.split("?")[1];
459
- }
460
- ProcessFlow.push({
461
- Id: step.RequestStepId,
462
- ImagePath: ProviderImagePath,
463
- Name: step.ProviderName,
464
- Comment: step.ProviderComments,
465
- SubmitDate: step.StartDate,
466
- });
467
- }
468
- });
469
- }
470
- MappedResult.push({
471
- RequestId: element.RequestId,
472
- StepId: 0,
473
- RequesterImagePath: ImagePath,
474
- RequesterName: element.InteractorName,
475
- ToName: ToName,
476
- CategoryColor: element.ExtraLine1 ? element.ExtraLine1 : "#FB4C2F",
477
- CategoryName: element.ServiceSubCategoryName,
478
- SubmitDate: element.SubmitDate,
479
- Subject: subject,
480
- Notes: notes,
481
- IsRead: true,
482
- ProcessFlow: ProcessFlow,
483
- });
484
- });
485
- APIResponse.Result = MappedResult;
486
- }
487
- return APIResponse;
488
- }
489
-
490
- /**
491
- * @description
492
- * Retrieves the list of comments for a request.
493
- *
494
- * @param {object} GetMyCorrespondenceCommentListDTO
495
- * Data object containing fields necessary for retrieving the list of comments.
496
- * RequestId: number
497
- *
498
- * @param {string} AuthToken
499
- * Authentication token for authorization purposes.
500
- *
501
- * @param {number} Timeout
502
- * Time in milliseconds to wait before the request times out. Default is 30000.
503
- *
504
- * @returns
505
- * An object containing the response from the Get My Request Comment List API, including
506
- * success message, status code, and any additional data returned by the API.
507
- * Message: Success,
508
- * StatusCode: 200,
509
- * Result: [{
510
- * RequestCommentId: number,
511
- * CommentDate: string,
512
- * InteractorFullName: string,
513
- * Comment: string,
514
- * RequestId: number,
515
- * IsByRequester: boolean,
516
- * AlternateComment: string,
517
- * AlternateInteractorName: string,
518
- * AttachmentFilePath: string,
519
- * RequesterComment: string,
520
- * ProviderPrimaryComment: string,
521
- * ProviderSecondaryComment: string,
522
- * DtoState: number
523
- * },..]
524
- */
525
- export async function GetMyCorrespondenceCommentList(
526
- GetMyCorrespondenceCommentListDTO,
527
- AuthToken = null,
528
- Timeout = 30000
529
- ) {
530
- let APIResponse = await apiHandler.PostMethod(
531
- RequestsAPIConstants.uriGetMyRequestCommentList(),
532
- GetMyCorrespondenceCommentListDTO,
533
- AuthToken,
534
- Timeout
535
- );
536
- return APIResponse;
537
- }
538
-
539
- /**
540
- * @description
541
- * Posts a comment for a request.
542
- *
543
- * @param {object} PostCommentDTO
544
- * Data object containing fields necessary for posting a comment.
545
- * RequestId: number
546
- * Comment: string
547
- * CommentLanguageCode: string
548
- * AttachmentFilePath: string (Optional)
549
- * ReturnAlternateNames: boolean (Optional)
550
- *
551
- * @param {string} AuthToken
552
- * Authentication token for authorization purposes.
553
- *
554
- * @param {number} Timeout
555
- * Time in milliseconds to wait before the request times out. Default is 30000.
556
- *
557
- * @returns
558
- * An object containing the response from the Post Comment API, including
559
- * success message, status code, and any additional data returned by the API.
560
- * Message: Success,
561
- * StatusCode: 200,
562
- * Result: boolean
563
- */
564
- export async function PostCorrespondenceComment(
565
- PostCommentDTO,
566
- AuthToken = null,
567
- Timeout = 30000
568
- ) {
569
- let APIResponse = await apiHandler.PostMethod(
570
- RequestsAPIConstants.uriPostComment(),
571
- PostCommentDTO,
572
- AuthToken,
573
- Timeout
574
- );
575
- return APIResponse;
576
- }
577
-
578
- /**
579
- * @description
580
- * Submits a draft correspondence with the given details.
581
- *
582
- * @param {object} SubmitDraftCorrespondenceDTO
583
- * Data object containing fields necessary for submitting a draft correspondence.
584
- * specificRequestIds: CorrespondenceSubmitDraftInput[]
585
- *
586
- * @param {string} AuthToken
587
- * Authentication token for authorization purposes.
588
- *
589
- * @param {number} Timeout
590
- * Time in milliseconds to wait before the request times out. Default is 30000.
591
- *
592
- * @returns
593
- * An object containing the response from the Submit Draft Correspondence request, including
594
- * success message, status code, and any additional data returned by the API.
595
- * {
596
- * Message: string,
597
- * StatusCode: number,
598
- * Result: {
599
- * BatchId: number
600
- * IsSuccess: boolean
601
- * }
602
- * }
603
- */
604
- export async function SubmitDraftCorrespondence(
605
- SubmitDraftCorrespondenceDTO,
606
- AuthToken = null,
607
- Timeout = 30000
608
- ) {
609
- let APIResponse = await apiHandler.PostMethod(
610
- RequestsAPIConstants.uriSubmitDraftCorrespondence(),
611
- SubmitDraftCorrespondenceDTO,
612
- AuthToken,
613
- Timeout
614
- );
615
- return APIResponse;
616
- }
617
-
618
- /**
619
- * @description
620
- * Retrieves the list of inbox correspondences.
621
- *
622
- * @param {object} GetMyCorrespondenceListDTO
623
- * Data object containing fields necessary for retrieving the request step list.
624
- * PageSize: number
625
- * PageIndex: number
626
- * IsAscendingOrder?: boolean (Optional)
627
- * FromFinishDate?: string (Optional)
628
- * ToFinishDate?: string (Optional)
629
- * FromStartDate?: string (Optional)
630
- * ToStartDate?: string (Optional)
631
- *
632
- * @param {string} AuthToken
633
- * Authentication token for authorization purposes.
634
- *
635
- * @param {number} Timeout
636
- * Time in milliseconds to wait before the request times out. Default is 30000.
637
- *
638
- * @returns
639
- * An object containing the API response from the Get My Request Step List request,
640
- * including a success message, status code, and any additional data returned by the API.
641
- * {
642
- * Message: string,
643
- * StatusCode: number,
644
- * Result: GetRequestStepListOutput[]
645
- * }
646
- */
647
- export async function GetMyInboxCorrespondenceRequests(
648
- GetMyCorrespondenceListDTO,
649
- AuthToken = null,
650
- Timeout = 30000,
651
- RequiredHeaderValue = null
652
- ) {
653
- GetMyCorrespondenceListDTO["WithRequest"] = true;
654
- GetMyCorrespondenceListDTO["WithRequestStepAttributes"] = true;
655
- GetMyCorrespondenceListDTO["WithRequestAttributes"] = true;
656
- let APIResponse = await apiHandler.PostMethod(
657
- RequestStepsAPIConstants.uriGetMyRequestStepList(),
658
- GetMyCorrespondenceListDTO,
659
- AuthToken,
660
- Timeout,
661
- RequiredHeaderValue
662
- );
663
- let MappedResult = [];
664
- let ReadSASResult = await CreateReadSAS(AuthToken, Timeout);
665
- if (APIResponse.StatusCode === 200 && APIResponse.Result?.length > 0) {
666
- APIResponse.Result.forEach((element) => {
667
- let subject = element.Request.ServiceName;
668
- let notes = "";
669
- let ImagePath = "";
670
- let ProcessFlow = [];
671
- if (element.Request?.RequestAttributeList?.length > 0) {
672
- element.Request.RequestAttributeList.forEach((attribute) => {
673
- if (attribute.Alias === "Subject") {
674
- subject = attribute.Value;
675
- }
676
- if (attribute.Alias === "Notes") {
677
- notes = attribute.Value;
678
- }
679
- if (attribute.Alias === "InteractorImagePath") {
680
- ImagePath = attribute.Value;
681
- }
682
- });
683
- }
684
- if (element.ProviderImagePath) {
685
- ImagePath = element.ProviderImagePath;
686
- }
687
- if (ImagePath && ReadSASResult.StatusCode === 200) {
688
- ImagePath =
689
- ReadSASResult.Result.split("?")[0] +
690
- "/" +
691
- ImagePath +
692
- "?" +
693
- ReadSASResult.Result.split("?")[1];
694
- }
695
- if (element.PreviousClosedRequestStepList) {
696
- element.PreviousClosedRequestStepList.forEach((step) => {
697
- let ProviderImagePath = "";
698
- if (step.ProviderImagePath) {
699
- ProviderImagePath = step.ProviderImagePath;
700
- }
701
- if (ProviderImagePath && ReadSASResult.StatusCode === 200) {
702
- ProviderImagePath =
703
- ReadSASResult.Result.split("?")[0] +
704
- "/" +
705
- ProviderImagePath +
706
- "?" +
707
- ReadSASResult.Result.split("?")[1];
708
- }
709
- ProcessFlow.push({
710
- Id: step.RequestStepId,
711
- ImagePath: ProviderImagePath,
712
- Name: step.ProviderName,
713
- Comment: step.ProviderComments,
714
- SubmitDate: step.StartDate,
715
- });
716
- });
717
- }
718
- MappedResult.push({
719
- RequestId: element.RequestId,
720
- StepId: element.RequestStepId,
721
- RequesterImagePath: ImagePath,
722
- RequesterName: element.Request.InteractorName,
723
- CategoryColor: element.Request.ExtraLine1
724
- ? element.Request.ExtraLine1
725
- : "#FB4C2F",
726
- CategoryName: element.Request.ServiceSubCategoryName,
727
- SubmitDate: element.StartDate,
728
- Subject: subject,
729
- Notes: notes,
730
- IsRead: element.IsCheckedOut,
731
- ProcessFlow: ProcessFlow,
732
- });
733
- });
734
- APIResponse.Result = MappedResult;
735
- }
736
- return APIResponse;
737
- }
738
-
739
- /**
740
- * @description
741
- * Retrieves the list of provider step type counts.
742
- *
743
- * @param {string} AuthToken
744
- * Authentication token for authorization purposes.
745
- *
746
- * @param {number} Timeout
747
- * Time in milliseconds to wait before the request times out. Default is 30000.
748
- *
749
- * @returns
750
- * An object containing the API response from the Get Provider Step Type Counts request,
751
- * including a success message, status code, and any additional data returned by the API.
752
- * {
753
- * Message: string,
754
- * StatusCode: number,
755
- * Result: GetProviderStepTypeCountsOutput[]
756
- * }
757
- **/
758
- export async function GetMyInboxCategoryWithCounts(
759
- AuthToken = null,
760
- Timeout = 30000,
761
- RequiredHeaderValue = null
762
- ) {
763
- let APIResponse = await apiHandler.PostMethod(
764
- RequestStepsAPIConstants.uriGetProviderStepTypeCounts(),
765
- { RequestStepStatus: "Active" },
766
- AuthToken,
767
- Timeout,
768
- RequiredHeaderValue
769
- );
770
- return APIResponse;
771
- }