@agroyaar/sdk 2.1.2 → 2.1.3

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,
@@ -150,6 +150,9 @@ var mappers = {
150
150
  UpdateTrackingDeviceData: (response) => ({
151
151
  deviceCode: response.deviceCode
152
152
  }),
153
+ DeleteTrackingDeviceData: (response) => ({
154
+ deviceCode: response.deviceCode
155
+ }),
153
156
  getQuestion: (dto) => ({
154
157
  id: dto.id,
155
158
  name: dto.key,
@@ -174,10 +177,7 @@ var mappers = {
174
177
  date,
175
178
  heading
176
179
  }),
177
- getMechanizationMovementChanges: (response) => response.map(mappers.getMechanizationMovementChange),
178
- DeleteTrackingDeviceData: (response) => ({
179
- deviceCode: response.deviceCode
180
- })
180
+ getMechanizationMovementChanges: (response) => response.map(mappers.getMechanizationMovementChange)
181
181
  };
182
182
 
183
183
  // src/utils/wrapError.ts
@@ -220,20 +220,22 @@ var createMechanizationServices = (client) => ({
220
220
  return wrapError(error);
221
221
  }
222
222
  },
223
- getMechanizations: async (variables) => {
223
+ getMechanizations: async ({ farmerId, kindName }) => {
224
224
  try {
225
225
  const response = await client.typed(
226
226
  "get",
227
227
  "/farmers/{farmerId}/mechanizations",
228
228
  {
229
229
  params: {
230
- kindName: variables.kindName
230
+ kindName
231
+ },
232
+ pathParams: {
233
+ farmerId
231
234
  }
232
235
  }
233
236
  );
234
- return import_ts_belt2.R.Ok(
235
- mappers.getMechanizationsList(response.result.data.mechanizations)
236
- );
237
+ const mechanizations = response.result.data.mechanizations;
238
+ return import_ts_belt2.R.Ok(mappers.getMechanizations(mechanizations));
237
239
  } catch (error) {
238
240
  return wrapError(error);
239
241
  }
@@ -253,10 +255,9 @@ var createMechanizationServices = (client) => ({
253
255
  }
254
256
  }
255
257
  );
258
+ const motorizedMechanizationSensors = response.result.data.motorizedMechanizationSensors;
256
259
  return import_ts_belt2.R.Ok(
257
- mappers.getMotorizedMechanizationSensors(
258
- response.result.data.motorizedMechanizationSensors
259
- )
260
+ mappers.getMotorizedMechanizationSensors(motorizedMechanizationSensors)
260
261
  );
261
262
  } catch (error) {
262
263
  return wrapError(error);
@@ -321,13 +322,14 @@ var createMechanizationServices = (client) => ({
321
322
  }
322
323
  );
323
324
  const questions = data?.result?.data.mechanizationsQuestions;
324
- console.log("in SDK - qustions", questions);
325
325
  return import_ts_belt2.R.Ok(mappers.getQuestions(questions));
326
326
  } catch (error) {
327
327
  return wrapError(error);
328
328
  }
329
329
  },
330
330
  getMechanizationMovementChanges: async ({
331
+ farmerId,
332
+ mechanizationId,
331
333
  fromDate,
332
334
  toDate
333
335
  }) => {
@@ -339,14 +341,15 @@ var createMechanizationServices = (client) => ({
339
341
  params: {
340
342
  fromDate,
341
343
  toDate
344
+ },
345
+ pathParams: {
346
+ farmerId,
347
+ mechanizationId
342
348
  }
343
349
  }
344
350
  );
345
- return import_ts_belt2.R.Ok(
346
- mappers.getMechanizationMovementChanges(
347
- response.result.data.movementChanges
348
- )
349
- );
351
+ const movementChanges = response.result.data.movementChanges;
352
+ return import_ts_belt2.R.Ok(mappers.getMechanizationMovementChanges(movementChanges));
350
353
  } catch (error) {
351
354
  return wrapError(error);
352
355
  }
@@ -360,14 +363,12 @@ var createMechanizationServices = (client) => ({
360
363
  const { data } = await client.delete(
361
364
  `/farmers/${farmerId}/mechanizations/${mechanizationId}/delete-device-code`,
362
365
  {
363
- data: verificationToken
366
+ data: { verificationToken }
364
367
  }
365
368
  );
366
369
  return import_ts_belt2.R.Ok(mappers.DeleteTrackingDeviceData(data));
367
370
  } catch (error) {
368
- const err = error instanceof Error ? error : new Error(String(error));
369
- console.error("UpdateTrackingDevice API Error:", err);
370
- return import_ts_belt2.R.Error(err);
371
+ return wrapError(error);
371
372
  }
372
373
  }
373
374
  });
package/dist/index.d.ts CHANGED
@@ -119,6 +119,11 @@ type UpdateTrackingDeviceVariables = {
119
119
  deviceCode: string;
120
120
  verificationToken: string;
121
121
  };
