@ricado/api-client 2.5.7 → 2.5.9

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.
@@ -2336,6 +2336,657 @@ class PackrunController
2336
2336
  });
2337
2337
  }
2338
2338
 
2339
+ /**
2340
+ * Retrive a Packrun's Latest Summary Data [GET /packhouse/sites/{siteId}/packruns/{id}/latestSummaryData]
2341
+ *
2342
+ * Retrieves the Latest Summary Data for a Packrun
2343
+ *
2344
+ * @static
2345
+ * @public
2346
+ * @param {number} siteId The Site ID
2347
+ * @param {string} id The Packrun ID
2348
+ * @return {Promise<PackrunController.PackrunLatestSummaryData>}
2349
+ */
2350
+ static getLatestSummaryData(siteId, id)
2351
+ {
2352
+ return new Promise((resolve, reject) => {
2353
+ RequestHelper.getRequest(`/packhouse/sites/${siteId}/packruns/${id}/latestSummaryData`)
2354
+ .then((result) => {
2355
+ let resolveValue = (function(){
2356
+ let resultObject = {};
2357
+
2358
+ if(typeof result === 'object' && 'id' in result)
2359
+ {
2360
+ resultObject.id = (function(){
2361
+ if(typeof result.id !== 'string')
2362
+ {
2363
+ return String(result.id);
2364
+ }
2365
+
2366
+ return result.id;
2367
+ }());
2368
+ }
2369
+ else
2370
+ {
2371
+ resultObject.id = "";
2372
+ }
2373
+
2374
+ if(typeof result === 'object' && 'name' in result)
2375
+ {
2376
+ resultObject.name = (function(){
2377
+ if(typeof result.name !== 'string')
2378
+ {
2379
+ return String(result.name);
2380
+ }
2381
+
2382
+ return result.name;
2383
+ }());
2384
+ }
2385
+ else
2386
+ {
2387
+ resultObject.name = "";
2388
+ }
2389
+
2390
+ if(typeof result === 'object' && 'createdTimestamp' in result)
2391
+ {
2392
+ resultObject.createdTimestamp = (function(){
2393
+ if(typeof result.createdTimestamp !== 'string')
2394
+ {
2395
+ return new Date(String(result.createdTimestamp));
2396
+ }
2397
+
2398
+ return new Date(result.createdTimestamp);
2399
+ }());
2400
+ }
2401
+ else
2402
+ {
2403
+ resultObject.createdTimestamp = new Date();
2404
+ }
2405
+
2406
+ if(typeof result === 'object' && 'growerName' in result)
2407
+ {
2408
+ resultObject.growerName = (function(){
2409
+ if(typeof result.growerName !== 'string')
2410
+ {
2411
+ return String(result.growerName);
2412
+ }
2413
+
2414
+ return result.growerName;
2415
+ }());
2416
+ }
2417
+ else
2418
+ {
2419
+ resultObject.growerName = "";
2420
+ }
2421
+
2422
+ if(typeof result === 'object' && 'growerCode' in result)
2423
+ {
2424
+ resultObject.growerCode = (function(){
2425
+ if(typeof result.growerCode !== 'string')
2426
+ {
2427
+ return String(result.growerCode);
2428
+ }
2429
+
2430
+ return result.growerCode;
2431
+ }());
2432
+ }
2433
+ else
2434
+ {
2435
+ resultObject.growerCode = "";
2436
+ }
2437
+
2438
+ if(typeof result === 'object' && 'maturityArea' in result)
2439
+ {
2440
+ resultObject.maturityArea = (function(){
2441
+ if(result.maturityArea === null)
2442
+ {
2443
+ return null;
2444
+ }
2445
+
2446
+ if(typeof result.maturityArea !== 'string')
2447
+ {
2448
+ return String(result.maturityArea);
2449
+ }
2450
+
2451
+ return result.maturityArea;
2452
+ }());
2453
+ }
2454
+ else
2455
+ {
2456
+ resultObject.maturityArea = null;
2457
+ }
2458
+
2459
+ if(typeof result === 'object' && 'startTimestamp' in result)
2460
+ {
2461
+ resultObject.startTimestamp = (function(){
2462
+ if(result.startTimestamp === null)
2463
+ {
2464
+ return null;
2465
+ }
2466
+
2467
+ if(typeof result.startTimestamp !== 'string')
2468
+ {
2469
+ return new Date(String(result.startTimestamp));
2470
+ }
2471
+
2472
+ return new Date(result.startTimestamp);
2473
+ }());
2474
+ }
2475
+ else
2476
+ {
2477
+ resultObject.startTimestamp = null;
2478
+ }
2479
+
2480
+ if(typeof result === 'object' && 'finishTimestamp' in result)
2481
+ {
2482
+ resultObject.finishTimestamp = (function(){
2483
+ if(result.finishTimestamp === null)
2484
+ {
2485
+ return null;
2486
+ }
2487
+
2488
+ if(typeof result.finishTimestamp !== 'string')
2489
+ {
2490
+ return new Date(String(result.finishTimestamp));
2491
+ }
2492
+
2493
+ return new Date(result.finishTimestamp);
2494
+ }());
2495
+ }
2496
+ else
2497
+ {
2498
+ resultObject.finishTimestamp = null;
2499
+ }
2500
+
2501
+ if(typeof result === 'object' && 'variety' in result)
2502
+ {
2503
+ resultObject.variety = (function(){
2504
+ let varietyObject = {};
2505
+
2506
+ if(typeof result.variety === 'object' && 'id' in result.variety)
2507
+ {
2508
+ varietyObject.id = (function(){
2509
+ if(typeof result.variety.id !== 'string')
2510
+ {
2511
+ return String(result.variety.id);
2512
+ }
2513
+
2514
+ return result.variety.id;
2515
+ }());
2516
+ }
2517
+ else
2518
+ {
2519
+ varietyObject.id = "";
2520
+ }
2521
+
2522
+ if(typeof result.variety === 'object' && 'code' in result.variety)
2523
+ {
2524
+ varietyObject.code = (function(){
2525
+ if(typeof result.variety.code !== 'string')
2526
+ {
2527
+ return String(result.variety.code);
2528
+ }
2529
+
2530
+ return result.variety.code;
2531
+ }());
2532
+ }
2533
+ else
2534
+ {
2535
+ varietyObject.code = "";
2536
+ }
2537
+
2538
+ if(typeof result.variety === 'object' && 'name' in result.variety)
2539
+ {
2540
+ varietyObject.name = (function(){
2541
+ if(typeof result.variety.name !== 'string')
2542
+ {
2543
+ return String(result.variety.name);
2544
+ }
2545
+
2546
+ return result.variety.name;
2547
+ }());
2548
+ }
2549
+ else
2550
+ {
2551
+ varietyObject.name = "";
2552
+ }
2553
+
2554
+ if(typeof result.variety === 'object' && 'description' in result.variety)
2555
+ {
2556
+ varietyObject.description = (function(){
2557
+ if(typeof result.variety.description !== 'string')
2558
+ {
2559
+ return String(result.variety.description);
2560
+ }
2561
+
2562
+ return result.variety.description;
2563
+ }());
2564
+ }
2565
+ else
2566
+ {
2567
+ varietyObject.description = "";
2568
+ }
2569
+
2570
+ if(typeof result.variety === 'object' && 'image' in result.variety)
2571
+ {
2572
+ varietyObject.image = (function(){
2573
+ if(typeof result.variety.image !== 'string')
2574
+ {
2575
+ return String(result.variety.image);
2576
+ }
2577
+
2578
+ return result.variety.image;
2579
+ }());
2580
+ }
2581
+ else
2582
+ {
2583
+ varietyObject.image = "";
2584
+ }
2585
+
2586
+ return varietyObject;
2587
+ }());
2588
+ }
2589
+ else
2590
+ {
2591
+ resultObject.variety = (function(){
2592
+ let varietyDefaultValue = {};
2593
+
2594
+ varietyDefaultValue.id = "";
2595
+
2596
+ varietyDefaultValue.code = "";
2597
+
2598
+ varietyDefaultValue.name = "";
2599
+
2600
+ varietyDefaultValue.description = "";
2601
+
2602
+ varietyDefaultValue.image = "";
2603
+
2604
+ return varietyDefaultValue;
2605
+ }());
2606
+ }
2607
+
2608
+ if(typeof result === 'object' && 'growingMethod' in result)
2609
+ {
2610
+ resultObject.growingMethod = (function(){
2611
+ let growingMethodObject = {};
2612
+
2613
+ if(typeof result.growingMethod === 'object' && 'id' in result.growingMethod)
2614
+ {
2615
+ growingMethodObject.id = (function(){
2616
+ if(typeof result.growingMethod.id !== 'string')
2617
+ {
2618
+ return String(result.growingMethod.id);
2619
+ }
2620
+
2621
+ return result.growingMethod.id;
2622
+ }());
2623
+ }
2624
+ else
2625
+ {
2626
+ growingMethodObject.id = "";
2627
+ }
2628
+
2629
+ if(typeof result.growingMethod === 'object' && 'code' in result.growingMethod)
2630
+ {
2631
+ growingMethodObject.code = (function(){
2632
+ if(typeof result.growingMethod.code !== 'string')
2633
+ {
2634
+ return String(result.growingMethod.code);
2635
+ }
2636
+
2637
+ return result.growingMethod.code;
2638
+ }());
2639
+ }
2640
+ else
2641
+ {
2642
+ growingMethodObject.code = "";
2643
+ }
2644
+
2645
+ if(typeof result.growingMethod === 'object' && 'name' in result.growingMethod)
2646
+ {
2647
+ growingMethodObject.name = (function(){
2648
+ if(typeof result.growingMethod.name !== 'string')
2649
+ {
2650
+ return String(result.growingMethod.name);
2651
+ }
2652
+
2653
+ return result.growingMethod.name;
2654
+ }());
2655
+ }
2656
+ else
2657
+ {
2658
+ growingMethodObject.name = "";
2659
+ }
2660
+
2661
+ if(typeof result.growingMethod === 'object' && 'description' in result.growingMethod)
2662
+ {
2663
+ growingMethodObject.description = (function(){
2664
+ if(typeof result.growingMethod.description !== 'string')
2665
+ {
2666
+ return String(result.growingMethod.description);
2667
+ }
2668
+
2669
+ return result.growingMethod.description;
2670
+ }());
2671
+ }
2672
+ else
2673
+ {
2674
+ growingMethodObject.description = "";
2675
+ }
2676
+
2677
+ return growingMethodObject;
2678
+ }());
2679
+ }
2680
+ else
2681
+ {
2682
+ resultObject.growingMethod = (function(){
2683
+ let growingMethodDefaultValue = {};
2684
+
2685
+ growingMethodDefaultValue.id = "";
2686
+
2687
+ growingMethodDefaultValue.code = "";
2688
+
2689
+ growingMethodDefaultValue.name = "";
2690
+
2691
+ growingMethodDefaultValue.description = "";
2692
+
2693
+ return growingMethodDefaultValue;
2694
+ }());
2695
+ }
2696
+
2697
+ if(typeof result === 'object' && 'packingLineId' in result)
2698
+ {
2699
+ resultObject.packingLineId = (function(){
2700
+ if(typeof result.packingLineId !== 'string')
2701
+ {
2702
+ return String(result.packingLineId);
2703
+ }
2704
+
2705
+ return result.packingLineId;
2706
+ }());
2707
+ }
2708
+ else
2709
+ {
2710
+ resultObject.packingLineId = "";
2711
+ }
2712
+
2713
+ if(typeof result === 'object' && 'packingLineName' in result)
2714
+ {
2715
+ resultObject.packingLineName = (function(){
2716
+ if(typeof result.packingLineName !== 'string')
2717
+ {
2718
+ return String(result.packingLineName);
2719
+ }
2720
+
2721
+ return result.packingLineName;
2722
+ }());
2723
+ }
2724
+ else
2725
+ {
2726
+ resultObject.packingLineName = "";
2727
+ }
2728
+
2729
+ if(typeof result === 'object' && 'status' in result)
2730
+ {
2731
+ resultObject.status = (function(){
2732
+ if(typeof result.status !== 'string')
2733
+ {
2734
+ return String(result.status);
2735
+ }
2736
+
2737
+ return result.status;
2738
+ }());
2739
+ }
2740
+ else
2741
+ {
2742
+ resultObject.status = "";
2743
+ }
2744
+
2745
+ if(typeof result === 'object' && 'allocatedBins' in result)
2746
+ {
2747
+ resultObject.allocatedBins = (function(){
2748
+ if(typeof result.allocatedBins !== 'number')
2749
+ {
2750
+ return Number.isInteger(Number(result.allocatedBins)) ? Number(result.allocatedBins) : Math.floor(Number(result.allocatedBins));
2751
+ }
2752
+
2753
+ return Number.isInteger(result.allocatedBins) ? result.allocatedBins : Math.floor(result.allocatedBins);
2754
+ }());
2755
+ }
2756
+ else
2757
+ {
2758
+ resultObject.allocatedBins = 0;
2759
+ }
2760
+
2761
+ if(typeof result === 'object' && 'tippedBins' in result)
2762
+ {
2763
+ resultObject.tippedBins = (function(){
2764
+ if(typeof result.tippedBins !== 'number')
2765
+ {
2766
+ return Number.isInteger(Number(result.tippedBins)) ? Number(result.tippedBins) : Math.floor(Number(result.tippedBins));
2767
+ }
2768
+
2769
+ return Number.isInteger(result.tippedBins) ? result.tippedBins : Math.floor(result.tippedBins);
2770
+ }());
2771
+ }
2772
+ else
2773
+ {
2774
+ resultObject.tippedBins = 0;
2775
+ }
2776
+
2777
+ if(typeof result === 'object' && 'class1FruitSizeProfile' in result)
2778
+ {
2779
+ resultObject.class1FruitSizeProfile = (function(){
2780
+ if(Array.isArray(result.class1FruitSizeProfile) !== true)
2781
+ {
2782
+ return [];
2783
+ }
2784
+
2785
+ return result.class1FruitSizeProfile.map((class1FruitSizeProfileItem) => {
2786
+ return (function(){
2787
+ let class1FruitSizeProfileItemObject = {};
2788
+
2789
+ if(typeof class1FruitSizeProfileItem === 'object' && 'fruitSize' in class1FruitSizeProfileItem)
2790
+ {
2791
+ class1FruitSizeProfileItemObject.fruitSize = (function(){
2792
+ if(typeof class1FruitSizeProfileItem.fruitSize !== 'string')
2793
+ {
2794
+ return String(class1FruitSizeProfileItem.fruitSize);
2795
+ }
2796
+
2797
+ return class1FruitSizeProfileItem.fruitSize;
2798
+ }());
2799
+ }
2800
+ else
2801
+ {
2802
+ class1FruitSizeProfileItemObject.fruitSize = "";
2803
+ }
2804
+
2805
+ if(typeof class1FruitSizeProfileItem === 'object' && 'fruitCount' in class1FruitSizeProfileItem)
2806
+ {
2807
+ class1FruitSizeProfileItemObject.fruitCount = (function(){
2808
+ if(typeof class1FruitSizeProfileItem.fruitCount !== 'number')
2809
+ {
2810
+ return Number.isInteger(Number(class1FruitSizeProfileItem.fruitCount)) ? Number(class1FruitSizeProfileItem.fruitCount) : Math.floor(Number(class1FruitSizeProfileItem.fruitCount));
2811
+ }
2812
+
2813
+ return Number.isInteger(class1FruitSizeProfileItem.fruitCount) ? class1FruitSizeProfileItem.fruitCount : Math.floor(class1FruitSizeProfileItem.fruitCount);
2814
+ }());
2815
+ }
2816
+ else
2817
+ {
2818
+ class1FruitSizeProfileItemObject.fruitCount = 0;
2819
+ }
2820
+
2821
+ if(typeof class1FruitSizeProfileItem === 'object' && 'percentage' in class1FruitSizeProfileItem)
2822
+ {
2823
+ class1FruitSizeProfileItemObject.percentage = (function(){
2824
+ if(typeof class1FruitSizeProfileItem.percentage !== 'number')
2825
+ {
2826
+ return Number(class1FruitSizeProfileItem.percentage);
2827
+ }
2828
+
2829
+ return class1FruitSizeProfileItem.percentage;
2830
+ }());
2831
+ }
2832
+ else
2833
+ {
2834
+ class1FruitSizeProfileItemObject.percentage = 0;
2835
+ }
2836
+
2837
+ return class1FruitSizeProfileItemObject;
2838
+ }());
2839
+ });
2840
+ }());
2841
+ }
2842
+ else
2843
+ {
2844
+ resultObject.class1FruitSizeProfile = [];
2845
+ }
2846
+
2847
+ if(typeof result === 'object' && 'class1TotalTrays' in result)
2848
+ {
2849
+ resultObject.class1TotalTrays = (function(){
2850
+ if(typeof result.class1TotalTrays !== 'number')
2851
+ {
2852
+ return Number(result.class1TotalTrays);
2853
+ }
2854
+
2855
+ return result.class1TotalTrays;
2856
+ }());
2857
+ }
2858
+ else
2859
+ {
2860
+ resultObject.class1TotalTrays = 0;
2861
+ }
2862
+
2863
+ if(typeof result === 'object' && 'class1TraysPerBin' in result)
2864
+ {
2865
+ resultObject.class1TraysPerBin = (function(){
2866
+ if(typeof result.class1TraysPerBin !== 'number')
2867
+ {
2868
+ return Number(result.class1TraysPerBin);
2869
+ }
2870
+
2871
+ return result.class1TraysPerBin;
2872
+ }());
2873
+ }
2874
+ else
2875
+ {
2876
+ resultObject.class1TraysPerBin = 0;
2877
+ }
2878
+
2879
+ if(typeof result === 'object' && 'class1AverageFruitSize' in result)
2880
+ {
2881
+ resultObject.class1AverageFruitSize = (function(){
2882
+ if(typeof result.class1AverageFruitSize !== 'number')
2883
+ {
2884
+ return Number(result.class1AverageFruitSize);
2885
+ }
2886
+
2887
+ return result.class1AverageFruitSize;
2888
+ }());
2889
+ }
2890
+ else
2891
+ {
2892
+ resultObject.class1AverageFruitSize = 0;
2893
+ }
2894
+
2895
+ if(typeof result === 'object' && 'class2TotalTrays' in result)
2896
+ {
2897
+ resultObject.class2TotalTrays = (function(){
2898
+ if(typeof result.class2TotalTrays !== 'number')
2899
+ {
2900
+ return Number(result.class2TotalTrays);
2901
+ }
2902
+
2903
+ return result.class2TotalTrays;
2904
+ }());
2905
+ }
2906
+ else
2907
+ {
2908
+ resultObject.class2TotalTrays = 0;
2909
+ }
2910
+
2911
+ if(typeof result === 'object' && 'classTypes' in result)
2912
+ {
2913
+ resultObject.classTypes = (function(){
2914
+ if(Array.isArray(result.classTypes) !== true)
2915
+ {
2916
+ return [];
2917
+ }
2918
+
2919
+ return result.classTypes.map((classTypesItem) => {
2920
+ return (function(){
2921
+ let classTypesItemObject = {};
2922
+
2923
+ if(typeof classTypesItem === 'object' && 'classType' in classTypesItem)
2924
+ {
2925
+ classTypesItemObject.classType = (function(){
2926
+ if(typeof classTypesItem.classType !== 'string')
2927
+ {
2928
+ return String(classTypesItem.classType);
2929
+ }
2930
+
2931
+ return classTypesItem.classType;
2932
+ }());
2933
+ }
2934
+ else
2935
+ {
2936
+ classTypesItemObject.classType = "";
2937
+ }
2938
+
2939
+ if(typeof classTypesItem === 'object' && 'name' in classTypesItem)
2940
+ {
2941
+ classTypesItemObject.name = (function(){
2942
+ if(typeof classTypesItem.name !== 'string')
2943
+ {
2944
+ return String(classTypesItem.name);
2945
+ }
2946
+
2947
+ return classTypesItem.name;
2948
+ }());
2949
+ }
2950
+ else
2951
+ {
2952
+ classTypesItemObject.name = "";
2953
+ }
2954
+
2955
+ if(typeof classTypesItem === 'object' && 'percentage' in classTypesItem)
2956
+ {
2957
+ classTypesItemObject.percentage = (function(){
2958
+ if(typeof classTypesItem.percentage !== 'number')
2959
+ {
2960
+ return Number(classTypesItem.percentage);
2961
+ }
2962
+
2963
+ return classTypesItem.percentage;
2964
+ }());
2965
+ }
2966
+ else
2967
+ {
2968
+ classTypesItemObject.percentage = 0;
2969
+ }
2970
+
2971
+ return classTypesItemObject;
2972
+ }());
2973
+ });
2974
+ }());
2975
+ }
2976
+ else
2977
+ {
2978
+ resultObject.classTypes = [];
2979
+ }
2980
+
2981
+ return resultObject;
2982
+ }());
2983
+
2984
+ resolve(resolveValue);
2985
+ })
2986
+ .catch(error => reject(error));
2987
+ });
2988
+ }
2989
+
2339
2990
  /**
2340
2991
  * List all Packruns [GET /packhouse/sites/{siteId}/packruns]
2341
2992
  *
@@ -2618,6 +3269,54 @@ export default PackrunController;
2618
3269
  * @memberof Controllers.Packhouse.Site
2619
3270
  */
