@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 +30 -31
- package/dist/index.d.ts +6 -4
- package/dist/index.mjs +30 -31
- package/package.json +1 -1
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: (
|
|
114
|
-
id:
|
|
115
|
-
commonName:
|
|
116
|
-
model:
|
|
117
|
-
avatarURL:
|
|
118
|
-
manufactureYear:
|
|
119
|
-
code:
|
|
120
|
-
kind:
|
|
121
|
-
kindName:
|
|
122
|
-
variety: mappers.getMechanizationVariety(
|
|
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
|
-
|
|
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 (
|
|
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
|
|
227
|
+
kindName
|
|
228
|
+
},
|
|
229
|
+
pathParams: {
|
|
230
|
+
farmerId
|
|
228
231
|
}
|
|
229
232
|
}
|
|
230
233
|
);
|
|
231
|
-
|
|
232
|
-
|
|
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
|
|
321
|
-
|
|
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
|
-
|
|
347
|
-
|
|
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:
|
|
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: (
|
|
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: (
|
|
78
|
-
id:
|
|
79
|
-
commonName:
|
|
80
|
-
model:
|
|
81
|
-
avatarURL:
|
|
82
|
-
manufactureYear:
|
|
83
|
-
code:
|
|
84
|
-
kind:
|
|
85
|
-
kindName:
|
|
86
|
-
variety: mappers.getMechanizationVariety(
|
|
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
|
-
|
|
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 (
|
|
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
|
|
191
|
+
kindName
|
|
192
|
+
},
|
|
193
|
+
pathParams: {
|
|
194
|
+
farmerId
|
|
192
195
|
}
|
|
193
196
|
}
|
|
194
197
|
);
|
|
195
|
-
|
|
196
|
-
|
|
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
|
|
285
|
-
|
|
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
|
-
|
|
311
|
-
|
|
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
|
}
|