@ricado/api-client 2.3.28 → 2.4.1

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.
Files changed (51) hide show
  1. package/dist/ricado.api.client.js +1 -1
  2. package/lib/Controllers/Lab/Site/DehydratorController.js +198 -0
  3. package/lib/Controllers/Lab/Site/FruitProfileController.js +204 -0
  4. package/lib/Controllers/Lab/Site/LabController.js +222 -0
  5. package/lib/Controllers/Lab/Site/RackController.js +222 -0
  6. package/lib/Controllers/Lab/Site/RackPositionController.js +207 -0
  7. package/lib/Controllers/Lab/Site/SampleController.js +1023 -0
  8. package/lib/Controllers/Lab/Site/SampleFailureReasonController.js +192 -0
  9. package/lib/Controllers/Lab/Site/SampleResultController.js +905 -0
  10. package/lib/Controllers/Lab/Site/index.js +46 -0
  11. package/lib/Controllers/Lab/index.js +25 -0
  12. package/lib/Controllers/Packhouse/Site/ShiftController.js +304 -0
  13. package/lib/Controllers/index.js +9 -6
  14. package/lib/Models/Lab/Site/DehydratorModel.js +250 -0
  15. package/lib/Models/Lab/Site/FruitProfileModel.js +303 -0
  16. package/lib/Models/Lab/Site/LabModel.js +365 -0
  17. package/lib/Models/Lab/Site/RackModel.js +358 -0
  18. package/lib/Models/Lab/Site/RackPositionModel.js +525 -0
  19. package/lib/Models/Lab/Site/SampleFailureReasonModel.js +195 -0
  20. package/lib/Models/Lab/Site/SampleModel.js +545 -0
  21. package/lib/Models/Lab/Site/SampleResultModel.js +545 -0
  22. package/lib/Models/Lab/Site/index.js +46 -0
  23. package/lib/Models/Lab/index.js +25 -0
  24. package/lib/Models/index.js +7 -4
  25. package/lib/PackageVersion.js +1 -1
  26. package/lib/index.d.ts +10441 -7526
  27. package/package.json +1 -1
  28. package/src/Controllers/Lab/Site/DehydratorController.js +175 -0
  29. package/src/Controllers/Lab/Site/FruitProfileController.js +181 -0
  30. package/src/Controllers/Lab/Site/LabController.js +199 -0
  31. package/src/Controllers/Lab/Site/RackController.js +199 -0
  32. package/src/Controllers/Lab/Site/RackPositionController.js +184 -0
  33. package/src/Controllers/Lab/Site/SampleController.js +1160 -0
  34. package/src/Controllers/Lab/Site/SampleFailureReasonController.js +169 -0
  35. package/src/Controllers/Lab/Site/SampleResultController.js +1036 -0
  36. package/src/Controllers/Lab/Site/index.js +30 -0
  37. package/src/Controllers/Lab/index.js +16 -0
  38. package/src/Controllers/Packhouse/Site/ShiftController.js +367 -0
  39. package/src/Controllers/index.js +2 -0
  40. package/src/Models/Lab/Site/DehydratorModel.js +234 -0
  41. package/src/Models/Lab/Site/FruitProfileModel.js +290 -0
  42. package/src/Models/Lab/Site/LabModel.js +372 -0
  43. package/src/Models/Lab/Site/RackModel.js +358 -0
  44. package/src/Models/Lab/Site/RackPositionModel.js +600 -0
  45. package/src/Models/Lab/Site/SampleFailureReasonModel.js +170 -0
  46. package/src/Models/Lab/Site/SampleModel.js +565 -0
  47. package/src/Models/Lab/Site/SampleResultModel.js +565 -0
  48. package/src/Models/Lab/Site/index.js +30 -0
  49. package/src/Models/Lab/index.js +16 -0
  50. package/src/Models/index.js +2 -0
  51. package/src/PackageVersion.js +1 -1