122
+ type DeleteTrackingDeviceVariables = {
123
+ farmerId: string;
124
+ mechanizationId: string;
125
+ verificationToken: string;
126
+ };
122
127
  type MechanizationQuestionModel = {
123
128
  id: Identifiers.QuestionId;
124
129
  name: string;
@@ -141,14 +146,11 @@ type MechanizationMovementChangesModel = {
141
146
  date: string;
142
147
  };
143
148
  type MechanizationMovementChangesVariable = {
149
+ farmerId: string;
150
+ mechanizationId: string;
144
151
  fromDate?: string | null | undefined;
145
152
  toDate?: string | null | undefined;
146
153
  };
147
- type DeleteTrackingDeviceVariables = {
148
- farmerId: Identifiers.FarmerId;
149
- mechanizationId: Identifiers.MechanizationId;
150
- verificationToken: string;
151
- };
152
154
 
153
155
  /**
154
156
  * This file was auto-generated by openapi-typescript.
@@ -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
2973
  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[]>>;
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,
@@ -114,6 +114,9 @@ var mappers = {
114
114
  UpdateTrackingDeviceData: (response) => ({
115
115
  deviceCode: response.deviceCode
116
116
  }),
117
+ DeleteTrackingDeviceData: (response) => ({
118
+ deviceCode: response.deviceCode
119
+ }),
117
120
  getQuestion: (dto) => ({
118
121
  id: dto.id,
119
122
  name: dto.key,
@@ -138,10 +141,7 @@ var mappers = {
138
141
  date,
139
142
  heading
140
143
  }),
141
- getMechanizationMovementChanges: (response) => response.map(mappers.getMechanizationMovementChange),
142
- DeleteTrackingDeviceData: (response) => ({
143
- deviceCode: response.deviceCode
144
- })
144
+ getMechanizationMovementChanges: (response) => response.map(mappers.getMechanizationMovementChange)
145
145
  };
146
146
 
147
147
  // src/utils/wrapError.ts
@@ -184,20 +184,22 @@ var createMechanizationServices = (client) => ({
184
184
  return wrapError(error);
185
185
  }
186
186
  },
187
- getMechanizations: async (variables) => {
187
+ getMechanizations: async ({ farmerId, kindName }) => {
188
188
  try {
189
189
  const response = await client.typed(
190
190
  "get",
191
191
  "/farmers/{farmerId}/mechanizations",
192
192
  {
193
193
  params: {
194
- kindName: variables.kindName
194
+ kindName
195
+ },
196
+ pathParams: {
197
+ farmerId
195
198
  }
196
199
  }
197
200
  );
198
- return R2.Ok(
199
- mappers.getMechanizationsList(response.result.data.mechanizations)
200
- );
201
+ const mechanizations = response.result.data.mechanizations;
202
+ return R2.Ok(mappers.getMechanizations(mechanizations));
201
203
  } catch (error) {
202
204
  return wrapError(error);
203
205
  }
@@ -217,10 +219,9 @@ var createMechanizationServices = (client) => ({
217
219
  }
218
220
  }
219
221
  );
222
+ const motorizedMechanizationSensors = response.result.data.motorizedMechanizationSensors;
220
223
  return R2.Ok(
221
- mappers.getMotorizedMechanizationSensors(
222
- response.result.data.motorizedMechanizationSensors
223
- )
224
+ mappers.getMotorizedMechanizationSensors(motorizedMechanizationSensors)
224
225
  );
225
226
  } catch (error) {
226
227
  return wrapError(error);
@@ -285,13 +286,14 @@ var createMechanizationServices = (client) => ({
285
286
  }
286
287
  );
287
288
  const questions = data?.result?.data.mechanizationsQuestions;
288
- console.log("in SDK - qustions", questions);
289
289
  return R2.Ok(mappers.getQuestions(questions));
290
290
  } catch (error) {
291
291
  return wrapError(error);
292
292
  }
293
293
  },
294
294
  getMechanizationMovementChanges: async ({
295
+ farmerId,
296
+ mechanizationId,
295
297
  fromDate,
296
298
  toDate
297
299
  }) => {
@@ -303,14 +305,15 @@ var createMechanizationServices = (client) => ({
303
305
  params: {
304
306
  fromDate,
305
307
  toDate
308
+ },
309
+ pathParams: {
310
+ farmerId,
311
+ mechanizationId
306
312
  }
307
313
  }
308
314
  );
309
- return R2.Ok(
310
- mappers.getMechanizationMovementChanges(
311
- response.result.data.movementChanges
312
- )
313
- );
315
+ const movementChanges = response.result.data.movementChanges;
316
+ return R2.Ok(mappers.getMechanizationMovementChanges(movementChanges));
314
317
  } catch (error) {
315
318
  return wrapError(error);
316
319
  }
@@ -324,14 +327,12 @@ var createMechanizationServices = (client) => ({
324
327
  const { data } = await client.delete(
325
328
  `/farmers/${farmerId}/mechanizations/${mechanizationId}/delete-device-code`,
326
329
  {
327
- data: verificationToken
330
+ data: { verificationToken }
328
331
  }
329
332
  );
330
333
  return R2.Ok(mappers.DeleteTrackingDeviceData(data));
331
334
  } catch (error) {
332
- const err = error instanceof Error ? error : new Error(String(error));
333
- console.error("UpdateTrackingDevice API Error:", err);
334
- return R2.Error(err);
335
+ return wrapError(error);
335
336
  }
336
337
  }
337
338
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agroyaar/sdk",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",