@agroyaar/sdk 2.1.2 → 2.2.0
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 +55 -33
- package/dist/index.d.ts +16 -9
- package/dist/index.mjs +55 -33
- 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,
|
|
@@ -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,43 @@ var createMechanizationServices = (client) => ({
|
|
|
220
220
|
return wrapError(error);
|
|
221
221
|
}
|
|
222
222
|
},
|
|
223
|
-
|
|
223
|
+
getMechanization: async ({ farmerId, mechanizationId }) => {
|
|
224
|
+
try {
|
|
225
|
+
const response = await client.typed(
|
|
226
|
+
"get",
|
|
227
|
+
"/farmers/{farmerId}/mechanizations/{mechanizationId}",
|
|
228
|
+
{
|
|
229
|
+
pathParams: {
|
|
230
|
+
farmerId,
|
|
231
|
+
mechanizationId
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
);
|
|
235
|
+
const mechanization = response.result.data.mechanization;
|
|
236
|
+
return import_ts_belt2.R.Ok(mappers.getMechanization(mechanization));
|
|
237
|
+
} catch (error) {
|
|
238
|
+
return wrapError(error);
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
getMechanizations: async ({
|
|
242
|
+
farmerId,
|
|
243
|
+
kindName
|
|
244
|
+
}) => {
|
|
224
245
|
try {
|
|
225
246
|
const response = await client.typed(
|
|
226
247
|
"get",
|
|
227
248
|
"/farmers/{farmerId}/mechanizations",
|
|
228
249
|
{
|
|
229
250
|
params: {
|
|
230
|
-
kindName
|
|
251
|
+
kindName
|
|
252
|
+
},
|
|
253
|
+
pathParams: {
|
|
254
|
+
farmerId
|
|
231
255
|
}
|
|
232
256
|
}
|
|
233
257
|
);
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
);
|
|
258
|
+
const mechanizations = response.result.data.mechanizations;
|
|
259
|
+
return import_ts_belt2.R.Ok(mappers.getMechanizations(mechanizations));
|
|
237
260
|
} catch (error) {
|
|
238
261
|
return wrapError(error);
|
|
239
262
|
}
|
|
@@ -253,10 +276,9 @@ var createMechanizationServices = (client) => ({
|
|
|
253
276
|
}
|
|
254
277
|
}
|
|
255
278
|
);
|
|
279
|
+
const motorizedMechanizationSensors = response.result.data.motorizedMechanizationSensors;
|
|
256
280
|
return import_ts_belt2.R.Ok(
|
|
257
|
-
mappers.getMotorizedMechanizationSensors(
|
|
258
|
-
response.result.data.motorizedMechanizationSensors
|
|
259
|
-
)
|
|
281
|
+
mappers.getMotorizedMechanizationSensors(motorizedMechanizationSensors)
|
|
260
282
|
);
|
|
261
283
|
} catch (error) {
|
|
262
284
|
return wrapError(error);
|
|
@@ -321,13 +343,14 @@ var createMechanizationServices = (client) => ({
|
|
|
321
343
|
}
|
|
322
344
|
);
|
|
323
345
|
const questions = data?.result?.data.mechanizationsQuestions;
|
|
324
|
-
console.log("in SDK - qustions", questions);
|
|
325
346
|
return import_ts_belt2.R.Ok(mappers.getQuestions(questions));
|
|
326
347
|
} catch (error) {
|
|
327
348
|
return wrapError(error);
|
|
328
349
|
}
|
|
329
350
|
},
|
|
330
351
|
getMechanizationMovementChanges: async ({
|
|
352
|
+
farmerId,
|
|
353
|
+
mechanizationId,
|
|
331
354
|
fromDate,
|
|
332
355
|
toDate
|
|
333
356
|
}) => {
|
|
@@ -339,14 +362,15 @@ var createMechanizationServices = (client) => ({
|
|
|
339
362
|
params: {
|
|
340
363
|
fromDate,
|
|
341
364
|
toDate
|
|
365
|
+
},
|
|
366
|
+
pathParams: {
|
|
367
|
+
farmerId,
|
|
368
|
+
mechanizationId
|
|
342
369
|
}
|
|
343
370
|
}
|
|
344
371
|
);
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
response.result.data.movementChanges
|
|
348
|
-
)
|
|
349
|
-
);
|
|
372
|
+
const movementChanges = response.result.data.movementChanges;
|
|
373
|
+
return import_ts_belt2.R.Ok(mappers.getMechanizationMovementChanges(movementChanges));
|
|
350
374
|
} catch (error) {
|
|
351
375
|
return wrapError(error);
|
|
352
376
|
}
|
|
@@ -360,14 +384,12 @@ var createMechanizationServices = (client) => ({
|
|
|
360
384
|
const { data } = await client.delete(
|
|
361
385
|
`/farmers/${farmerId}/mechanizations/${mechanizationId}/delete-device-code`,
|
|
362
386
|
{
|
|
363
|
-
data: verificationToken
|
|
387
|
+
data: { verificationToken }
|
|
364
388
|
}
|
|
365
389
|
);
|
|
366
390
|
return import_ts_belt2.R.Ok(mappers.DeleteTrackingDeviceData(data));
|
|
367
391
|
} catch (error) {
|
|
368
|
-
|
|
369
|
-
console.error("UpdateTrackingDevice API Error:", err);
|
|
370
|
-
return import_ts_belt2.R.Error(err);
|
|
392
|
+
return wrapError(error);
|
|
371
393
|
}
|
|
372
394
|
}
|
|
373
395
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -68,10 +68,14 @@ type MechanizationModel = {
|
|
|
68
68
|
kindName: MechanizationType;
|
|
69
69
|
variety: MechanizationVarietyModel;
|
|
70
70
|
};
|
|
71
|
-
type
|
|
71
|
+
type MechanizationsVariables = {
|
|
72
72
|
farmerId: string;
|
|
73
73
|
kindName: MechanizationType;
|
|
74
74
|
};
|
|
75
|
+
type MechanizationVariables = {
|
|
76
|
+
farmerId: string;
|
|
77
|
+
mechanizationId: string;
|
|
78
|
+
};
|
|
75
79
|
type SeasonsProcessModel = {
|
|
76
80
|
id: Identifiers.SeasonsProcessId;
|
|
77
81
|
name: string;
|
|
@@ -119,6 +123,11 @@ type UpdateTrackingDeviceVariables = {
|
|
|
119
123
|
deviceCode: string;
|
|
120
124
|
verificationToken: string;
|
|
121
125
|
};
|
|
126
|
+
type DeleteTrackingDeviceVariables = {
|
|
127
|
+
farmerId: string;
|
|
128
|
+
mechanizationId: string;
|
|
129
|
+
verificationToken: string;
|
|
130
|
+
};
|
|
122
131
|
type MechanizationQuestionModel = {
|
|
123
132
|
id: Identifiers.QuestionId;
|
|
124
133
|
name: string;
|
|
@@ -141,14 +150,11 @@ type MechanizationMovementChangesModel = {
|
|
|
141
150
|
date: string;
|
|
142
151
|
};
|
|
143
152
|
type MechanizationMovementChangesVariable = {
|
|
153
|
+
farmerId: string;
|
|
154
|
+
mechanizationId: string;
|
|
144
155
|
fromDate?: string | null | undefined;
|
|
145
156
|
toDate?: string | null | undefined;
|
|
146
157
|
};
|
|
147
|
-
type DeleteTrackingDeviceVariables = {
|
|
148
|
-
farmerId: Identifiers.FarmerId;
|
|
149
|
-
mechanizationId: Identifiers.MechanizationId;
|
|
150
|
-
verificationToken: string;
|
|
151
|
-
};
|
|
152
158
|
|
|
153
159
|
/**
|
|
154
160
|
* This file was auto-generated by openapi-typescript.
|
|
@@ -2963,16 +2969,17 @@ declare const createSDK: (config: ClientConfig, middlewares?: Parameters<typeof
|
|
|
2963
2969
|
mechanization: {
|
|
2964
2970
|
getMechanizationVarieties: ({ kindName, }: MechanizationVarietyVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationVarietyModel[]>>;
|
|
2965
2971
|
getSpeedChangesChartData: ({ farmerId, mechanizationId, }: SpeedChangesChartVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<SpeedChangesChartModel[]>>;
|
|
2966
|
-
|
|
2972
|
+
getMechanization: ({ farmerId, mechanizationId }: MechanizationVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationModel>>;
|
|
2973
|
+
getMechanizations: ({ farmerId, kindName, }: MechanizationsVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationModel[]>>;
|
|
2967
2974
|
getMotorizedMechanizationSensors: ({ farmerId, mechanizationId, }: MotorizedMechanizationSensorsVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MotorizedMechanizationSensorsModel>>;
|
|
2968
2975
|
SubmitTrackingDeviceCode: ({ farmerId, mechanizationId, deviceCode, }: SubmitTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<TrackingDeviceCodeModel>>;
|
|
2969
2976
|
getSeasonsProcess: () => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<SeasonsProcessModel[]>>;
|
|
2970
2977
|
UpdateTrackingDeviceCode: ({ farmerId, mechanizationId, deviceCode, verificationToken, }: UpdateTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<TrackingDeviceCodeModel>>;
|
|
2971
2978
|
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[]>>;
|
|
2979
|
+
getMechanizationMovementChanges: ({ farmerId, mechanizationId, fromDate, toDate, }: MechanizationMovementChangesVariable) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationMovementChangesModel[]>>;
|
|
2973
2980
|
DeleteTrackingDeviceCode: ({ farmerId, mechanizationId, verificationToken, }: DeleteTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<TrackingDeviceCodeModel>>;
|
|
2974
2981
|
};
|
|
2975
2982
|
};
|
|
2976
2983
|
};
|
|
2977
2984
|
|
|
2978
|
-
export { type DeleteTrackingDeviceVariables, type GetMechanizationQuestionVariable, Identifiers, type MechanizationMachineUsageKind, type MechanizationMachineUsageType, type MechanizationModel, type MechanizationMovementChangesModel, type MechanizationMovementChangesVariable, type MechanizationQuestionModel, type MechanizationSeasonProcessKind, type MechanizationSeasonProcessType, type MechanizationType, type MechanizationVariables, type MechanizationVarietyModel, type MechanizationVarietyVariables, type MotorizedMechanizationSensorsModel, type MotorizedMechanizationSensorsVariables, type SeasonsProcessModel, type ServiceType, type SpeedChangesChartModel, type SpeedChangesChartVariables, type Status, type StatusType, type SubmitTrackingDeviceVariables, type TaskType, type TrackingDeviceCodeModel, type UpdateTrackingDeviceVariables, type VarietyKind, createSDK };
|
|
2985
|
+
export { type DeleteTrackingDeviceVariables, type GetMechanizationQuestionVariable, Identifiers, type MechanizationMachineUsageKind, type MechanizationMachineUsageType, type MechanizationModel, type MechanizationMovementChangesModel, type MechanizationMovementChangesVariable, type MechanizationQuestionModel, type MechanizationSeasonProcessKind, type MechanizationSeasonProcessType, type MechanizationType, type MechanizationVariables, type MechanizationVarietyModel, type MechanizationVarietyVariables, type MechanizationsVariables, type MotorizedMechanizationSensorsModel, type MotorizedMechanizationSensorsVariables, type SeasonsProcessModel, type ServiceType, type SpeedChangesChartModel, type SpeedChangesChartVariables, type Status, type StatusType, type SubmitTrackingDeviceVariables, type TaskType, type TrackingDeviceCodeModel, type UpdateTrackingDeviceVariables, type VarietyKind, createSDK };
|
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,
|
|
@@ -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,43 @@ var createMechanizationServices = (client) => ({
|
|
|
184
184
|
return wrapError(error);
|
|
185
185
|
}
|
|
186
186
|
},
|
|
187
|
-
|
|
187
|
+
getMechanization: async ({ farmerId, mechanizationId }) => {
|
|
188
|
+
try {
|
|
189
|
+
const response = await client.typed(
|
|
190
|
+
"get",
|
|
191
|
+
"/farmers/{farmerId}/mechanizations/{mechanizationId}",
|
|
192
|
+
{
|
|
193
|
+
pathParams: {
|
|
194
|
+
farmerId,
|
|
195
|
+
mechanizationId
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
const mechanization = response.result.data.mechanization;
|
|
200
|
+
return R2.Ok(mappers.getMechanization(mechanization));
|
|
201
|
+
} catch (error) {
|
|
202
|
+
return wrapError(error);
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
getMechanizations: async ({
|
|
206
|
+
farmerId,
|
|
207
|
+
kindName
|
|
208
|
+
}) => {
|
|
188
209
|
try {
|
|
189
210
|
const response = await client.typed(
|
|
190
211
|
"get",
|
|
191
212
|
"/farmers/{farmerId}/mechanizations",
|
|
192
213
|
{
|
|
193
214
|
params: {
|
|
194
|
-
kindName
|
|
215
|
+
kindName
|
|
216
|
+
},
|
|
217
|
+
pathParams: {
|
|
218
|
+
farmerId
|
|
195
219
|
}
|
|
196
220
|
}
|
|
197
221
|
);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
);
|
|
222
|
+
const mechanizations = response.result.data.mechanizations;
|
|
223
|
+
return R2.Ok(mappers.getMechanizations(mechanizations));
|
|
201
224
|
} catch (error) {
|
|
202
225
|
return wrapError(error);
|
|
203
226
|
}
|
|
@@ -217,10 +240,9 @@ var createMechanizationServices = (client) => ({
|
|
|
217
240
|
}
|
|
218
241
|
}
|
|
219
242
|
);
|
|
243
|
+
const motorizedMechanizationSensors = response.result.data.motorizedMechanizationSensors;
|
|
220
244
|
return R2.Ok(
|
|
221
|
-
mappers.getMotorizedMechanizationSensors(
|
|
222
|
-
response.result.data.motorizedMechanizationSensors
|
|
223
|
-
)
|
|
245
|
+
mappers.getMotorizedMechanizationSensors(motorizedMechanizationSensors)
|
|
224
246
|
);
|
|
225
247
|
} catch (error) {
|
|
226
248
|
return wrapError(error);
|
|
@@ -285,13 +307,14 @@ var createMechanizationServices = (client) => ({
|
|
|
285
307
|
}
|
|
286
308
|
);
|
|
287
309
|
const questions = data?.result?.data.mechanizationsQuestions;
|
|
288
|
-
console.log("in SDK - qustions", questions);
|
|
289
310
|
return R2.Ok(mappers.getQuestions(questions));
|
|
290
311
|
} catch (error) {
|
|
291
312
|
return wrapError(error);
|
|
292
313
|
}
|
|
293
314
|
},
|
|
294
315
|
getMechanizationMovementChanges: async ({
|
|
316
|
+
farmerId,
|
|
317
|
+
mechanizationId,
|
|
295
318
|
fromDate,
|
|
296
319
|
toDate
|
|
297
320
|
}) => {
|
|
@@ -303,14 +326,15 @@ var createMechanizationServices = (client) => ({
|
|
|
303
326
|
params: {
|
|
304
327
|
fromDate,
|
|
305
328
|
toDate
|
|
329
|
+
},
|
|
330
|
+
pathParams: {
|
|
331
|
+
farmerId,
|
|
332
|
+
mechanizationId
|
|
306
333
|
}
|
|
307
334
|
}
|
|
308
335
|
);
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
response.result.data.movementChanges
|
|
312
|
-
)
|
|
313
|
-
);
|
|
336
|
+
const movementChanges = response.result.data.movementChanges;
|
|
337
|
+
return R2.Ok(mappers.getMechanizationMovementChanges(movementChanges));
|
|
314
338
|
} catch (error) {
|
|
315
339
|
return wrapError(error);
|
|
316
340
|
}
|
|
@@ -324,14 +348,12 @@ var createMechanizationServices = (client) => ({
|
|
|
324
348
|
const { data } = await client.delete(
|
|
325
349
|
`/farmers/${farmerId}/mechanizations/${mechanizationId}/delete-device-code`,
|
|
326
350
|
{
|
|
327
|
-
data: verificationToken
|
|
351
|
+
data: { verificationToken }
|
|
328
352
|
}
|
|
329
353
|
);
|
|
330
354
|
return R2.Ok(mappers.DeleteTrackingDeviceData(data));
|
|
331
355
|
} catch (error) {
|
|
332
|
-
|
|
333
|
-
console.error("UpdateTrackingDevice API Error:", err);
|
|
334
|
-
return R2.Error(err);
|
|
356
|
+
return wrapError(error);
|
|
335
357
|
}
|
|
336
358
|
}
|
|
337
359
|
});
|