@@ -0,0 +1,1160 @@
1
+ /**
2
+ * File Auto-Generated by the RICADO Gen 4 PHP API Project
3
+ *
4
+ * Do Not Edit this File Manually!
5
+ */
6
+
7
+ import RequestHelper from '../../../RequestHelper';
8
+ import SampleModel from '../../../Models/Lab/Site/SampleModel';
9
+ import SampleResultModel from '../../../Models/Lab/Site/SampleResultModel';
10
+
11
+ /**
12
+ * Controller Class for Samples
13
+ *
14
+ * @class
15
+ */
16
+ class SampleController
17
+ {
18
+ /**
19
+ * Retrieve a Sample [GET /lab/sites/{siteId}/samples/{id}]
20
+ *
21
+ * @static
22
+ * @public
23
+ * @param {number} siteId The Site ID
24
+ * @param {string} id The Sample ID
25
+ * @return {Promise<SampleModel>}
26
+ */
27
+ static getOne(siteId, id)
28
+ {
29
+ return new Promise((resolve, reject) => {
30
+ RequestHelper.getRequest(`/lab/sites/${siteId}/samples/${id}`)
31
+ .then((result) => {
32
+ let resolveValue = (function(){
33
+ return SampleModel.fromJSON(result, siteId);
34
+ }());
35
+
36
+ resolve(resolveValue);
37
+ })
38
+ .catch(error => reject(error));
39
+ });
40
+ }
41
+
42
+ /**
43
+ * Update a Sample [PATCH /lab/sites/{siteId}/samples/{id}]
44
+ *
45
+ * @static
46
+ * @public
47
+ * @param {number} siteId The Site ID
48
+ * @param {string} id The Sample ID
49
+ * @param {SampleController.UpdateData} updateData The Sample Update Data
50
+ * @return {Promise<SampleModel>}
51
+ */
52
+ static update(siteId, id, updateData)
53
+ {
54
+ return new Promise((resolve, reject) => {
55
+ RequestHelper.patchRequest(`/lab/sites/${siteId}/samples/${id}`, updateData)
56
+ .then((result) => {
57
+ let resolveValue = (function(){
58
+ return SampleModel.fromJSON(result, siteId);
59
+ }());
60
+
61
+ resolve(resolveValue);
62
+ })
63
+ .catch(error => reject(error));
64
+ });
65
+ }
66
+
67
+ /**
68
+ * Delete a Sample [DELETE /lab/sites/{siteId}/samples/{id}]
69
+ *
70
+ * @static
71
+ * @public
72
+ * @param {number} siteId The Site ID
73
+ * @param {string} id The Sample ID
74
+ * @return {Promise<boolean>}
75
+ */
76
+ static delete(siteId, id)
77
+ {
78
+ return new Promise((resolve, reject) => {
79
+ RequestHelper.deleteRequest(`/lab/sites/${siteId}/samples/${id}`)
80
+ .then((result) => {
81
+ resolve(result ?? true);
82
+ })
83
+ .catch(error => reject(error));
84
+ });
85
+ }
86
+
87
+ /**
88
+ * Retrieve Comments [GET /lab/sites/{siteId}/samples/{id}/comments]
89
+ *
90
+ * Retrieves Comments for a Sample
91
+ *
92
+ * @static
93
+ * @public
94
+ * @param {number} siteId The Site ID
95
+ * @param {string} id The Sample ID
96
+ * @return {Promise<Array<SampleController.CommentItem>>}
97
+ */
98
+ static getComments(siteId, id)
99
+ {
100
+ return new Promise((resolve, reject) => {
101
+ RequestHelper.getRequest(`/lab/sites/${siteId}/samples/${id}/comments`)
102
+ .then((result) => {
103
+ let resolveValue = (function(){
104
+ if(Array.isArray(result) !== true)
105
+ {
106
+ return [];
107
+ }
108
+
109
+ return result.map((resultItem) => {
110
+ return (function(){
111
+ let resultItemObject = {};
112
+
113
+ if(typeof resultItem === 'object' && 'id' in resultItem)
114
+ {
115
+ resultItemObject.id = (function(){
116
+ if(typeof resultItem.id !== 'string')
117
+ {
118
+ return String(resultItem.id);
119
+ }
120
+
121
+ return resultItem.id;
122
+ }());
123
+ }
124
+ else
125
+ {
126
+ resultItemObject.id = "";
127
+ }
128
+
129
+ if(typeof resultItem === 'object' && 'userAccount' in resultItem)
130
+ {
131
+ resultItemObject.userAccount = (function(){
132
+ let userAccountObject = {};
133
+
134
+ if(typeof resultItem.userAccount === 'object' && 'id' in resultItem.userAccount)
135
+ {
136
+ userAccountObject.id = (function(){
137
+ if(resultItem.userAccount.id === null)
138
+ {
139
+ return null;
140
+ }
141
+
142
+ if(typeof resultItem.userAccount.id !== 'string')
143
+ {
144
+ return String(resultItem.userAccount.id);
145
+ }
146
+
147
+ return resultItem.userAccount.id;
148
+ }());
149
+ }
150
+ else
151
+ {
152
+ userAccountObject.id = null;
153
+ }
154
+
155
+ if(typeof resultItem.userAccount === 'object' && 'firstName' in resultItem.userAccount)
156
+ {
157
+ userAccountObject.firstName = (function(){
158
+ if(resultItem.userAccount.firstName === null)
159
+ {
160
+ return null;
161
+ }
162
+
163
+ if(typeof resultItem.userAccount.firstName !== 'string')
164
+ {
165
+ return String(resultItem.userAccount.firstName);
166
+ }
167
+
168
+ return resultItem.userAccount.firstName;
169
+ }());
170
+ }
171
+ else
172
+ {
173
+ userAccountObject.firstName = null;
174
+ }
175
+
176
+ if(typeof resultItem.userAccount === 'object' && 'lastName' in resultItem.userAccount)
177
+ {
178
+ userAccountObject.lastName = (function(){
179
+ if(resultItem.userAccount.lastName === null)
180
+ {
181
+ return null;
182
+ }
183
+
184
+ if(typeof resultItem.userAccount.lastName !== 'string')
185
+ {
186
+ return String(resultItem.userAccount.lastName);
187
+ }
188
+
189
+ return resultItem.userAccount.lastName;
190
+ }());
191
+ }
192
+ else
193
+ {
194
+ userAccountObject.lastName = null;
195
+ }
196
+
197
+ return userAccountObject;
198
+ }());
199
+ }
200
+ else
201
+ {
202
+ resultItemObject.userAccount = (function(){
203
+ let userAccountDefaultValue = {};
204
+
205
+ userAccountDefaultValue.id = null;
206
+
207
+ userAccountDefaultValue.firstName = null;
208
+
209
+ userAccountDefaultValue.lastName = null;
210
+
211
+ return userAccountDefaultValue;
212
+ }());
213
+ }
214
+
215
+ if(typeof resultItem === 'object' && 'content' in resultItem)
216
+ {
217
+ resultItemObject.content = (function(){
218
+ if(resultItem.content === null)
219
+ {
220
+ return null;
221
+ }
222
+
223
+ if(typeof resultItem.content !== 'string')
224
+ {
225
+ return String(resultItem.content);
226
+ }
227
+
228
+ return resultItem.content;
229
+ }());
230
+ }
231
+ else
232
+ {
233
+ resultItemObject.content = null;
234
+ }
235
+
236
+ if(typeof resultItem === 'object' && 'createdTimestamp' in resultItem)
237
+ {
238
+ resultItemObject.createdTimestamp = (function(){
239
+ if(resultItem.createdTimestamp === null)
240
+ {
241
+ return null;
242
+ }
243
+
244
+ if(typeof resultItem.createdTimestamp !== 'string')
245
+ {
246
+ return new Date(String(resultItem.createdTimestamp));
247
+ }
248
+
249
+ return new Date(resultItem.createdTimestamp);
250
+ }());
251
+ }
252
+ else
253
+ {
254
+ resultItemObject.createdTimestamp = null;
255
+ }
256
+
257
+ if(typeof resultItem === 'object' && 'updatedTimestamp' in resultItem)
258
+ {
259
+ resultItemObject.updatedTimestamp = (function(){
260
+ if(resultItem.updatedTimestamp === null)
261
+ {
262
+ return null;
263
+ }
264
+
265
+ if(typeof resultItem.updatedTimestamp !== 'string')
266
+ {
267
+ return new Date(String(resultItem.updatedTimestamp));
268
+ }
269
+
270
+ return new Date(resultItem.updatedTimestamp);
271
+ }());
272
+ }
273
+ else
274
+ {
275
+ resultItemObject.updatedTimestamp = null;
276
+ }
277
+
278
+ return resultItemObject;
279
+ }());
280
+ });
281
+ }());
282
+
283
+ resolve(resolveValue);
284
+ })
285
+ .catch(error => reject(error));
286
+ });
287
+ }
288
+
289
+ /**
290
+ * Create a Comment [POST /lab/sites/{siteId}/samples/{id}/comments]
291
+ *
292
+ * Create a Comment for a Sample
293
+ *
294
+ * @static
295
+ * @public
296
+ * @param {number} siteId The Site ID
297
+ * @param {string} id The Sample ID
298
+ * @param {string} content The Content of the New Comment
299
+ * @return {Promise<SampleController.CommentItem>}
300
+ */
301
+ static createComment(siteId, id, content)
302
+ {
303
+ return new Promise((resolve, reject) => {
304
+ RequestHelper.postRequest(`/lab/sites/${siteId}/samples/${id}/comments`, {content})
305
+ .then((result) => {
306
+ let resolveValue = (function(){
307
+ let resultObject = {};
308
+
309
+ if(typeof result === 'object' && 'id' in result)
310
+ {
311
+ resultObject.id = (function(){
312
+ if(typeof result.id !== 'string')
313
+ {
314
+ return String(result.id);
315
+ }
316
+
317
+ return result.id;
318
+ }());
319
+ }
320
+ else
321
+ {
322
+ resultObject.id = "";
323
+ }
324
+
325
+ if(typeof result === 'object' && 'userAccount' in result)
326
+ {
327
+ resultObject.userAccount = (function(){
328
+ let userAccountObject = {};
329
+
330
+ if(typeof result.userAccount === 'object' && 'id' in result.userAccount)
331
+ {
332
+ userAccountObject.id = (function(){
333
+ if(result.userAccount.id === null)
334
+ {
335
+ return null;
336
+ }
337
+
338
+ if(typeof result.userAccount.id !== 'string')
339
+ {
340
+ return String(result.userAccount.id);
341
+ }
342
+
343
+ return result.userAccount.id;
344
+ }());
345
+ }
346
+ else
347
+ {
348
+ userAccountObject.id = null;
349
+ }
350
+
351
+ if(typeof result.userAccount === 'object' && 'firstName' in result.userAccount)
352
+ {
353
+ userAccountObject.firstName = (function(){
354
+ if(result.userAccount.firstName === null)
355
+ {
356
+ return null;
357
+ }
358
+
359
+ if(typeof result.userAccount.firstName !== 'string')
360
+ {
361
+ return String(result.userAccount.firstName);
362
+ }
363
+
364
+ return result.userAccount.firstName;
365
+ }());
366
+ }
367
+ else
368
+ {
369
+ userAccountObject.firstName = null;
370
+ }
371
+
372
+ if(typeof result.userAccount === 'object' && 'lastName' in result.userAccount)
373
+ {
374
+ userAccountObject.lastName = (function(){
375
+ if(result.userAccount.lastName === null)
376
+ {
377
+ return null;
378
+ }
379
+
380
+ if(typeof result.userAccount.lastName !== 'string')
381
+ {
382
+ return String(result.userAccount.lastName);
383
+ }
384
+
385
+ return result.userAccount.lastName;
386
+ }());
387
+ }
388
+ else
389
+ {
390
+ userAccountObject.lastName = null;
391
+ }
392
+
393
+ return userAccountObject;
394
+ }());
395
+ }
396
+ else
397
+ {
398
+ resultObject.userAccount = (function(){
399
+ let userAccountDefaultValue = {};
400
+
401
+ userAccountDefaultValue.id = null;
402
+
403
+ userAccountDefaultValue.firstName = null;
404
+
405
+ userAccountDefaultValue.lastName = null;
406
+
407
+ return userAccountDefaultValue;
408
+ }());
409
+ }
410
+
411
+ if(typeof result === 'object' && 'content' in result)
412
+ {
413
+ resultObject.content = (function(){
414
+ if(result.content === null)
415
+ {
416
+ return null;
417
+ }
418
+
419
+ if(typeof result.content !== 'string')
420
+ {
421
+ return String(result.content);
422
+ }
423
+
424
+ return result.content;
425
+ }());
426
+ }
427
+ else
428
+ {
429
+ resultObject.content = null;
430
+ }
431
+
432
+ if(typeof result === 'object' && 'createdTimestamp' in result)
433
+ {
434
+ resultObject.createdTimestamp = (function(){
435
+ if(result.createdTimestamp === null)
436
+ {
437
+ return null;
438
+ }
439
+
440
+ if(typeof result.createdTimestamp !== 'string')
441
+ {
442
+ return new Date(String(result.createdTimestamp));
443
+ }
444
+
445
+ return new Date(result.createdTimestamp);
446
+ }());
447
+ }
448
+ else
449
+ {
450
+ resultObject.createdTimestamp = null;
451
+ }
452
+
453
+ if(typeof result === 'object' && 'updatedTimestamp' in result)
454
+ {
455
+ resultObject.updatedTimestamp = (function(){
456
+ if(result.updatedTimestamp === null)
457
+ {
458
+ return null;
459
+ }
460
+
461
+ if(typeof result.updatedTimestamp !== 'string')
462
+ {
463
+ return new Date(String(result.updatedTimestamp));
464
+ }
465
+
466
+ return new Date(result.updatedTimestamp);
467
+ }());
468
+ }
469
+ else
470
+ {
471
+ resultObject.updatedTimestamp = null;
472
+ }
473
+
474
+ return resultObject;
475
+ }());
476
+
477
+ resolve(resolveValue);
478
+ })
479
+ .catch(error => reject(error));
480
+ });
481
+ }
482
+
483
+ /**
484
+ * Retrieve a Comment [GET /lab/sites/{siteId}/samples/{id}/comments/{commentId}]
485
+ *
486
+ * Retrieves Comments for a Sample
487
+ *
488
+ * @static
489
+ * @public
490
+ * @param {number} siteId The Site ID
491
+ * @param {string} id The Sample ID
492
+ * @param {string} commentId The Comment ID
493
+ * @return {Promise<SampleController.CommentItem>}
494
+ */
495
+ static getOneComment(siteId, id, commentId)
496
+ {
497
+ return new Promise((resolve, reject) => {
498
+ RequestHelper.getRequest(`/lab/sites/${siteId}/samples/${id}/comments/${commentId}`)
499
+ .then((result) => {
500
+ let resolveValue = (function(){
501
+ let resultObject = {};
502
+
503
+ if(typeof result === 'object' && 'id' in result)
504
+ {
505
+ resultObject.id = (function(){
506
+ if(typeof result.id !== 'string')
507
+ {
508
+ return String(result.id);
509
+ }
510
+
511
+ return result.id;
512
+ }());
513
+ }
514
+ else
515
+ {
516
+ resultObject.id = "";
517
+ }
518
+
519
+ if(typeof result === 'object' && 'userAccount' in result)
520
+ {
521
+ resultObject.userAccount = (function(){
522
+ let userAccountObject = {};
523
+
524
+ if(typeof result.userAccount === 'object' && 'id' in result.userAccount)
525
+ {
526
+ userAccountObject.id = (function(){
527
+ if(result.userAccount.id === null)
528
+ {
529
+ return null;
530
+ }
531
+
532
+ if(typeof result.userAccount.id !== 'string')
533
+ {
534
+ return String(result.userAccount.id);
535
+ }
536
+
537
+ return result.userAccount.id;
538
+ }());
539
+ }
540
+ else
541
+ {
542
+ userAccountObject.id = null;
543
+ }
544
+
545
+ if(typeof result.userAccount === 'object' && 'firstName' in result.userAccount)
546
+ {
547
+ userAccountObject.firstName = (function(){
548
+ if(result.userAccount.firstName === null)
549
+ {
550
+ return null;
551
+ }
552
+
553
+ if(typeof result.userAccount.firstName !== 'string')
554
+ {
555
+ return String(result.userAccount.firstName);
556
+ }
557
+
558
+ return result.userAccount.firstName;
559
+ }());
560
+ }
561
+ else
562
+ {
563
+ userAccountObject.firstName = null;
564
+ }
565
+
566
+ if(typeof result.userAccount === 'object' && 'lastName' in result.userAccount)
567
+ {
568
+ userAccountObject.lastName = (function(){
569
+ if(result.userAccount.lastName === null)
570
+ {
571
+ return null;
572
+ }
573
+
574
+ if(typeof result.userAccount.lastName !== 'string')
575
+ {
576
+ return String(result.userAccount.lastName);
577
+ }
578
+
579
+ return result.userAccount.lastName;
580
+ }());
581
+ }
582
+ else
583
+ {
584
+ userAccountObject.lastName = null;
585
+ }
586
+
587
+ return userAccountObject;
588
+ }());
589
+ }
590
+ else
591
+ {
592
+ resultObject.userAccount = (function(){
593
+ let userAccountDefaultValue = {};
594
+
595
+ userAccountDefaultValue.id = null;
596
+
597
+ userAccountDefaultValue.firstName = null;
598
+
599
+ userAccountDefaultValue.lastName = null;
600
+
601
+ return userAccountDefaultValue;
602
+ }());
603
+ }
604
+
605
+ if(typeof result === 'object' && 'content' in result)
606
+ {
607
+ resultObject.content = (function(){
608
+ if(result.content === null)
609
+ {
610
+ return null;
611
+ }
612
+
613
+ if(typeof result.content !== 'string')
614
+ {
615
+ return String(result.content);
616
+ }
617
+
618
+ return result.content;
619
+ }());
620
+ }
621
+ else
622
+ {
623
+ resultObject.content = null;
624
+ }
625
+
626
+ if(typeof result === 'object' && 'createdTimestamp' in result)
627
+ {
628
+ resultObject.createdTimestamp = (function(){
629
+ if(result.createdTimestamp === null)
630
+ {
631
+ return null;
632
+ }
633
+
634
+ if(typeof result.createdTimestamp !== 'string')
635
+ {
636
+ return new Date(String(result.createdTimestamp));
637
+ }
638
+
639
+ return new Date(result.createdTimestamp);
640
+ }());
641
+ }
642
+ else
643
+ {
644
+ resultObject.createdTimestamp = null;
645
+ }
646
+
647
+ if(typeof result === 'object' && 'updatedTimestamp' in result)
648
+ {
649
+ resultObject.updatedTimestamp = (function(){
650
+ if(result.updatedTimestamp === null)
651
+ {
652
+ return null;
653
+ }
654
+
655
+ if(typeof result.updatedTimestamp !== 'string')
656
+ {
657
+ return new Date(String(result.updatedTimestamp));
658
+ }
659
+
660
+ return new Date(result.updatedTimestamp);
661
+ }());
662
+ }
663
+ else
664
+ {
665
+ resultObject.updatedTimestamp = null;
666
+ }
667
+
668
+ return resultObject;
669
+ }());
670
+
671
+ resolve(resolveValue);
672
+ })
673
+ .catch(error => reject(error));
674
+ });
675
+ }
676
+
677
+ /**
678
+ * Update a Comment [PATCH /lab/sites/{siteId}/samples/{id}/comments/{commentId}]
679
+ *
680
+ * Update a Comment for a Sample
681
+ *
682
+ * @static
683
+ * @public
684
+ * @param {number} siteId The Site ID
685
+ * @param {string} id The Sample ID
686
+ * @param {string} commentId The Comment ID
687
+ * @param {string} content The Updated Content for the Comment
688
+ * @return {Promise<SampleController.CommentItem>}
689
+ */
690
+ static updateOneComment(siteId, id, commentId, content)
691
+ {
692
+ return new Promise((resolve, reject) => {
693
+ RequestHelper.patchRequest(`/lab/sites/${siteId}/samples/${id}/comments/${commentId}`, {content})
694
+ .then((result) => {
695
+ let resolveValue = (function(){
696
+ let resultObject = {};
697
+
698
+ if(typeof result === 'object' && 'id' in result)
699
+ {
700
+ resultObject.id = (function(){
701
+ if(typeof result.id !== 'string')
702
+ {
703
+ return String(result.id);
704
+ }
705
+
706
+ return result.id;
707
+ }());
708
+ }
709
+ else
710
+ {
711
+ resultObject.id = "";
712
+ }
713
+
714
+ if(typeof result === 'object' && 'userAccount' in result)
715
+ {
716
+ resultObject.userAccount = (function(){
717
+ let userAccountObject = {};
718
+
719
+ if(typeof result.userAccount === 'object' && 'id' in result.userAccount)
720
+ {
721
+ userAccountObject.id = (function(){
722
+ if(result.userAccount.id === null)
723
+ {
724
+ return null;
725
+ }
726
+
727
+ if(typeof result.userAccount.id !== 'string')
728
+ {
729
+ return String(result.userAccount.id);
730
+ }
731
+
732
+ return result.userAccount.id;
733
+ }());
734
+ }
735
+ else
736
+ {
737
+ userAccountObject.id = null;
738
+ }
739
+
740
+ if(typeof result.userAccount === 'object' && 'firstName' in result.userAccount)
741
+ {
742
+ userAccountObject.firstName = (function(){
743
+ if(result.userAccount.firstName === null)
744
+ {
745
+ return null;
746
+ }
747
+
748
+ if(typeof result.userAccount.firstName !== 'string')
749
+ {
750
+ return String(result.userAccount.firstName);
751
+ }
752
+
753
+ return result.userAccount.firstName;
754
+ }());
755
+ }
756
+ else
757
+ {
758
+ userAccountObject.firstName = null;
759
+ }
760
+
761
+ if(typeof result.userAccount === 'object' && 'lastName' in result.userAccount)
762
+ {
763
+ userAccountObject.lastName = (function(){
764
+ if(result.userAccount.lastName === null)
765
+ {
766
+ return null;
767
+ }
768
+
769
+ if(typeof result.userAccount.lastName !== 'string')
770
+ {
771
+ return String(result.userAccount.lastName);
772
+ }
773
+
774
+ return result.userAccount.lastName;
775
+ }());
776
+ }
777
+ else
778
+ {
779
+ userAccountObject.lastName = null;
780
+ }
781
+
782
+ return userAccountObject;
783
+ }());
784
+ }
785
+ else
786
+ {
787
+ resultObject.userAccount = (function(){
788
+ let userAccountDefaultValue = {};
789
+
790
+ userAccountDefaultValue.id = null;
791
+
792
+ userAccountDefaultValue.firstName = null;
793
+
794
+ userAccountDefaultValue.lastName = null;
795
+
796
+ return userAccountDefaultValue;
797
+ }());
798
+ }
799
+
800
+ if(typeof result === 'object' && 'content' in result)
801
+ {
802
+ resultObject.content = (function(){
803
+ if(result.content === null)
804
+ {
805
+ return null;
806
+ }
807
+
808
+ if(typeof result.content !== 'string')
809
+ {
810
+ return String(result.content);
811
+ }
812
+
813
+ return result.content;
814
+ }());
815
+ }
816
+ else
817
+ {
818
+ resultObject.content = null;
819
+ }
820
+
821
+ if(typeof result === 'object' && 'createdTimestamp' in result)
822
+ {
823
+ resultObject.createdTimestamp = (function(){
824
+ if(result.createdTimestamp === null)
825
+ {
826
+ return null;
827
+ }
828
+
829
+ if(typeof result.createdTimestamp !== 'string')
830
+ {
831
+ return new Date(String(result.createdTimestamp));
832
+ }
833
+
834
+ return new Date(result.createdTimestamp);
835
+ }());
836
+ }
837
+ else
838
+ {
839
+ resultObject.createdTimestamp = null;
840
+ }
841
+
842
+ if(typeof result === 'object' && 'updatedTimestamp' in result)
843
+ {
844
+ resultObject.updatedTimestamp = (function(){
845
+ if(result.updatedTimestamp === null)
846
+ {
847
+ return null;
848
+ }
849
+
850
+ if(typeof result.updatedTimestamp !== 'string')
851
+ {
852
+ return new Date(String(result.updatedTimestamp));
853
+ }
854
+
855
+ return new Date(result.updatedTimestamp);
856
+ }());
857
+ }
858
+ else
859
+ {
860
+ resultObject.updatedTimestamp = null;
861
+ }
862
+
863
+ return resultObject;
864
+ }());
865
+
866
+ resolve(resolveValue);
867
+ })
868
+ .catch(error => reject(error));
869
+ });
870
+ }
871
+
872
+ /**
873
+ * Delete a Comment [DELETE /lab/sites/{siteId}/samples/{id}/comments/{commentId}]
874
+ *
875
+ * Delete a Comment for a Sample
876
+ *
877
+ * @static
878
+ * @public
879
+ * @param {number} siteId The Site ID
880
+ * @param {string} id The Sample ID
881
+ * @param {string} commentId The Comment ID
882
+ * @return {Promise<boolean>}
883
+ */
884
+ static deleteOneComment(siteId, id, commentId)
885
+ {
886
+ return new Promise((resolve, reject) => {
887
+ RequestHelper.deleteRequest(`/lab/sites/${siteId}/samples/${id}/comments/${commentId}`)
888
+ .then((result) => {
889
+ resolve(result ?? true);
890
+ })
891
+ .catch(error => reject(error));
892
+ });
893
+ }
894
+
895
+ /**
896
+ * Retrieve a Sample Result [GET /lab/sites/{siteId}/samples/{id}/result]
897
+ *
898
+ * Retrieves a Sample Result for a Sample
899
+ *
900
+ * @static
901
+ * @public
902
+ * @param {number} siteId The Site ID
903
+ * @param {string} id The Sample ID
904
+ * @return {Promise<SampleResultModel>}
905
+ */
906
+ static getSampleResult(siteId, id)
907
+ {
908
+ return new Promise((resolve, reject) => {
909
+ RequestHelper.getRequest(`/lab/sites/${siteId}/samples/${id}/result`)
910
+ .then((result) => {
911
+ let resolveValue = (function(){
912
+ return SampleResultModel.fromJSON(result, siteId);
913
+ }());
914
+
915
+ resolve(resolveValue);
916
+ })
917
+ .catch(error => reject(error));
918
+ });
919
+ }
920
+
921
+ /**
922
+ * Retrieve Temperature Data [GET /lab/sites/{siteId}/samples/{id}/temperature-data]
923
+ *
924
+ * Retrieves Temperature Data for a Sample
925
+ *
926
+ * @static
927
+ * @public
928
+ * @param {number} siteId The Site ID
929
+ * @param {string} id The Sample ID
930
+ * @return {Promise<Array<SampleController.TemperatureDataItem>>}
931
+ */
932
+ static getTemperatureData(siteId, id)
933
+ {
934
+ return new Promise((resolve, reject) => {
935
+ RequestHelper.getRequest(`/lab/sites/${siteId}/samples/${id}/temperature-data`)
936
+ .then((result) => {
937
+ let resolveValue = (function(){
938
+ if(Array.isArray(result) !== true)
939
+ {
940
+ return [];
941
+ }
942
+
943
+ return result.map((resultItem) => {
944
+ return (function(){
945
+ let resultItemObject = {};
946
+
947
+ if(typeof resultItem === 'object' && 'timestamp' in resultItem)
948
+ {
949
+ resultItemObject.timestamp = (function(){
950
+ if(typeof resultItem.timestamp !== 'string')
951
+ {
952
+ return new Date(String(resultItem.timestamp));
953
+ }
954
+
955
+ return new Date(resultItem.timestamp);
956
+ }());
957
+ }
958
+ else
959
+ {
960
+ resultItemObject.timestamp = new Date();
961
+ }
962
+
963
+ if(typeof resultItem === 'object' && 'temperature' in resultItem)
964
+ {
965
+ resultItemObject.temperature = (function(){
966
+ if(typeof resultItem.temperature !== 'number')
967
+ {
968
+ return Number(resultItem.temperature);
969
+ }
970
+
971
+ return resultItem.temperature;
972
+ }());
973
+ }
974
+ else
975
+ {
976
+ resultItemObject.temperature = 0;
977
+ }
978
+
979
+ return resultItemObject;
980
+ }());
981
+ });
982
+ }());
983
+
984
+ resolve(resolveValue);
985
+ })
986
+ .catch(error => reject(error));
987
+ });
988
+ }
989
+
990
+ /**
991
+ * List all Samples [GET /lab/sites/{siteId}/samples]
992
+ *
993
+ * @static
994
+ * @public
995
+ * @param {number} siteId The Site ID
996
+ * @param {SampleController.GetAllQueryParameters} [queryParameters] The Optional Query Parameters
997
+ * @return {Promise<SampleModel[]>}
998
+ */
999
+ static getAll(siteId, queryParameters = {})
1000
+ {
1001
+ return new Promise((resolve, reject) => {
1002
+ RequestHelper.getRequest(`/lab/sites/${siteId}/samples`, queryParameters)
1003
+ .then((result) => {
1004
+ let resolveValue = (function(){
1005
+ if(Array.isArray(result) !== true)
1006
+ {
1007
+ return [];
1008
+ }
1009
+
1010
+ return result.map((resultItem) => {
1011
+ return (function(){
1012
+ return SampleModel.fromJSON(resultItem, siteId);
1013
+ }());
1014
+ });
1015
+ }());
1016
+
1017
+ resolve(resolveValue);
1018
+ })
1019
+ .catch(error => reject(error));
1020
+ });
1021
+ }
1022
+
1023
+ /**
1024
+ * Create a Sample [POST /lab/sites/{siteId}/samples]
1025
+ *
1026
+ * @static
1027
+ * @public
1028
+ * @param {number} siteId The Site ID
1029
+ * @param {SampleController.CreateData} createData The Sample Create Data
1030
+ * @return {Promise<SampleModel>}
1031
+ */
1032
+ static create(siteId, createData)
1033
+ {
1034
+ return new Promise((resolve, reject) => {
1035
+ RequestHelper.postRequest(`/lab/sites/${siteId}/samples`, createData)
1036
+ .then((result) => {
1037
+ let resolveValue = (function(){
1038
+ return SampleModel.fromJSON(result, siteId);
1039
+ }());
1040
+
1041
+ resolve(resolveValue);
1042
+ })
1043
+ .catch(error => reject(error));
1044
+ });
1045
+ }
1046
+ }
1047
+
1048
+ export default SampleController;
1049
+
1050
+ /**
1051
+ * The Optional Query Parameters for the getAll Function
1052
+ *
1053
+ * @typedef {Object} SampleController.GetAllQueryParameters
1054
+ * @property {string} [labId] The Lab ID this Sample is associated with
1055
+ * @property {string} [sampleNumber] The Numeric Sample Number
1056
+ * @property {string} [createdSource] The Source that Created this Sample
1057
+ * @property {?string} [createdUserId] ID of the User who Created this Sample. Only applies if the `createdSource` is 'System'
1058
+ * @property {?string} [createdUserName] Name of the User who Created this Sample. Only applies if the `createdSource` is 'System'
1059
+ * @property {?string} [publishUserId] ID of the User who Published this Sample
1060
+ * @property {?string} [publishUserName] Name of the User who Published this Sample
1061
+ * @property {string} [fruitProfileId] The Fruit Profile for this Sample
1062
+ * @property {string} [rackPositionId] The Rack Position used for this Sample
1063
+ * @property {string} [dehydratorId] The Dehydrator used for this Sample
1064
+ * @property {?string} [outcome] The Outcome of this Sample
1065
+ * @property {?string} [failureReasonId] A Sample Failure Reason ID if this Sample Failed
1066
+ * @property {?string} [resultId] The Sample Result ID asociated with this Sample
1067
+ * @property {Date} [createdTimestampBegin] Filter by the Timestamp when Samples were Created. Results Greater than or Equal to Timestamp
1068
+ * @property {Date} [createdTimestampEnd] Filter by the Timestamp when Samples were Created. Results Less than or Equal to Timestamp
1069
+ * @property {Date} [scheduledTimestampBegin] Filter by the Timestamp when Samples were Scheduled to Begin. Results Greater than or Equal to Timestamp
1070
+ * @property {Date} [scheduledTimestampEnd] Filter by the Timestamp when Samples were Scheduled to Begin. Results Less than or Equal to Timestamp
1071
+ * @property {Date} [startTimestampBegin] Filter by the Timestamp when Samples were Started. Results Greater than or Equal to Timestamp
1072
+ * @property {Date} [startTimestampEnd] Filter by the Timestamp when Samples were Started. Results Less than or Equal to Timestamp
1073
+ * @property {Date} [finishTimestampBegin] Filter by the Timestamp when Samples were Finished. Results Greater than or Equal to Timestamp
1074
+ * @property {Date} [finishTimestampEnd] Filter by the Timestamp when Samples were Finished. Results Less than or Equal to Timestamp
1075
+ * @property {Date} [publishTimestampBegin] Filter by the Timestamp when Samples were Published. Results Greater than or Equal to Timestamp
1076
+ * @property {Date} [publishTimestampEnd] Filter by the Timestamp when Samples were Published. Results Less than or Equal to Timestamp
1077
+ * @property {Date} [updateTimestampBegin] Filter by the Timestamp when Samples were last Updated. Results Greater than or Equal to Timestamp
1078
+ * @property {Date} [updateTimestampEnd] Filter by the Timestamp when Samples were last Updated. Results Less than or Equal to Timestamp
1079
+ * @memberof Controllers.Lab.Site
1080
+ */
1081
+
1082
+ /**
1083
+ * The Create Data for a Sample
1084
+ *
1085
+ * @typedef {Object} SampleController.CreateData
1086
+ * @property {string} labId The Lab ID this Sample is associated with
1087
+ * @property {string} [sampleNumber] The Numeric Sample Number
1088
+ * @property {Date} [createdTimestamp] When this Sample was Created
1089
+ * @property {string} createdSource The Source that Created this Sample
1090
+ * @property {?string} [createdUserId] ID of the User who Created this Sample. Only applies if the `createdSource` is 'System'
1091
+ * @property {?string} [createdUserName] Name of the User who Created this Sample. Only applies if the `createdSource` is 'System'
1092
+ * @property {?Date} [scheduledTimestamp] Optional Scheduled Timestamp when this Sample should Begin
1093
+ * @property {?Date} [startTimestamp] When this Sample was Started
1094
+ * @property {?Date} [finishTimestamp] When this Sample was Finished
1095
+ * @property {?Date} [publishTimestamp] When this Sample was Published
1096
+ * @property {?string} [publishUserId] ID of the User who Published this Sample
1097
+ * @property {?string} [publishUserName] Name of the User who Published this Sample
1098
+ * @property {string} fruitProfileId The Fruit Profile for this Sample
1099
+ * @property {string} rackPositionId The Rack Position used for this Sample
1100
+ * @property {string} dehydratorId The Dehydrator used for this Sample
1101
+ * @property {?string} [outcome] The Outcome of this Sample
1102
+ * @property {?string} [failureReasonId] A Sample Failure Reason ID if this Sample Failed
1103
+ * @property {?string} [resultId] The Sample Result ID asociated with this Sample
1104
+ * @memberof Controllers.Lab.Site
1105
+ */
1106
+
1107
+ /**
1108
+ * The Update Data for a Sample
1109
+ *
1110
+ * @typedef {Object} SampleController.UpdateData
1111
+ * @property {string} [labId] The Lab ID this Sample is associated with
1112
+ * @property {Date} [createdTimestamp] When this Sample was Created
1113
+ * @property {string} [createdSource] The Source that Created this Sample
1114
+ * @property {?string} [createdUserId] ID of the User who Created this Sample. Only applies if the `createdSource` is 'System'
1115
+ * @property {?string} [createdUserName] Name of the User who Created this Sample. Only applies if the `createdSource` is 'System'
1116
+ * @property {?Date} [scheduledTimestamp] Optional Scheduled Timestamp when this Sample should Begin
1117
+ * @property {?Date} [startTimestamp] When this Sample was Started
1118
+ * @property {?Date} [finishTimestamp] When this Sample was Finished
1119
+ * @property {?Date} [publishTimestamp] When this Sample was Published
1120
+ * @property {?string} [publishUserId] ID of the User who Published this Sample
1121
+ * @property {?string} [publishUserName] Name of the User who Published this Sample
1122
+ * @property {string} [fruitProfileId] The Fruit Profile for this Sample
1123
+ * @property {string} [rackPositionId] The Rack Position used for this Sample
1124
+ * @property {string} [dehydratorId] The Dehydrator used for this Sample
1125
+ * @property {?string} [outcome] The Outcome of this Sample
1126
+ * @property {?string} [failureReasonId] A Sample Failure Reason ID if this Sample Failed
1127
+ * @property {?string} [resultId] The Sample Result ID asociated with this Sample
1128
+ * @memberof Controllers.Lab.Site
1129
+ */
1130
+
1131
+ /**
1132
+ * A **UserAccount** Type
1133
+ *
1134
+ * @typedef {Object} SampleController.UserAccount
1135
+ * @property {?string} id The User Account ID
1136
+ * @property {?string} firstName The User's First Name
1137
+ * @property {?string} lastName The User's Last Name
1138
+ * @memberof Controllers.Lab.Site
1139
+ */
1140
+
1141
+ /**
1142
+ * A **CommentItem** Type
1143
+ *
1144
+ * @typedef {Object} SampleController.CommentItem
1145
+ * @property {string} id The Comment ID
1146
+ * @property {SampleController.UserAccount} userAccount
1147
+ * @property {?string} content The Content of the Comment
1148
+ * @property {?Date} createdTimestamp When the Comment was Created
1149
+ * @property {?Date} updatedTimestamp When the Comment was last Updated
1150
+ * @memberof Controllers.Lab.Site
1151
+ */
1152
+
1153
+ /**
1154
+ * A **TemperatureDataItem** Type
1155
+ *
1156
+ * @typedef {Object} SampleController.TemperatureDataItem
1157
+ * @property {Date} timestamp The Timestamp for the Temperature Value
1158
+ * @property {number} temperature The Temperature Value
1159
+ * @memberof Controllers.Lab.Site
1160
+ */