@agroyaar/sdk 2.4.8 → 3.0.0-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 +320 -299
- package/dist/index.d.ts +1105 -263
- package/dist/index.mjs +320 -299
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -90,118 +90,9 @@ var createClient = (config, middlewares = []) => {
|
|
|
90
90
|
return client;
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
// src/services/dashboard/
|
|
93
|
+
// src/services/dashboard/sensors/sensors.service.ts
|
|
94
94
|
var import_ts_belt2 = require("@mobily/ts-belt");
|
|
95
95
|
|
|
96
|
-
// src/services/dashboard/mechanization/mechanization.mapper.ts
|
|
97
|
-
var mappers = {
|
|
98
|
-
getMechanizationVariety: (response) => ({
|
|
99
|
-
id: response.id,
|
|
100
|
-
name: response.name,
|
|
101
|
-
iconURL: response.iconURL,
|
|
102
|
-
kind: response.kind,
|
|
103
|
-
seasonProcessIds: response.seasonProcessIds,
|
|
104
|
-
machineUsageIds: response.machineUsageIds,
|
|
105
|
-
seasonsProcess: response.seasonsProcess
|
|
106
|
-
}),
|
|
107
|
-
getMechanizationVarietyList: (response) => response.map(mappers.getMechanizationVariety),
|
|
108
|
-
getSpeedChangesChart: (response) => ({
|
|
109
|
-
speed: response.speed,
|
|
110
|
-
date: response.date
|
|
111
|
-
}),
|
|
112
|
-
getSpeedChangesChartPointsList: (response) => response.map(mappers.getSpeedChangesChart),
|
|
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
|
-
deviceCode: res.deviceCode,
|
|
123
|
-
variety: mappers.getMechanizationVariety(res.variety)
|
|
124
|
-
}),
|
|
125
|
-
getMechanizations: (response) => response.map(mappers.getMechanization),
|
|
126
|
-
getSeasonsProcess: (response) => ({
|
|
127
|
-
id: response.id,
|
|
128
|
-
label: response.label,
|
|
129
|
-
mechanizationVarietyIds: response.mechanizationVarietyIds,
|
|
130
|
-
name: response.name
|
|
131
|
-
}),
|
|
132
|
-
getSeasonsProcessList: (response) => response.map(mappers.getSeasonsProcess),
|
|
133
|
-
getMotorizedMechanizationSensors: (response) => ({
|
|
134
|
-
id: response.id,
|
|
135
|
-
speed: response.speed,
|
|
136
|
-
heading: response.heading,
|
|
137
|
-
latitude: response.latitude,
|
|
138
|
-
longitude: response.longitude,
|
|
139
|
-
fuelLevel: response.fuelLevel,
|
|
140
|
-
engineRpm: response.engineRpm,
|
|
141
|
-
deviceCode: response.deviceCode,
|
|
142
|
-
stateEngine: response.stateEngine,
|
|
143
|
-
engineOilPressure: response.engineOilPressure,
|
|
144
|
-
engineWaterTemperature: response.engineWaterTemperature,
|
|
145
|
-
batteryChargePercentage: response.batteryChargePercentage,
|
|
146
|
-
mechanizationId: response.mechanizationId
|
|
147
|
-
}),
|
|
148
|
-
SubmitTrackingDeviceData: (response) => ({
|
|
149
|
-
deviceCode: response.deviceCode
|
|
150
|
-
}),
|
|
151
|
-
UpdateTrackingDeviceData: (response) => ({
|
|
152
|
-
deviceCode: response.deviceCode
|
|
153
|
-
}),
|
|
154
|
-
DeleteTrackingDeviceData: (response) => ({
|
|
155
|
-
deviceCode: response.deviceCode
|
|
156
|
-
}),
|
|
157
|
-
getQuestion: (dto) => ({
|
|
158
|
-
id: dto.id,
|
|
159
|
-
name: dto.key,
|
|
160
|
-
label: dto.title,
|
|
161
|
-
placeholder: dto.placeholder,
|
|
162
|
-
isRequired: dto.required,
|
|
163
|
-
type: dto.kindName,
|
|
164
|
-
options: dto.options?.map((item) => ({
|
|
165
|
-
label: item.label,
|
|
166
|
-
value: item.id
|
|
167
|
-
})) ?? []
|
|
168
|
-
}),
|
|
169
|
-
getQuestions: (dto) => dto.map(mappers.getQuestion),
|
|
170
|
-
getMechanizationMovementChange: ({
|
|
171
|
-
date,
|
|
172
|
-
heading,
|
|
173
|
-
latitude,
|
|
174
|
-
longitude
|
|
175
|
-
}) => ({
|
|
176
|
-
longitude,
|
|
177
|
-
latitude,
|
|
178
|
-
date,
|
|
179
|
-
heading
|
|
180
|
-
}),
|
|
181
|
-
getMechanizationMovementChanges: (response) => response.map(mappers.getMechanizationMovementChange),
|
|
182
|
-
createMechanization: (_dto) => ({}),
|
|
183
|
-
verifyPhoneNumber: (dto) => ({
|
|
184
|
-
phoneNumber: dto.phoneNumber,
|
|
185
|
-
verificationToken: dto.verificationToken
|
|
186
|
-
}),
|
|
187
|
-
getMechanizationTemperatureChange: ({
|
|
188
|
-
engineWaterTemperature,
|
|
189
|
-
date
|
|
190
|
-
}) => ({
|
|
191
|
-
engineWaterTemperature,
|
|
192
|
-
date
|
|
193
|
-
}),
|
|
194
|
-
getMechanizationTemperatureChanges: (response) => response.map(mappers.getMechanizationTemperatureChange),
|
|
195
|
-
getMechanizationFuelConsumptionChange: ({
|
|
196
|
-
fuelConsumption,
|
|
197
|
-
date
|
|
198
|
-
}) => ({
|
|
199
|
-
fuelConsumption,
|
|
200
|
-
date
|
|
201
|
-
}),
|
|
202
|
-
getMechanizationFuelConsumptionChanges: (response) => response.map(mappers.getMechanizationFuelConsumptionChange)
|
|
203
|
-
};
|
|
204
|
-
|
|
205
96
|
// src/utils/wrapError.ts
|
|
206
97
|
var import_ts_belt = require("@mobily/ts-belt");
|
|
207
98
|
var wrapError = (error) => {
|
|
@@ -209,323 +100,446 @@ var wrapError = (error) => {
|
|
|
209
100
|
return import_ts_belt.R.Error(err);
|
|
210
101
|
};
|
|
211
102
|
|
|
212
|
-
// src/services/dashboard/
|
|
213
|
-
var
|
|
214
|
-
|
|
215
|
-
|
|
103
|
+
// src/services/dashboard/sensors/sensors.mapper.ts
|
|
104
|
+
var sensorsMapper = {
|
|
105
|
+
getMechanizationSensors: (dto) => ({
|
|
106
|
+
id: dto.id,
|
|
107
|
+
speed: dto.speed,
|
|
108
|
+
heading: dto.heading,
|
|
109
|
+
latitude: dto.latitude,
|
|
110
|
+
longitude: dto.longitude,
|
|
111
|
+
fuelLevel: dto.fuelLevel,
|
|
112
|
+
engineRpm: dto.engineRpm,
|
|
113
|
+
deviceCode: dto.deviceCode,
|
|
114
|
+
stateEngine: dto.stateEngine,
|
|
115
|
+
engineOilPressure: dto.engineOilPressure,
|
|
116
|
+
engineWaterTemperature: dto.engineWaterTemperature,
|
|
117
|
+
batteryChargePercentage: dto.batteryChargePercentage,
|
|
118
|
+
mechanizationId: dto.mechanizationId
|
|
119
|
+
}),
|
|
120
|
+
getMechanizationTemperatureChange: (dto) => ({
|
|
121
|
+
date: dto.date,
|
|
122
|
+
engineWaterTemperature: dto.engineWaterTemperature
|
|
123
|
+
}),
|
|
124
|
+
getMechanizationTemperatureChanges: (dto) => dto.map(sensorsMapper.getMechanizationTemperatureChange),
|
|
125
|
+
getMechanizationFuelConsumptionChange: (dto) => ({
|
|
126
|
+
date: dto.date,
|
|
127
|
+
fuelConsumption: dto.fuelConsumption
|
|
128
|
+
}),
|
|
129
|
+
getMechanizationFuelConsumptionChanges: (dto) => dto.map(sensorsMapper.getMechanizationFuelConsumptionChange)
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// src/services/dashboard/sensors/sensors.service.ts
|
|
133
|
+
var createSensorsServices = (client) => ({
|
|
134
|
+
getMechanizationSensors: async ({
|
|
135
|
+
pathParams
|
|
216
136
|
}) => {
|
|
217
137
|
try {
|
|
218
|
-
const
|
|
138
|
+
const response = await client.typed(
|
|
219
139
|
"get",
|
|
220
|
-
"/
|
|
221
|
-
{
|
|
140
|
+
"/farmers/{farmerId}/mechanizations/{mechanizationId}/sensors",
|
|
141
|
+
{
|
|
142
|
+
pathParams
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
const motorizedMechanizationSensors = response.result.data.motorizedMechanizationSensors;
|
|
146
|
+
return import_ts_belt2.R.Ok(
|
|
147
|
+
sensorsMapper.getMechanizationSensors(motorizedMechanizationSensors)
|
|
222
148
|
);
|
|
223
|
-
const mechanizationVarieties = result.data.mechanizationVarieties;
|
|
224
|
-
return import_ts_belt2.R.Ok(mappers.getMechanizationVarietyList(mechanizationVarieties));
|
|
225
149
|
} catch (error) {
|
|
226
150
|
return wrapError(error);
|
|
227
151
|
}
|
|
228
152
|
},
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
153
|
+
getMechanizationTemperatureChanges: async ({
|
|
154
|
+
params,
|
|
155
|
+
pathParams
|
|
232
156
|
}) => {
|
|
233
157
|
try {
|
|
234
|
-
const
|
|
158
|
+
const response = await client.typed(
|
|
235
159
|
"get",
|
|
236
|
-
"/farmers/{farmerId}/mechanizations/{mechanizationId}/sensors/
|
|
160
|
+
"/farmers/{farmerId}/mechanizations/{mechanizationId}/sensors/temperature-changes",
|
|
237
161
|
{
|
|
238
|
-
|
|
162
|
+
params,
|
|
163
|
+
pathParams
|
|
239
164
|
}
|
|
240
165
|
);
|
|
166
|
+
const temperatureChanges = response.result.data.temperatureChanges;
|
|
241
167
|
return import_ts_belt2.R.Ok(
|
|
242
|
-
|
|
168
|
+
sensorsMapper.getMechanizationTemperatureChanges(temperatureChanges)
|
|
243
169
|
);
|
|
244
170
|
} catch (error) {
|
|
245
171
|
return wrapError(error);
|
|
246
172
|
}
|
|
247
173
|
},
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
174
|
+
getMechanizationFuelConsumptionChanges: async ({
|
|
175
|
+
params,
|
|
176
|
+
pathParams
|
|
251
177
|
}) => {
|
|
252
178
|
try {
|
|
253
179
|
const response = await client.typed(
|
|
254
180
|
"get",
|
|
255
|
-
"/farmers/{farmerId}/mechanizations/{mechanizationId}",
|
|
181
|
+
"/farmers/{farmerId}/mechanizations/{mechanizationId}/sensors/fuel-consumption-changes",
|
|
256
182
|
{
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
mechanizationId
|
|
260
|
-
}
|
|
183
|
+
params,
|
|
184
|
+
pathParams
|
|
261
185
|
}
|
|
262
186
|
);
|
|
263
|
-
const
|
|
264
|
-
return import_ts_belt2.R.Ok(
|
|
187
|
+
const fuelConsumptionChanges = response.result.data.fuelConsumptionChanges;
|
|
188
|
+
return import_ts_belt2.R.Ok(
|
|
189
|
+
sensorsMapper.getMechanizationFuelConsumptionChanges(
|
|
190
|
+
fuelConsumptionChanges
|
|
191
|
+
)
|
|
192
|
+
);
|
|
265
193
|
} catch (error) {
|
|
266
194
|
return wrapError(error);
|
|
267
195
|
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// src/services/dashboard/seasons-process/seasonsProcess.service.ts
|
|
200
|
+
var import_ts_belt3 = require("@mobily/ts-belt");
|
|
201
|
+
|
|
202
|
+
// src/services/dashboard/seasons-process/seasonsProcess.mapper.ts
|
|
203
|
+
var seasonsProcessMapper = {
|
|
204
|
+
getOne: (dto) => ({
|
|
205
|
+
id: dto.id,
|
|
206
|
+
label: dto.label,
|
|
207
|
+
name: dto.name
|
|
208
|
+
}),
|
|
209
|
+
getAll: (dto) => dto.map(seasonsProcessMapper.getOne)
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// src/services/dashboard/seasons-process/seasonsProcess.service.ts
|
|
213
|
+
var createSeasonsProcess = (client) => ({
|
|
214
|
+
getSeasonsProcess: async () => {
|
|
273
215
|
try {
|
|
274
216
|
const response = await client.typed(
|
|
275
217
|
"get",
|
|
276
|
-
"/
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
farmerId
|
|
283
|
-
}
|
|
284
|
-
}
|
|
218
|
+
"/statics/mechanizations-seasons-process-kinds"
|
|
219
|
+
);
|
|
220
|
+
return import_ts_belt3.R.Ok(
|
|
221
|
+
seasonsProcessMapper.getAll(
|
|
222
|
+
response.result.data.mechanizationSeasonProcessKinds
|
|
223
|
+
)
|
|
285
224
|
);
|
|
286
|
-
const mechanizations = response.result.data.mechanizations;
|
|
287
|
-
return import_ts_belt2.R.Ok(mappers.getMechanizations(mechanizations));
|
|
288
225
|
} catch (error) {
|
|
289
226
|
return wrapError(error);
|
|
290
227
|
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
// src/services/dashboard/mechanization-variety/variety.mapper.ts
|
|
232
|
+
var varietiesMapper = {
|
|
233
|
+
getOne: (dto) => ({
|
|
234
|
+
id: dto.id,
|
|
235
|
+
name: dto.name,
|
|
236
|
+
iconURL: dto.iconURL,
|
|
237
|
+
kind: dto.kind,
|
|
238
|
+
seasonProcessIds: dto.seasonProcessIds,
|
|
239
|
+
machineUsageIds: dto.machineUsageIds,
|
|
240
|
+
seasonsProcess: dto.seasonsProcess
|
|
241
|
+
}),
|
|
242
|
+
getAll: (dto) => dto.map(varietiesMapper.getOne)
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// src/services/dashboard/mechanization-variety/variety.service.ts
|
|
246
|
+
var import_ts_belt4 = require("@mobily/ts-belt");
|
|
247
|
+
var createVarietiesService = (client) => ({
|
|
248
|
+
getAllMechanizationVarieties: async ({
|
|
249
|
+
params
|
|
295
250
|
}) => {
|
|
296
251
|
try {
|
|
297
|
-
const
|
|
252
|
+
const { result } = await client.typed(
|
|
298
253
|
"get",
|
|
299
|
-
"/
|
|
300
|
-
{
|
|
301
|
-
pathParams: {
|
|
302
|
-
farmerId,
|
|
303
|
-
mechanizationId
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
);
|
|
307
|
-
const motorizedMechanizationSensors = response.result.data.motorizedMechanizationSensors;
|
|
308
|
-
return import_ts_belt2.R.Ok(
|
|
309
|
-
mappers.getMotorizedMechanizationSensors(motorizedMechanizationSensors)
|
|
254
|
+
"/statics/mechanizations-varieties",
|
|
255
|
+
{ params }
|
|
310
256
|
);
|
|
257
|
+
const mechanizationVarieties = result.data.mechanizationVarieties;
|
|
258
|
+
return import_ts_belt4.R.Ok(varietiesMapper.getAll(mechanizationVarieties));
|
|
311
259
|
} catch (error) {
|
|
312
260
|
return wrapError(error);
|
|
313
261
|
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// src/services/dashboard/mechanization-question/getQuestion.service.ts
|
|
266
|
+
var import_ts_belt5 = require("@mobily/ts-belt");
|
|
267
|
+
|
|
268
|
+
// src/services/dashboard/mechanization-question/question.mapper.ts
|
|
269
|
+
var mechanizationQuestionMappers = {
|
|
270
|
+
getOne: (dto) => ({
|
|
271
|
+
id: dto.id,
|
|
272
|
+
name: dto.key,
|
|
273
|
+
label: dto.title,
|
|
274
|
+
placeholder: dto.placeholder,
|
|
275
|
+
isRequired: dto.required,
|
|
276
|
+
type: dto.kindName,
|
|
277
|
+
options: dto.options?.map((item) => ({
|
|
278
|
+
label: item.label,
|
|
279
|
+
value: item.id
|
|
280
|
+
})) ?? []
|
|
281
|
+
}),
|
|
282
|
+
getAll: (dto) => dto.map(mechanizationQuestionMappers.getOne)
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
// src/services/dashboard/mechanization-question/getQuestion.service.ts
|
|
286
|
+
var createQuestionServices = (client) => ({
|
|
287
|
+
getAllMechanizationQuestions: async ({
|
|
288
|
+
params
|
|
319
289
|
}) => {
|
|
320
290
|
try {
|
|
321
|
-
const
|
|
322
|
-
"
|
|
323
|
-
"/
|
|
291
|
+
const data = await client.typed(
|
|
292
|
+
"get",
|
|
293
|
+
"/statics/mechanizations-questions",
|
|
324
294
|
{
|
|
325
|
-
|
|
326
|
-
pathParams: {
|
|
327
|
-
farmerId,
|
|
328
|
-
mechanizationId
|
|
329
|
-
}
|
|
295
|
+
params: { mechanizationVarietyId: params.mechanizationVarietyId }
|
|
330
296
|
}
|
|
331
297
|
);
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
);
|
|
298
|
+
const questions = data?.result.data.mechanizationsQuestions;
|
|
299
|
+
return import_ts_belt5.R.Ok(mechanizationQuestionMappers.getAll(questions));
|
|
335
300
|
} catch (error) {
|
|
336
301
|
return wrapError(error);
|
|
337
302
|
}
|
|
338
|
-
}
|
|
339
|
-
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
// src/services/dashboard/device-code/device.service.ts
|
|
307
|
+
var import_ts_belt6 = require("@mobily/ts-belt");
|
|
308
|
+
|
|
309
|
+
// src/services/dashboard/device-code/deviceCode.mapper.ts
|
|
310
|
+
var deviceCodeMapper = {
|
|
311
|
+
create: (dto) => ({
|
|
312
|
+
deviceCode: dto.deviceCode
|
|
313
|
+
}),
|
|
314
|
+
update: (dto) => ({
|
|
315
|
+
deviceCode: dto.deviceCode
|
|
316
|
+
}),
|
|
317
|
+
delete: (dto) => ({
|
|
318
|
+
deviceCode: dto.deviceCode
|
|
319
|
+
})
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
// src/services/dashboard/device-code/device.service.ts
|
|
323
|
+
var createDeviceCodeServices = (client) => ({
|
|
324
|
+
create: async ({
|
|
325
|
+
body,
|
|
326
|
+
pathParams
|
|
327
|
+
}) => {
|
|
340
328
|
try {
|
|
341
|
-
const
|
|
342
|
-
"
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
329
|
+
const result = await client.typed(
|
|
330
|
+
"put",
|
|
331
|
+
"/farmers/{farmerId}/mechanizations/{mechanizationId}/submit-device-code",
|
|
332
|
+
{
|
|
333
|
+
body,
|
|
334
|
+
pathParams
|
|
335
|
+
}
|
|
348
336
|
);
|
|
337
|
+
return import_ts_belt6.R.Ok(deviceCodeMapper.create(result.result.data.mechanization));
|
|
349
338
|
} catch (error) {
|
|
350
339
|
return wrapError(error);
|
|
351
340
|
}
|
|
352
341
|
},
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
deviceCode,
|
|
357
|
-
verificationToken
|
|
342
|
+
update: async ({
|
|
343
|
+
body,
|
|
344
|
+
pathParams
|
|
358
345
|
}) => {
|
|
359
346
|
try {
|
|
360
347
|
const result = await client.typed(
|
|
361
348
|
"put",
|
|
362
349
|
"/farmers/{farmerId}/mechanizations/{mechanizationId}/update-device-code",
|
|
363
350
|
{
|
|
364
|
-
body
|
|
365
|
-
|
|
366
|
-
verificationToken
|
|
367
|
-
},
|
|
368
|
-
pathParams: {
|
|
369
|
-
farmerId,
|
|
370
|
-
mechanizationId
|
|
371
|
-
}
|
|
351
|
+
body,
|
|
352
|
+
pathParams
|
|
372
353
|
}
|
|
373
354
|
);
|
|
374
|
-
return
|
|
375
|
-
mappers.UpdateTrackingDeviceData(result.result.data.mechanization)
|
|
376
|
-
);
|
|
355
|
+
return import_ts_belt6.R.Ok(deviceCodeMapper.update(result.result.data.mechanization));
|
|
377
356
|
} catch (error) {
|
|
378
357
|
return wrapError(error);
|
|
379
358
|
}
|
|
380
359
|
},
|
|
381
|
-
|
|
382
|
-
|
|
360
|
+
deleteTrackingDeviceCode: async ({
|
|
361
|
+
body,
|
|
362
|
+
pathParams
|
|
383
363
|
}) => {
|
|
384
364
|
try {
|
|
385
|
-
const
|
|
386
|
-
"
|
|
387
|
-
"/
|
|
365
|
+
const result = await client.typed(
|
|
366
|
+
"delete",
|
|
367
|
+
"/farmers/{farmerId}/mechanizations/{mechanizationId}/delete-device-code",
|
|
388
368
|
{
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
}
|
|
369
|
+
body,
|
|
370
|
+
pathParams
|
|
392
371
|
}
|
|
393
372
|
);
|
|
394
|
-
|
|
395
|
-
return import_ts_belt2.R.Ok(mappers.getQuestions(questions));
|
|
373
|
+
return import_ts_belt6.R.Ok(deviceCodeMapper.delete(result.result.data.mechanization));
|
|
396
374
|
} catch (error) {
|
|
397
375
|
return wrapError(error);
|
|
398
376
|
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
// src/services/dashboard/charts/charts.service.ts
|
|
381
|
+
var import_ts_belt7 = require("@mobily/ts-belt");
|
|
382
|
+
|
|
383
|
+
// src/services/dashboard/charts/chart.mapper.ts
|
|
384
|
+
var chartMapper = {
|
|
385
|
+
getSpeedChange: (dto) => ({
|
|
386
|
+
speed: dto.speed,
|
|
387
|
+
date: dto.date
|
|
388
|
+
}),
|
|
389
|
+
getSpeedChangesList: (dto) => dto.map(chartMapper.getSpeedChange),
|
|
390
|
+
getMovementChange: ({
|
|
391
|
+
date,
|
|
392
|
+
heading,
|
|
393
|
+
latitude,
|
|
394
|
+
longitude
|
|
395
|
+
}) => ({
|
|
396
|
+
longitude,
|
|
397
|
+
latitude,
|
|
398
|
+
date,
|
|
399
|
+
heading
|
|
400
|
+
}),
|
|
401
|
+
getMovementChangeList: (dto) => ({
|
|
402
|
+
movementChanges: dto.movementChanges.map(chartMapper.getMovementChange),
|
|
403
|
+
meta: dto.meta
|
|
404
|
+
})
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
// src/services/dashboard/charts/charts.service.ts
|
|
408
|
+
var createChartServices = (client) => ({
|
|
409
|
+
getSpeedChangesChartData: async ({
|
|
410
|
+
params,
|
|
411
|
+
pathParams
|
|
405
412
|
}) => {
|
|
406
413
|
try {
|
|
407
|
-
const
|
|
414
|
+
const { result } = await client.typed(
|
|
408
415
|
"get",
|
|
409
|
-
"/farmers/{farmerId}/mechanizations/{mechanizationId}/sensors/
|
|
416
|
+
"/farmers/{farmerId}/mechanizations/{mechanizationId}/sensors/speed-changes",
|
|
410
417
|
{
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
toDate
|
|
414
|
-
},
|
|
415
|
-
pathParams: {
|
|
416
|
-
farmerId,
|
|
417
|
-
mechanizationId
|
|
418
|
-
}
|
|
418
|
+
pathParams,
|
|
419
|
+
params
|
|
419
420
|
}
|
|
420
421
|
);
|
|
421
|
-
|
|
422
|
-
return import_ts_belt2.R.Ok(mappers.getMechanizationMovementChanges(movementChanges));
|
|
422
|
+
return import_ts_belt7.R.Ok(chartMapper.getSpeedChangesList(result.data.speedChanges));
|
|
423
423
|
} catch (error) {
|
|
424
424
|
return wrapError(error);
|
|
425
425
|
}
|
|
426
426
|
},
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
verificationToken
|
|
427
|
+
getMechanizationMovementChanges: async ({
|
|
428
|
+
params,
|
|
429
|
+
pathParams
|
|
431
430
|
}) => {
|
|
432
431
|
try {
|
|
433
|
-
const
|
|
434
|
-
"
|
|
435
|
-
"/farmers/{farmerId}/mechanizations/{mechanizationId}/
|
|
432
|
+
const response = await client.typed(
|
|
433
|
+
"get",
|
|
434
|
+
"/farmers/{farmerId}/mechanizations/{mechanizationId}/sensors/movement-changes",
|
|
436
435
|
{
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
},
|
|
440
|
-
pathParams: {
|
|
441
|
-
farmerId,
|
|
442
|
-
mechanizationId
|
|
443
|
-
}
|
|
436
|
+
params,
|
|
437
|
+
pathParams
|
|
444
438
|
}
|
|
445
439
|
);
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
);
|
|
440
|
+
const data = response.result.data;
|
|
441
|
+
return import_ts_belt7.R.Ok(chartMapper.getMovementChangeList(data));
|
|
449
442
|
} catch (error) {
|
|
450
443
|
return wrapError(error);
|
|
451
444
|
}
|
|
452
|
-
}
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
// src/services/dashboard/auth/auth.service.ts
|
|
449
|
+
var import_ts_belt8 = require("@mobily/ts-belt");
|
|
450
|
+
|
|
451
|
+
// src/services/dashboard/auth/auth.mapper.ts
|
|
452
|
+
var authMapper = {
|
|
453
|
+
verifyPhoneNumber: (dto) => ({
|
|
454
|
+
phoneNumber: dto.phoneNumber,
|
|
455
|
+
verificationToken: dto.verificationToken
|
|
456
|
+
})
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
// src/services/dashboard/auth/auth.service.ts
|
|
460
|
+
var createAuthService = (client) => ({
|
|
453
461
|
verifyPhoneNumber: async ({
|
|
454
|
-
|
|
455
|
-
otpCode
|
|
462
|
+
body
|
|
456
463
|
}) => {
|
|
457
464
|
try {
|
|
458
465
|
const result = await client.typed("post", "/auth/verify-phone-number", {
|
|
459
|
-
body
|
|
466
|
+
body
|
|
460
467
|
});
|
|
461
|
-
return
|
|
462
|
-
|
|
468
|
+
return import_ts_belt8.R.Ok(
|
|
469
|
+
authMapper.verifyPhoneNumber(result.result.data.verifyPhoneNumber)
|
|
463
470
|
);
|
|
464
471
|
} catch (error) {
|
|
465
472
|
return wrapError(error);
|
|
466
473
|
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
// src/services/dashboard/mechanization/mechanization.service.ts
|
|
478
|
+
var import_ts_belt9 = require("@mobily/ts-belt");
|
|
479
|
+
|
|
480
|
+
// src/services/dashboard/mechanization/mechanization.mapper.ts
|
|
481
|
+
var mechanizationMapper = {
|
|
482
|
+
getOne: (dto) => ({
|
|
483
|
+
id: dto.id,
|
|
484
|
+
commonName: dto.commonName,
|
|
485
|
+
model: dto.model,
|
|
486
|
+
avatarURL: dto.avatarURL,
|
|
487
|
+
manufactureYear: dto.manufactureYear,
|
|
488
|
+
code: dto.code,
|
|
489
|
+
kind: dto.kind,
|
|
490
|
+
kindName: dto.kindName,
|
|
491
|
+
deviceCode: dto.deviceCode,
|
|
492
|
+
variety: varietiesMapper.getOne(dto.variety)
|
|
493
|
+
}),
|
|
494
|
+
getAll: (dto) => dto.map(mechanizationMapper.getOne),
|
|
495
|
+
create: (_res) => ({})
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
// src/services/dashboard/mechanization/mechanization.service.ts
|
|
499
|
+
var createMechanizationServices = (client) => ({
|
|
500
|
+
getOne: async ({
|
|
501
|
+
pathParams
|
|
473
502
|
}) => {
|
|
474
503
|
try {
|
|
475
504
|
const response = await client.typed(
|
|
476
505
|
"get",
|
|
477
|
-
"/farmers/{farmerId}/mechanizations/{mechanizationId}
|
|
506
|
+
"/farmers/{farmerId}/mechanizations/{mechanizationId}",
|
|
478
507
|
{
|
|
479
|
-
|
|
480
|
-
fromDate,
|
|
481
|
-
toDate
|
|
482
|
-
},
|
|
483
|
-
pathParams: {
|
|
484
|
-
farmerId,
|
|
485
|
-
mechanizationId
|
|
486
|
-
}
|
|
508
|
+
pathParams
|
|
487
509
|
}
|
|
488
510
|
);
|
|
489
|
-
const
|
|
490
|
-
return
|
|
491
|
-
mappers.getMechanizationTemperatureChanges(temperatureChanges)
|
|
492
|
-
);
|
|
511
|
+
const mechanization = response.result.data.mechanization;
|
|
512
|
+
return import_ts_belt9.R.Ok(mechanizationMapper.getOne(mechanization));
|
|
493
513
|
} catch (error) {
|
|
494
514
|
return wrapError(error);
|
|
495
515
|
}
|
|
496
516
|
},
|
|
497
|
-
|
|
498
|
-
farmerId,
|
|
499
|
-
|
|
500
|
-
fromDate,
|
|
501
|
-
toDate
|
|
517
|
+
getAllMechanizations: async ({
|
|
518
|
+
pathParams: { farmerId },
|
|
519
|
+
path: { kindName }
|
|
502
520
|
}) => {
|
|
503
521
|
try {
|
|
504
522
|
const response = await client.typed(
|
|
505
523
|
"get",
|
|
506
|
-
"/farmers/{farmerId}/mechanizations
|
|
524
|
+
"/farmers/{farmerId}/mechanizations",
|
|
507
525
|
{
|
|
508
526
|
params: {
|
|
509
|
-
|
|
510
|
-
toDate
|
|
527
|
+
kindName
|
|
511
528
|
},
|
|
512
529
|
pathParams: {
|
|
513
|
-
farmerId
|
|
514
|
-
mechanizationId
|
|
530
|
+
farmerId
|
|
515
531
|
}
|
|
516
532
|
}
|
|
517
533
|
);
|
|
518
|
-
const
|
|
519
|
-
return
|
|
520
|
-
mappers.getMechanizationFuelConsumptionChanges(fuelConsumptionChanges)
|
|
521
|
-
);
|
|
534
|
+
const mechanizations = response.result.data.mechanizations;
|
|
535
|
+
return import_ts_belt9.R.Ok(mechanizationMapper.getAll(mechanizations));
|
|
522
536
|
} catch (error) {
|
|
523
537
|
return wrapError(error);
|
|
524
538
|
}
|
|
525
539
|
},
|
|
526
540
|
CreateMechanization: async ({
|
|
527
|
-
|
|
528
|
-
|
|
541
|
+
body,
|
|
542
|
+
pathParams
|
|
529
543
|
}) => {
|
|
530
544
|
try {
|
|
531
545
|
const response = await client.typed(
|
|
@@ -533,7 +547,7 @@ var createMechanizationServices = (client) => ({
|
|
|
533
547
|
"/farmers/{farmerId}/mechanizations",
|
|
534
548
|
{
|
|
535
549
|
pathParams: {
|
|
536
|
-
farmerId
|
|
550
|
+
farmerId: pathParams.farmerId
|
|
537
551
|
},
|
|
538
552
|
body: {
|
|
539
553
|
avatarURL: body.avatarURL,
|
|
@@ -542,8 +556,8 @@ var createMechanizationServices = (client) => ({
|
|
|
542
556
|
}
|
|
543
557
|
}
|
|
544
558
|
);
|
|
545
|
-
return
|
|
546
|
-
|
|
559
|
+
return import_ts_belt9.R.Ok(
|
|
560
|
+
mechanizationMapper.create(response.result.data.mechanization)
|
|
547
561
|
);
|
|
548
562
|
} catch (error) {
|
|
549
563
|
return wrapError(error);
|
|
@@ -556,7 +570,14 @@ var createSDK = (config, middlewares = []) => {
|
|
|
556
570
|
const client = createClient(config, middlewares);
|
|
557
571
|
return {
|
|
558
572
|
dashboardServices: {
|
|
559
|
-
mechanization: createMechanizationServices(client)
|
|
573
|
+
mechanization: createMechanizationServices(client),
|
|
574
|
+
auth: createAuthService(client),
|
|
575
|
+
charts: createChartServices(client),
|
|
576
|
+
deviceCode: createDeviceCodeServices(client),
|
|
577
|
+
mechanizationQuestion: createQuestionServices(client),
|
|
578
|
+
seasonsProcess: createSeasonsProcess(client),
|
|
579
|
+
sensors: createSensorsServices(client),
|
|
580
|
+
varieties: createVarietiesService(client)
|
|
560
581
|
}
|
|
561
582
|
};
|
|
562
583
|
};
|