@gesagro/jaspion-sdk 1.0.9 → 1.0.10

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/dist/index.mjs CHANGED
@@ -2322,48 +2322,57 @@ var WeaningList = class extends Report {
2322
2322
  }
2323
2323
  async pdf(input) {
2324
2324
  return this.requestPdf({
2325
- resources: [{ key: "FARM_ID", value: input.farmId }],
2325
+ resources: this.getResources(input),
2326
2326
  parameters: [
2327
- { key: "DATE_BEGIN", value: input.dateRange?.start ?? null },
2328
- { key: "DATE_END", value: input.dateRange?.end ?? null },
2329
- { key: "CALENDAR", value: input.calendarType },
2330
- { key: "PARITY", value: input.parity?.toString() ?? null },
2331
- { key: "ORIGIN_ID", value: input.originId },
2332
- { key: "BREED_ID", value: input.breedId },
2333
- { key: "BIRTH_PLACE_ID", value: input.birthPlaceId },
2334
- { key: "FEMALE_SWINE_ID", value: input.femaleSwineId },
2335
- {
2336
- key: "MATING_DATE_BEGIN",
2337
- value: input.matingDateRange?.start ?? null
2338
- },
2339
- { key: "MATING_DATE_END", value: input.matingDateRange?.end ?? null },
2340
- { key: "CONTEXT", value: input.context },
2341
- { key: "PIGLET_BATCH_ID", value: input.nurseryPigletBatchId }
2327
+ ...this.getParameters(input),
2328
+ { key: "DATA_ONLY", value: false }
2342
2329
  ]
2343
2330
  });
2344
2331
  }
2345
2332
  async csv(input) {
2346
2333
  return this.requestCsv({
2347
- resources: [{ key: "FARM_ID", value: input.farmId }],
2334
+ resources: this.getResources(input),
2348
2335
  parameters: [
2349
- { key: "DATE_BEGIN", value: input.dateRange?.start ?? null },
2350
- { key: "DATE_END", value: input.dateRange?.end ?? null },
2351
- { key: "CALENDAR", value: input.calendarType },
2352
- { key: "PARITY", value: input.parity?.toString() ?? null },
2353
- { key: "ORIGIN_ID", value: input.originId },
2354
- { key: "BREED_ID", value: input.breedId },
2355
- { key: "BIRTH_PLACE_ID", value: input.birthPlaceId },
2356
- { key: "FEMALE_SWINE_ID", value: input.femaleSwineId },
2357
- {
2358
- key: "MATING_DATE_BEGIN",
2359
- value: input.matingDateRange?.start ?? null
2360
- },
2361
- { key: "MATING_DATE_END", value: input.matingDateRange?.end ?? null },
2362
- { key: "CONTEXT", value: input.context },
2363
- { key: "PIGLET_BATCH_ID", value: input.nurseryPigletBatchId }
2336
+ ...this.getParameters(input),
2337
+ { key: "DATA_ONLY", value: true }
2364
2338
  ]
2365
2339
  });
2366
2340
  }
2341
+ getResources(input) {
2342
+ return [{ key: "FARM_ID", value: input.farmId }];
2343
+ }
2344
+ getParameters(input) {
2345
+ let orderByColumn = input.orderBy.column;
2346
+ switch (orderByColumn) {
2347
+ case "createdAt":
2348
+ orderByColumn = "created_at";
2349
+ break;
2350
+ case "weanedPiglets":
2351
+ orderByColumn = "weaned_piglets";
2352
+ break;
2353
+ default:
2354
+ break;
2355
+ }
2356
+ return [
2357
+ { key: "DATE_BEGIN", value: input.dateRange?.start ?? null },
2358
+ { key: "DATE_END", value: input.dateRange?.end ?? null },
2359
+ { key: "CALENDAR", value: input.calendarType },
2360
+ { key: "PARITY", value: input.parity?.toString() ?? null },
2361
+ { key: "ORIGIN_ID", value: input.originId },
2362
+ { key: "BREED_ID", value: input.breedId },
2363
+ { key: "BIRTH_PLACE_ID", value: input.birthPlaceId },
2364
+ { key: "FEMALE_SWINE_ID", value: input.femaleSwineId },
2365
+ {
2366
+ key: "MATING_DATE_BEGIN",
2367
+ value: input.matingDateRange?.start ?? null
2368
+ },
2369
+ { key: "MATING_DATE_END", value: input.matingDateRange?.end ?? null },
2370
+ { key: "CONTEXT", value: input.context },
2371
+ { key: "PIGLET_BATCH_ID", value: input.nurseryPigletBatchId },
2372
+ { key: "ORDERBYDIRECTION", value: input.orderBy.direction },
2373
+ { key: "ORDERBYCOLUMN", value: orderByColumn }
2374
+ ];
2375
+ }
2367
2376
  };
2368
2377
 
2369
2378
  // src/namespaces/pig-master/index.ts