@ricado/api-client 2.3.28 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +927 -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 +10348 -7537
  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 +1067 -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,1067 @@
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 Temperature Data [GET /lab/sites/{siteId}/samples/{id}]
20
+ *
21
+ * Retrieves Temperature Data for a Sample
22
+ *
23
+ * @static
24
+ * @public
25
+ * @param {number} siteId The Site ID
26
+ * @param {string} id The Sample ID
27
+ * @return {Promise<Array<SampleController.TemperatureDataItem>>}
28
+ */
29
+ static getTemperatureData(siteId, id)
30
+ {
31
+ return new Promise((resolve, reject) => {
32
+ RequestHelper.getRequest(`/lab/sites/${siteId}/samples/${id}`)
33
+ .then((result) => {
34
+ let resolveValue = (function(){
35
+ if(Array.isArray(result) !== true)
36
+ {
37
+ return [];
38
+ }
39
+
40
+ return result.map((resultItem) => {
41
+ return (function(){
42
+ let resultItemObject = {};
43
+
44
+ if(typeof resultItem === 'object' && 'timestamp' in resultItem)
45
+ {
46
+ resultItemObject.timestamp = (function(){
47
+ if(typeof resultItem.timestamp !== 'string')
48
+ {
49
+ return new Date(String(resultItem.timestamp));
50
+ }
51
+
52
+ return new Date(resultItem.timestamp);
53
+ }());
54
+ }
55
+ else
56
+ {
57
+ resultItemObject.timestamp = new Date();
58
+ }
59
+
60
+ if(typeof resultItem === 'object' && 'temperature' in resultItem)
61
+ {
62
+ resultItemObject.temperature = (function(){
63
+ if(typeof resultItem.temperature !== 'number')
64
+ {
65
+ return Number(resultItem.temperature);
66
+ }
67
+
68
+ return resultItem.temperature;
69
+ }());
70
+ }
71
+ else
72
+ {
73
+ resultItemObject.temperature = 0;
74
+ }
75
+
76
+ return resultItemObject;
77
+ }());
78
+ });
79
+ }());
80
+
81
+ resolve(resolveValue);
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
+ * List all Samples [GET /lab/sites/{siteId}/samples]
923
+ *
924
+ * @static
925
+ * @public
926
+ * @param {number} siteId The Site ID
927
+ * @param {SampleController.GetAllQueryParameters} [queryParameters] The Optional Query Parameters
928
+ * @return {Promise<SampleModel[]>}
929
+ */
930
+ static getAll(siteId, queryParameters = {})
931
+ {
932
+ return new Promise((resolve, reject) => {
933
+ RequestHelper.getRequest(`/lab/sites/${siteId}/samples`, queryParameters)
934
+ .then((result) => {
935
+ let resolveValue = (function(){
936
+ if(Array.isArray(result) !== true)
937
+ {
938
+ return [];
939
+ }
940
+
941
+ return result.map((resultItem) => {
942
+ return (function(){
943
+ return SampleModel.fromJSON(resultItem, siteId);
944
+ }());
945
+ });
946
+ }());
947
+
948
+ resolve(resolveValue);
949
+ })
950
+ .catch(error => reject(error));
951
+ });
952
+ }
953
+
954
+ /**
955
+ * Create a Sample [POST /lab/sites/{siteId}/samples]
956
+ *
957
+ * @static
958
+ * @public
959
+ * @param {number} siteId The Site ID
960
+ * @param {SampleController.CreateData} createData The Sample Create Data
961
+ * @return {Promise<SampleModel>}
962
+ */
963
+ static create(siteId, createData)
964
+ {
965
+ return new Promise((resolve, reject) => {
966
+ RequestHelper.postRequest(`/lab/sites/${siteId}/samples`, createData)
967
+ .then((result) => {
968
+ let resolveValue = (function(){
969
+ return SampleModel.fromJSON(result, siteId);
970
+ }());
971
+
972
+ resolve(resolveValue);
973
+ })
974
+ .catch(error => reject(error));
975
+ });
976
+ }
977
+ }
978
+
979
+ export default SampleController;
980
+
981
+ /**
982
+ * The Optional Query Parameters for the getAll Function
983
+ *
984
+ * @typedef {Object} SampleController.GetAllQueryParameters
985
+ * @property {string} [labId] The Lab ID this Sample is associated with
986
+ * @property {string} [sampleNumber] The Numeric Sample Number
987
+ * @property {string} [createdSource] The Source that Created this Sample
988
+ * @property {?string} [createdUserId] ID of the User who Created this Sample. Only applies if the `createdSource` is 'System'
989
+ * @property {?string} [createdUserName] Name of the User who Created this Sample. Only applies if the `createdSource` is 'System'
990
+ * @property {?string} [publishUserId] ID of the User who Published this Sample
991
+ * @property {?string} [publishUserName] Name of the User who Published this Sample
992
+ * @property {string} [fruitProfileId] The Fruit Profile for this Sample
993
+ * @property {string} [rackPositionId] The Rack Position used for this Sample
994
+ * @property {string} [dehydratorId] The Dehydrator used for this Sample
995
+ * @property {?string} [outcome] The Outcome of this Sample
996
+ * @property {?string} [failureReasonId] A Sample Failure Reason ID if this Sample Failed
997
+ * @property {?string} [resultId] The Sample Result ID asociated with this Sample
998
+ * @property {Date} [createdTimestampBegin] Filter by the Timestamp when Samples were Created. Results Greater than or Equal to Timestamp
999
+ * @property {Date} [createdTimestampEnd] Filter by the Timestamp when Samples were Created. Results Less than or Equal to Timestamp
1000
+ * @property {Date} [scheduledTimestampBegin] Filter by the Timestamp when Samples were Scheduled to Begin. Results Greater than or Equal to Timestamp
1001
+ * @property {Date} [scheduledTimestampEnd] Filter by the Timestamp when Samples were Scheduled to Begin. Results Less than or Equal to Timestamp
1002
+ * @property {Date} [startTimestampBegin] Filter by the Timestamp when Samples were Started. Results Greater than or Equal to Timestamp
1003
+ * @property {Date} [startTimestampEnd] Filter by the Timestamp when Samples were Started. Results Less than or Equal to Timestamp
1004
+ * @property {Date} [finishTimestampBegin] Filter by the Timestamp when Samples were Finished. Results Greater than or Equal to Timestamp
1005
+ * @property {Date} [finishTimestampEnd] Filter by the Timestamp when Samples were Finished. Results Less than or Equal to Timestamp
1006
+ * @property {Date} [publishTimestampBegin] Filter by the Timestamp when Samples were Published. Results Greater than or Equal to Timestamp
1007
+ * @property {Date} [publishTimestampEnd] Filter by the Timestamp when Samples were Published. Results Less than or Equal to Timestamp
1008
+ * @property {Date} [updateTimestampBegin] Filter by the Timestamp when Samples were last Updated. Results Greater than or Equal to Timestamp
1009
+ * @property {Date} [updateTimestampEnd] Filter by the Timestamp when Samples were last Updated. Results Less than or Equal to Timestamp
1010
+ * @memberof Controllers.Lab.Site
1011
+ */
1012
+
1013
+ /**
1014
+ * The Create Data for a Sample
1015
+ *
1016
+ * @typedef {Object} SampleController.CreateData
1017
+ * @property {string} labId The Lab ID this Sample is associated with
1018
+ * @property {string} [sampleNumber] The Numeric Sample Number
1019
+ * @property {Date} [createdTimestamp] When this Sample was Created
1020
+ * @property {string} createdSource The Source that Created this Sample
1021
+ * @property {?string} [createdUserId] ID of the User who Created this Sample. Only applies if the `createdSource` is 'System'
1022
+ * @property {?string} [createdUserName] Name of the User who Created this Sample. Only applies if the `createdSource` is 'System'
1023
+ * @property {?Date} [scheduledTimestamp] Optional Scheduled Timestamp when this Sample should Begin
1024
+ * @property {?Date} [startTimestamp] When this Sample was Started
1025
+ * @property {?Date} [finishTimestamp] When this Sample was Finished
1026
+ * @property {?Date} [publishTimestamp] When this Sample was Published
1027
+ * @property {?string} [publishUserId] ID of the User who Published this Sample
1028
+ * @property {?string} [publishUserName] Name of the User who Published this Sample
1029
+ * @property {string} fruitProfileId The Fruit Profile for this Sample
1030
+ * @property {string} rackPositionId The Rack Position used for this Sample
1031
+ * @property {string} dehydratorId The Dehydrator used for this Sample
1032
+ * @property {?string} [outcome] The Outcome of this Sample
1033
+ * @property {?string} [failureReasonId] A Sample Failure Reason ID if this Sample Failed
1034
+ * @property {?string} [resultId] The Sample Result ID asociated with this Sample
1035
+ * @memberof Controllers.Lab.Site
1036
+ */
1037
+
1038
+ /**
1039
+ * A **TemperatureDataItem** Type
1040
+ *
1041
+ * @typedef {Object} SampleController.TemperatureDataItem
1042
+ * @property {Date} timestamp The Timestamp for the Temperature Value
1043
+ * @property {number} temperature The Temperature Value
1044
+ * @memberof Controllers.Lab.Site
1045
+ */
1046
+
1047
+ /**
1048
+ * A **UserAccount** Type
1049
+ *
1050
+ * @typedef {Object} SampleController.UserAccount
1051
+ * @property {?string} id The User Account ID
1052
+ * @property {?string} firstName The User's First Name
1053
+ * @property {?string} lastName The User's Last Name
1054
+ * @memberof Controllers.Lab.Site
1055
+ */
1056
+
1057
+ /**
1058
+ * A **CommentItem** Type
1059
+ *
1060
+ * @typedef {Object} SampleController.CommentItem
1061
+ * @property {string} id The Comment ID
1062
+ * @property {SampleController.UserAccount} userAccount
1063
+ * @property {?string} content The Content of the Comment
1064
+ * @property {?Date} createdTimestamp When the Comment was Created
1065
+ * @property {?Date} updatedTimestamp When the Comment was last Updated
1066
+ * @memberof Controllers.Lab.Site
1067
+ */