2620
3271
 
3272
+ /**
3273
+ * A **FruitSizeProfileItem** Type
3274
+ *
3275
+ * @typedef {Object} PackrunController.FruitSizeProfileItem
3276
+ * @property {string} fruitSize The Fruit Size
3277
+ * @property {number} fruitCount The Fruit Count
3278
+ * @property {number} percentage The Percentage of Total Fruit for this Fruit Size
3279
+ * @memberof Controllers.Packhouse.Site
3280
+ */
3281
+
3282
+ /**
3283
+ * A **ClassTypePercentageItem** Type
3284
+ *
3285
+ * @typedef {Object} PackrunController.ClassTypePercentageItem
3286
+ * @property {string} classType The Class Type
3287
+ * @property {string} name The Class Type Name
3288
+ * @property {number} percentage The Percentage of Total Weight for this Class Type
3289
+ * @memberof Controllers.Packhouse.Site
3290
+ */
3291
+
3292
+ /**
3293
+ * A **PackrunLatestSummaryData** Type
3294
+ *
3295
+ * @typedef {Object} PackrunController.PackrunLatestSummaryData
3296
+ * @property {string} id The Packrun ID
3297
+ * @property {string} name The Packrun Name
3298
+ * @property {Date} createdTimestamp When the Packrun was Created
3299
+ * @property {string} growerName The Grower Name
3300
+ * @property {string} growerCode The Grower Code
3301
+ * @property {?string} maturityArea The Maturity Area
3302
+ * @property {?Date} startTimestamp When the Packrun was Started
3303
+ * @property {?Date} finishTimestamp When the Packrun was Finished
3304
+ * @property {PackrunController.VarietyItem} variety The Variety for the Packrun
3305
+ * @property {PackrunController.GrowingMethodItem} growingMethod The Growing Method for the Packrun
3306
+ * @property {string} packingLineId The Packing Line ID
3307
+ * @property {string} packingLineName The Packing Line Name
3308
+ * @property {string} status The Status of this Packrun
3309
+ * @property {number} allocatedBins The Number of Bins Allocated for the Packrun
3310
+ * @property {number} tippedBins The Number of Bins Tipped for the Packrun
3311
+ * @property {Array<PackrunController.FruitSizeProfileItem>} class1FruitSizeProfile An Array of Class 1 Fruit Profiles by Size for the Packrun
3312
+ * @property {number} class1TotalTrays The Total Class 1 Trays for this Packrun
3313
+ * @property {number} class1TraysPerBin The Number of Class 1 Trays per Bin for this Packrun
3314
+ * @property {number} class1AverageFruitSize The Average Class 1 Fruit Size for this Packrun
3315
+ * @property {number} class2TotalTrays The Total Class 2 Trays for this Packrun
3316
+ * @property {Array<PackrunController.ClassTypePercentageItem>} classTypes An Array of Class Types and their Percentages for this Packrun
3317
+ * @memberof Controllers.Packhouse.Site
3318
+ */
3319
+
2621
3320
  /**
2622
3321
  * A **TimeBatch** Type
2623
3322
  *