@agroyaar/sdk 2.0.4 → 2.0.5-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.
package/dist/index.cjs CHANGED
@@ -110,18 +110,18 @@ var mappers = {
110
110
  date: response.date
111
111
  }),
112
112
  getSpeedChangesChartPointsList: (response) => response.map(mappers.getSpeedChangesChart),
113
- getMechanization: (dto) => ({
114
- id: dto.id,
115
- commonName: dto.commonName,
116
- model: dto.model,
117
- avatarURL: dto.avatarURL,
118
- manufactureYear: dto.manufactureYear,
119
- code: dto.code,
120
- kind: dto.kind,
121
- kindName: dto.kindName,
122
- variety: mappers.getMechanizationVariety(dto.variety)
113
+ getMechanization: (res) => ({
114
+ id: res.id,
115
+ commonName: res.commonName,
116
+ model: res.model,
117
+ avatarURL: res.avatarURL,
118
+ manufactureYear: res.manufactureYear,
119
+ code: res.code,
120
+ kind: res.kind,
121
+ kindName: res.kindName,
122
+ variety: mappers.getMechanizationVariety(res.variety)
123
123
  }),
124
- getMechanizationsList: (response) => response.map(mappers.getMechanization),
124
+ getMechanizations: (response) => response.map(mappers.getMechanization),
125
125
  getSeasonsProcess: (response) => ({
126
126
  id: response.id,
127
127
  label: response.label,
@@ -217,20 +217,22 @@ var createMechanizationServices = (client) => ({
217
217
  return wrapError(error);
218
218
  }
219
219
  },
220
- getMechanizations: async (variables) => {
220
+ getMechanizations: async ({ farmerId, kindName }) => {
221
221
  try {
222
222
  const response = await client.typed(
223
223
  "get",
224
224
  "/farmers/{farmerId}/mechanizations",
225
225
  {
226
226
  params: {
227
- kindName: variables.kindName
227
+ kindName
228
+ },
229
+ pathParams: {
230
+ farmerId
228
231
  }
229
232
  }
230
233
  );
231
- return import_ts_belt2.R.Ok(
232
- mappers.getMechanizationsList(response.result.data.mechanizations)
233
- );
234
+ const mechanizations = response.result.data.mechanizations;
235
+ return import_ts_belt2.R.Ok(mappers.getMechanizations(mechanizations));
234
236
  } catch (error) {
235
237
  return wrapError(error);
236
238
  }
@@ -250,10 +252,9 @@ var createMechanizationServices = (client) => ({
250
252
  }
251
253
  }
252
254
  );
255
+ const motorizedMechanizationSensors = response.result.data.motorizedMechanizationSensors;
253
256
  return import_ts_belt2.R.Ok(
254
- mappers.getMotorizedMechanizationSensors(
255
- response.result.data.motorizedMechanizationSensors
256
- )
257
+ mappers.getMotorizedMechanizationSensors(motorizedMechanizationSensors)
257
258
  );
258
259
  } catch (error) {
259
260
  return wrapError(error);
@@ -317,18 +318,15 @@ var createMechanizationServices = (client) => ({
317
318
  }
318
319
  }
319
320
  );
320
- const questions = data.result.data.mechanizationsQuestions;
321
- if (!questions) {
322
- throw new Error(
323
- "Invalid API response: 'mechanizationsQuestions' missing"
324
- );
325
- }
326
- return import_ts_belt2.R.Ok(mappers.getQuestions(questions));
321
+ const maybeQuestions = data?.result?.data.mechanizationsQuestions;
322
+ return maybeQuestions ? import_ts_belt2.R.Ok(mappers.getQuestions(maybeQuestions)) : import_ts_belt2.R.Error("missing questions in response");
327
323
  } catch (error) {
328
324
  return wrapError(error);
329
325
  }
330
326
  },
331
327
  getMechanizationMovementChanges: async ({
328
+ farmerId,
329
+ mechanizationId,
332
330
  fromDate,
333
331
  toDate
334
332
  }) => {
@@ -340,14 +338,15 @@ var createMechanizationServices = (client) => ({
340
338
  params: {
341
339
  fromDate,
342
340
  toDate
341
+ },
342
+ pathParams: {
343
+ farmerId,
344
+ mechanizationId
343
345
  }
344
346
  }
345
347
  );
346
- return import_ts_belt2.R.Ok(
347
- mappers.getMechanizationMovementChanges(
348
- response.result.data.movementChanges
349
- )
350
- );
348
+ const movementChanges = response.result.data.movementChanges;
349
+ return import_ts_belt2.R.Ok(mappers.getMechanizationMovementChanges(movementChanges));
351
350
  } catch (error) {
352
351
  return wrapError(error);
353
352
  }
package/dist/index.d.ts CHANGED
@@ -62,7 +62,7 @@ type MechanizationModel = {
62
62
  model: string;
63
63
  commonName: string;
64
64
  avatarURL: string;
65
- manufactureYear: number;
65
+ manufactureYear: string;
66
66
  code: string;
67
67
  kind: VarietyKind;
68
68
  kindName: MechanizationType;
@@ -141,6 +141,8 @@ type MechanizationMovementChangesModel = {
141
141
  date: string;
142
142
  };
143
143
  type MechanizationMovementChangesVariable = {
144
+ farmerId: string;
145
+ mechanizationId: string;
144
146
  fromDate?: string | null | undefined;
145
147
  toDate?: string | null | undefined;
146
148
  };
@@ -2963,13 +2965,13 @@ declare const createSDK: (config: ClientConfig, middlewares?: Parameters<typeof
2963
2965
  mechanization: {
2964
2966
  getMechanizationVarieties: ({ kindName, }: MechanizationVarietyVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationVarietyModel[]>>;
2965
2967
  getSpeedChangesChartData: ({ farmerId, mechanizationId, }: SpeedChangesChartVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<SpeedChangesChartModel[]>>;
2966
- getMechanizations: (variables: MechanizationVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationModel[]>>;
2968
+ getMechanizations: ({ farmerId, kindName }: MechanizationVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationModel[]>>;
2967
2969
  getMotorizedMechanizationSensors: ({ farmerId, mechanizationId, }: MotorizedMechanizationSensorsVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MotorizedMechanizationSensorsModel>>;
2968
2970
  SubmitTrackingDeviceCode: ({ farmerId, mechanizationId, deviceCode, }: SubmitTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<TrackingDeviceCodeModel>>;
2969
2971
  getSeasonsProcess: () => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<SeasonsProcessModel[]>>;
2970
2972
  UpdateTrackingDeviceCode: ({ farmerId, mechanizationId, deviceCode, verificationToken, }: UpdateTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<TrackingDeviceCodeModel>>;
2971
- getMechanizationQuestionList: ({ varietyId, }: GetMechanizationQuestionVariable) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationQuestionModel[]>>;
2972
- getMechanizationMovementChanges: ({ fromDate, toDate, }: MechanizationMovementChangesVariable) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationMovementChangesModel[]>>;
2973
+ getMechanizationQuestionList: ({ varietyId, }: GetMechanizationQuestionVariable) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationQuestionModel[]> | _mobily_ts_belt.Error<"missing questions in response">>;
2974
+ getMechanizationMovementChanges: ({ farmerId, mechanizationId, fromDate, toDate, }: MechanizationMovementChangesVariable) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationMovementChangesModel[]>>;
2973
2975
  DeleteTrackingDeviceCode: ({ farmerId, mechanizationId, verificationToken, }: DeleteTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<TrackingDeviceCodeModel>>;
2974
2976
  };
2975
2977
  };
package/dist/index.mjs CHANGED
@@ -74,18 +74,18 @@ var mappers = {
74
74
  date: response.date
75
75
  }),
76
76
  getSpeedChangesChartPointsList: (response) => response.map(mappers.getSpeedChangesChart),
77
- getMechanization: (dto) => ({
78
- id: dto.id,
79
- commonName: dto.commonName,
80
- model: dto.model,
81
- avatarURL: dto.avatarURL,
82
- manufactureYear: dto.manufactureYear,
83
- code: dto.code,
84
- kind: dto.kind,
85
- kindName: dto.kindName,
86
- variety: mappers.getMechanizationVariety(dto.variety)
77
+ getMechanization: (res) => ({
78
+ id: res.id,
79
+ commonName: res.commonName,
80
+ model: res.model,
81
+ avatarURL: res.avatarURL,
82
+ manufactureYear: res.manufactureYear,
83
+ code: res.code,
84
+ kind: res.kind,
85
+ kindName: res.kindName,
86
+ variety: mappers.getMechanizationVariety(res.variety)
87
87
  }),
88
- getMechanizationsList: (response) => response.map(mappers.getMechanization),
88
+ getMechanizations: (response) => response.map(mappers.getMechanization),
89
89
  getSeasonsProcess: (response) => ({
90
90
  id: response.id,
91
91
  label: response.label,
@@ -181,20 +181,22 @@ var createMechanizationServices = (client) => ({
181
181
  return wrapError(error);
182
182
  }
183
183
  },
184
- getMechanizations: async (variables) => {
184
+ getMechanizations: async ({ farmerId, kindName }) => {
185
185
  try {
186
186
  const response = await client.typed(
187
187
  "get",
188
188
  "/farmers/{farmerId}/mechanizations",
189
189
  {
190
190
  params: {
191
- kindName: variables.kindName
191
+ kindName
192
+ },
193
+ pathParams: {
194
+ farmerId
192
195
  }
193
196
  }
194
197
  );
195
- return R2.Ok(
196
- mappers.getMechanizationsList(response.result.data.mechanizations)
197
- );
198
+ const mechanizations = response.result.data.mechanizations;
199
+ return R2.Ok(mappers.getMechanizations(mechanizations));
198
200
  } catch (error) {
199
201
  return wrapError(error);
200
202
  }
@@ -214,10 +216,9 @@ var createMechanizationServices = (client) => ({
214
216
  }
215
217
  }
216
218
  );
219
+ const motorizedMechanizationSensors = response.result.data.motorizedMechanizationSensors;
217
220
  return R2.Ok(
218
- mappers.getMotorizedMechanizationSensors(
219
- response.result.data.motorizedMechanizationSensors
220
- )
221
+ mappers.getMotorizedMechanizationSensors(motorizedMechanizationSensors)
221
222
  );
222
223
  } catch (error) {
223
224
  return wrapError(error);
@@ -281,18 +282,15 @@ var createMechanizationServices = (client) => ({
281
282
  }
282
283
  }
283
284
  );
284
- const questions = data.result.data.mechanizationsQuestions;
285
- if (!questions) {
286
- throw new Error(
287
- "Invalid API response: 'mechanizationsQuestions' missing"
288
- );
289
- }
290
- return R2.Ok(mappers.getQuestions(questions));
285
+ const maybeQuestions = data?.result?.data.mechanizationsQuestions;
286
+ return maybeQuestions ? R2.Ok(mappers.getQuestions(maybeQuestions)) : R2.Error("missing questions in response");
291
287
  } catch (error) {
292
288
  return wrapError(error);
293
289
  }
294
290
  },
295
291
  getMechanizationMovementChanges: async ({
292
+ farmerId,
293
+ mechanizationId,
296
294
  fromDate,
297
295
  toDate
298
296
  }) => {
@@ -304,14 +302,15 @@ var createMechanizationServices = (client) => ({
304
302
  params: {
305
303
  fromDate,
306
304
  toDate
305
+ },
306
+ pathParams: {
307
+ farmerId,
308
+ mechanizationId
307
309
  }
308
310
  }
309
311
  );
310
- return R2.Ok(
311
- mappers.getMechanizationMovementChanges(
312
- response.result.data.movementChanges
313
- )
314
- );
312
+ const movementChanges = response.result.data.movementChanges;
313
+ return R2.Ok(mappers.getMechanizationMovementChanges(movementChanges));
315
314
  } catch (error) {
316
315
  return wrapError(error);
317
316
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agroyaar/sdk",
3
- "version": "2.0.4",
3
+ "version": "2.0.5-1",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",