@agroyaar/sdk 1.4.1-3 → 1.4.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 +64 -16
- package/dist/index.d.ts +227 -12
- package/dist/index.mjs +64 -16
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -84,10 +84,14 @@ var mappers = {
|
|
|
84
84
|
iconURL: response.iconURL,
|
|
85
85
|
kind: response.kind,
|
|
86
86
|
seasonProcessIds: response.seasonProcessIds,
|
|
87
|
-
machineUsageIds: response.machineUsageIds
|
|
88
|
-
seasonsProcess: response.seasonsProcess
|
|
87
|
+
machineUsageIds: response.machineUsageIds
|
|
89
88
|
}),
|
|
90
89
|
getMechanizationVarietyList: (response) => response.map(mappers.getMechanizationVariety),
|
|
90
|
+
getSpeedChangesChart: (response) => ({
|
|
91
|
+
speed: response.speed,
|
|
92
|
+
date: response.date
|
|
93
|
+
}),
|
|
94
|
+
getSpeedChangesChartPointsList: (response) => response.map(mappers.getSpeedChangesChart),
|
|
91
95
|
getMechanization: (response) => ({
|
|
92
96
|
id: response.id,
|
|
93
97
|
commonName: response.commonName,
|
|
@@ -100,13 +104,24 @@ var mappers = {
|
|
|
100
104
|
variety: mappers.getMechanizationVariety(response.variety)
|
|
101
105
|
}),
|
|
102
106
|
getMechanizationsList: (response) => response.map(mappers.getMechanization),
|
|
103
|
-
|
|
107
|
+
getMotorizedMechanizationSensors: (response) => ({
|
|
104
108
|
id: response.id,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
109
|
+
speed: response.speed,
|
|
110
|
+
heading: response.heading,
|
|
111
|
+
latitude: response.latitude,
|
|
112
|
+
longitude: response.longitude,
|
|
113
|
+
fuelLevel: response.fuelLevel,
|
|
114
|
+
engineRpm: response.engineRpm,
|
|
115
|
+
deviceCode: response.deviceCode,
|
|
116
|
+
stateEngine: response.stateEngine,
|
|
117
|
+
engineOilPressure: response.engineOilPressure,
|
|
118
|
+
engineWaterTemperature: response.engineWaterTemperature,
|
|
119
|
+
batteryChargePercentage: response.batteryChargePercentage,
|
|
120
|
+
mechanizationId: response.mechanizationId
|
|
108
121
|
}),
|
|
109
|
-
|
|
122
|
+
SubmitTrackingDeviceData: (response) => ({
|
|
123
|
+
deviceCode: response.deviceCode
|
|
124
|
+
})
|
|
110
125
|
};
|
|
111
126
|
|
|
112
127
|
// src/services/dashboard/mechanization/mechanization.service.ts
|
|
@@ -129,10 +144,26 @@ var createMechanizationServices = (client) => ({
|
|
|
129
144
|
return import_ts_belt.R.Error(err);
|
|
130
145
|
}
|
|
131
146
|
},
|
|
132
|
-
|
|
147
|
+
getSpeedChangesChartData: async ({
|
|
148
|
+
farmerId,
|
|
149
|
+
mechanizationId
|
|
150
|
+
}) => {
|
|
151
|
+
try {
|
|
152
|
+
const { data } = await client.get(
|
|
153
|
+
`/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors/speed-changes`
|
|
154
|
+
);
|
|
155
|
+
return import_ts_belt.R.Ok(
|
|
156
|
+
mappers.getSpeedChangesChartPointsList(data.result.data.speedChanges)
|
|
157
|
+
);
|
|
158
|
+
} catch (error) {
|
|
159
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
160
|
+
console.error("SpeedChangesChartPointsList API Error:", err);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
getMechanizations: async ({ kindName, farmerId }) => {
|
|
133
164
|
try {
|
|
134
165
|
const { data } = await client.get(
|
|
135
|
-
`/farmers/
|
|
166
|
+
`/farmers/${farmerId}/mechanizations?kindName=${kindName}`
|
|
136
167
|
);
|
|
137
168
|
return import_ts_belt.R.Ok(
|
|
138
169
|
mappers.getMechanizationsList(data.result.data.mechanizations)
|
|
@@ -143,19 +174,36 @@ var createMechanizationServices = (client) => ({
|
|
|
143
174
|
return import_ts_belt.R.Error(err);
|
|
144
175
|
}
|
|
145
176
|
},
|
|
146
|
-
|
|
177
|
+
getMotorizedMechanizationSensors: async ({
|
|
178
|
+
farmerId,
|
|
179
|
+
mechanizationId
|
|
180
|
+
}) => {
|
|
147
181
|
try {
|
|
148
|
-
const { data } = await client.get(
|
|
149
|
-
"/statics/mechanizations-seasons-process-kinds"
|
|
150
|
-
);
|
|
182
|
+
const { data } = await client.get(`/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors`);
|
|
151
183
|
return import_ts_belt.R.Ok(
|
|
152
|
-
mappers.
|
|
153
|
-
data.result.data.
|
|
184
|
+
mappers.getMotorizedMechanizationSensors(
|
|
185
|
+
data.result.data.motorizedMechanizationSensors
|
|
154
186
|
)
|
|
155
187
|
);
|
|
156
188
|
} catch (error) {
|
|
157
189
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
158
|
-
console.error("
|
|
190
|
+
console.error("Mechanization API Error:", err);
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
SubmitTrackingDeviceCode: async ({
|
|
194
|
+
farmerId,
|
|
195
|
+
mechanizationId,
|
|
196
|
+
deviceCode
|
|
197
|
+
}) => {
|
|
198
|
+
try {
|
|
199
|
+
const { data } = await client.put(
|
|
200
|
+
`/farmers/${farmerId}/mechanizations/${mechanizationId}/submit-device-code`,
|
|
201
|
+
{ deviceCode }
|
|
202
|
+
);
|
|
203
|
+
return import_ts_belt.R.Ok(mappers.SubmitTrackingDeviceData(data));
|
|
204
|
+
} catch (error) {
|
|
205
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
206
|
+
console.error("SubmitTrackingDevice API Error:", err);
|
|
159
207
|
return import_ts_belt.R.Error(err);
|
|
160
208
|
}
|
|
161
209
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,9 +9,176 @@ type Brand<B> = {
|
|
|
9
9
|
type Branded<T, B> = Brand<B> & T;
|
|
10
10
|
|
|
11
11
|
declare namespace Identifiers {
|
|
12
|
-
type MechanizationVarietyId = Branded<string, "
|
|
13
|
-
type MechanizationId = Branded<string, "
|
|
14
|
-
type
|
|
12
|
+
type MechanizationVarietyId = Branded<string, "mechanizationVarietyId-id">;
|
|
13
|
+
type MechanizationId = Branded<string, "mechanizationId-id">;
|
|
14
|
+
type MotorizedMechanizationSensorsId = Branded<string, "motorized-mechanization-sensorsId-id">;
|
|
15
|
+
type FarmerId = Branded<string, "farmer-id">;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type FarmerDTO = {
|
|
19
|
+
id: string;
|
|
20
|
+
username: string;
|
|
21
|
+
firstName: string;
|
|
22
|
+
lastName: string;
|
|
23
|
+
fullName: string;
|
|
24
|
+
phoneNumber: string;
|
|
25
|
+
nationalCode: string;
|
|
26
|
+
farmerCode: string;
|
|
27
|
+
birthDate: string;
|
|
28
|
+
avatar: string;
|
|
29
|
+
province: string;
|
|
30
|
+
provinceId: number;
|
|
31
|
+
city: string;
|
|
32
|
+
cityId: number;
|
|
33
|
+
zone: string;
|
|
34
|
+
address: string;
|
|
35
|
+
postalCode: number;
|
|
36
|
+
role: string;
|
|
37
|
+
productsIds: number[];
|
|
38
|
+
status: string;
|
|
39
|
+
walletBalance: number;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
type MechanizationAnswerOptionDTO = {
|
|
43
|
+
id: string;
|
|
44
|
+
label: string;
|
|
45
|
+
mechanizationQuestionId: string;
|
|
46
|
+
};
|
|
47
|
+
type InformationDTO = {
|
|
48
|
+
id: string;
|
|
49
|
+
status: Status;
|
|
50
|
+
answerOptions: MechanizationAnswerOptionDTO;
|
|
51
|
+
answerValue: string;
|
|
52
|
+
mechanizationId: string;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
declare namespace ServerResponseTypes {
|
|
56
|
+
namespace Dashboard {
|
|
57
|
+
type MechanizationVarietyDTO = {
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
code: string;
|
|
61
|
+
iconURL: string;
|
|
62
|
+
kind: VarietyKind;
|
|
63
|
+
kindName: MechanizationType;
|
|
64
|
+
seasonsProcess: MechanizationSeasonProcessKind[];
|
|
65
|
+
seasonProcessIds: string[];
|
|
66
|
+
machinesUsage: MechanizationMachineUsageKind[];
|
|
67
|
+
machineUsageIds: string[];
|
|
68
|
+
mechanizationQuestions: string[];
|
|
69
|
+
};
|
|
70
|
+
type MechanizationDTO = {
|
|
71
|
+
id: string;
|
|
72
|
+
model: string;
|
|
73
|
+
commonName: string;
|
|
74
|
+
avatarURL: string;
|
|
75
|
+
manufactureYear: string;
|
|
76
|
+
code: string;
|
|
77
|
+
kind: VarietyKind;
|
|
78
|
+
kindName: MechanizationType;
|
|
79
|
+
deviceCode: string;
|
|
80
|
+
status: Status;
|
|
81
|
+
farmer: FarmerDTO;
|
|
82
|
+
farmerId: string;
|
|
83
|
+
variety: MechanizationVarietyDTO;
|
|
84
|
+
information: InformationDTO[];
|
|
85
|
+
};
|
|
86
|
+
type MotorizedMechanizationSensorsDTO = {
|
|
87
|
+
id: string;
|
|
88
|
+
speed: number;
|
|
89
|
+
heading: string;
|
|
90
|
+
latitude: number;
|
|
91
|
+
longitude: number;
|
|
92
|
+
fuelLevel: number;
|
|
93
|
+
engineRpm: number;
|
|
94
|
+
deviceCode: string;
|
|
95
|
+
stateEngine: boolean;
|
|
96
|
+
engineOilPressure: boolean;
|
|
97
|
+
engineWaterTemperature: string;
|
|
98
|
+
batteryChargePercentage: string;
|
|
99
|
+
mechanizationId: string;
|
|
100
|
+
mechanization: MechanizationDTO;
|
|
101
|
+
};
|
|
102
|
+
type SubmitTrackingDeviceDTO = {
|
|
103
|
+
model: string;
|
|
104
|
+
commonName: string;
|
|
105
|
+
manufactureYear: number;
|
|
106
|
+
code: string;
|
|
107
|
+
deviceCode: string;
|
|
108
|
+
status: {
|
|
109
|
+
id: string;
|
|
110
|
+
label: string;
|
|
111
|
+
name: string;
|
|
112
|
+
};
|
|
113
|
+
farmer: {
|
|
114
|
+
id: string;
|
|
115
|
+
createdAt: string;
|
|
116
|
+
updatedAt: string;
|
|
117
|
+
deletedAt: string | null;
|
|
118
|
+
firstName: string;
|
|
119
|
+
lastName: string;
|
|
120
|
+
phoneNumber: string;
|
|
121
|
+
city: {};
|
|
122
|
+
cityId: string;
|
|
123
|
+
nationalCode: string;
|
|
124
|
+
province: {};
|
|
125
|
+
provinceId: string;
|
|
126
|
+
zone: string;
|
|
127
|
+
farmerCode: string;
|
|
128
|
+
avatar: string;
|
|
129
|
+
walletBalance: number;
|
|
130
|
+
status: string;
|
|
131
|
+
};
|
|
132
|
+
farmerId: string;
|
|
133
|
+
variety: {
|
|
134
|
+
id: string;
|
|
135
|
+
name: string;
|
|
136
|
+
code: string;
|
|
137
|
+
iconURL: string;
|
|
138
|
+
kind: {
|
|
139
|
+
id: string;
|
|
140
|
+
label: string;
|
|
141
|
+
name: string;
|
|
142
|
+
};
|
|
143
|
+
kindName: string;
|
|
144
|
+
seasonsProcess: {
|
|
145
|
+
id: string;
|
|
146
|
+
label: string;
|
|
147
|
+
name: string;
|
|
148
|
+
}[];
|
|
149
|
+
seasonProcessIds: string[];
|
|
150
|
+
machinesUsage: {
|
|
151
|
+
id: string;
|
|
152
|
+
label: string;
|
|
153
|
+
name: string;
|
|
154
|
+
}[];
|
|
155
|
+
machineUsageIds: string[];
|
|
156
|
+
mechanizationQuestions: string[];
|
|
157
|
+
};
|
|
158
|
+
information: {
|
|
159
|
+
id: string;
|
|
160
|
+
createdAt: string;
|
|
161
|
+
updatedAt: string;
|
|
162
|
+
deletedAt: string | null;
|
|
163
|
+
status: {
|
|
164
|
+
id: string;
|
|
165
|
+
label: string;
|
|
166
|
+
name: string;
|
|
167
|
+
};
|
|
168
|
+
answerOptions: {
|
|
169
|
+
id: string;
|
|
170
|
+
label: string;
|
|
171
|
+
mechanizationQuestionId: string;
|
|
172
|
+
};
|
|
173
|
+
answerValue: string;
|
|
174
|
+
mechanizationId: string;
|
|
175
|
+
}[];
|
|
176
|
+
};
|
|
177
|
+
type SpeedChangesChartDTO = {
|
|
178
|
+
speed: number;
|
|
179
|
+
date: string;
|
|
180
|
+
};
|
|
181
|
+
}
|
|
15
182
|
}
|
|
16
183
|
|
|
17
184
|
type ServiceType = "EXPERIMENT" | "VISIT" | "CHILLING_REQUIREMENT" | "CULTIVAR_RECOMMENDATION" | "FIRST_SAFFRON_IRRIGATION_DATE_RECOMMENDATION" | "HARVEST_DATE_RECOMMENDATION" | "QUESTIONNAIRE" | "SOWING_DATE_RECOMMENDATIONS" | "WEATHER_STATION" | "YIELD_GAP";
|
|
@@ -21,6 +188,14 @@ type MechanizationType = "MOTORIZED" | "NON_MOTORIZED";
|
|
|
21
188
|
type MechanizationSeasonProcessType = "GROWING" | "HARVESTING" | "PLANTING" | "TRANSPORTATION";
|
|
22
189
|
type MechanizationMachineUsageType = "BALER" | "CRUSHING" | "CRUST_BREAKER" | "FERTILIZER_SPREADER" | "FORAGE_COLLECTOR" | "FURROWER" | "GRASS_CUTTER" | "GRINDING" | "HARVESTING" | "LEVELING" | "LOADER" | "MULTI_PURPOSE" | "SEEDER" | "SPRAYER" | "TILLAGE" | "TRANSPORTATION" | "WEEDER";
|
|
23
190
|
|
|
191
|
+
type ServerResponse<T> = {
|
|
192
|
+
message: string;
|
|
193
|
+
code: string;
|
|
194
|
+
data: T;
|
|
195
|
+
};
|
|
196
|
+
type BaseResponse<T> = {
|
|
197
|
+
result: ServerResponse<T>;
|
|
198
|
+
};
|
|
24
199
|
type Status = {
|
|
25
200
|
id: string;
|
|
26
201
|
label: string;
|
|
@@ -41,6 +216,15 @@ type MechanizationMachineUsageKind = {
|
|
|
41
216
|
label: string;
|
|
42
217
|
name: MechanizationMachineUsageType;
|
|
43
218
|
};
|
|
219
|
+
type MechanizationListData = {
|
|
220
|
+
meta: Record<string, unknown>;
|
|
221
|
+
totalItems: number;
|
|
222
|
+
mechanizations: ServerResponseTypes.Dashboard.MechanizationDTO[];
|
|
223
|
+
};
|
|
224
|
+
type MotorizedMechanizationSensorsData = {
|
|
225
|
+
meta: Record<string, unknown>;
|
|
226
|
+
motorizedMechanizationSensors: ServerResponseTypes.Dashboard.MotorizedMechanizationSensorsDTO;
|
|
227
|
+
};
|
|
44
228
|
|
|
45
229
|
type MechanizationVarietyModel = {
|
|
46
230
|
id: Identifiers.MechanizationVarietyId;
|
|
@@ -49,7 +233,6 @@ type MechanizationVarietyModel = {
|
|
|
49
233
|
kind: VarietyKind;
|
|
50
234
|
seasonProcessIds: string[];
|
|
51
235
|
machineUsageIds: string[];
|
|
52
|
-
seasonsProcess: MechanizationSeasonProcessKind[];
|
|
53
236
|
};
|
|
54
237
|
type MechanizationVarietyVariables = {
|
|
55
238
|
kindName: MechanizationType;
|
|
@@ -66,13 +249,43 @@ type MechanizationModel = {
|
|
|
66
249
|
variety: MechanizationVarietyModel;
|
|
67
250
|
};
|
|
68
251
|
type MechanizationVariables = {
|
|
252
|
+
farmerId: string;
|
|
69
253
|
kindName: MechanizationType;
|
|
70
254
|
};
|
|
71
|
-
type
|
|
72
|
-
id:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
255
|
+
type MotorizedMechanizationSensorsModel = {
|
|
256
|
+
id: string;
|
|
257
|
+
speed: number;
|
|
258
|
+
heading: string;
|
|
259
|
+
latitude: number;
|
|
260
|
+
longitude: number;
|
|
261
|
+
fuelLevel: number;
|
|
262
|
+
engineRpm: number;
|
|
263
|
+
deviceCode: string;
|
|
264
|
+
stateEngine: boolean;
|
|
265
|
+
engineOilPressure: boolean;
|
|
266
|
+
engineWaterTemperature: string;
|
|
267
|
+
batteryChargePercentage: string;
|
|
268
|
+
mechanizationId: string;
|
|
269
|
+
};
|
|
270
|
+
type MotorizedMechanizationSensorsVariables = {
|
|
271
|
+
farmerId: string;
|
|
272
|
+
mechanizationId: string;
|
|
273
|
+
};
|
|
274
|
+
type SubmitTrackingDeviceModel = {
|
|
275
|
+
deviceCode: string;
|
|
276
|
+
};
|
|
277
|
+
type SubmitTrackingDeviceVariables = {
|
|
278
|
+
farmerId: Identifiers.FarmerId;
|
|
279
|
+
mechanizationId: Identifiers.MechanizationId;
|
|
280
|
+
deviceCode: string;
|
|
281
|
+
};
|
|
282
|
+
type SpeedChangesChartModel = {
|
|
283
|
+
speed: number;
|
|
284
|
+
date: string;
|
|
285
|
+
};
|
|
286
|
+
type SpeedChangesChartVariables = {
|
|
287
|
+
farmerId: Identifiers.FarmerId;
|
|
288
|
+
mechanizationId: Identifiers.MechanizationId;
|
|
76
289
|
};
|
|
77
290
|
|
|
78
291
|
type ClientConfig = {
|
|
@@ -84,10 +297,12 @@ declare const createSDK: (config: ClientConfig, middlewares?: Parameters<typeof
|
|
|
84
297
|
dashboardServices: {
|
|
85
298
|
mechanization: {
|
|
86
299
|
getMechanizationVarieties: ({ kindName, }: MechanizationVarietyVariables) => Promise<_mobily_ts_belt.Ok<MechanizationVarietyModel[]> | _mobily_ts_belt.Error<Error>>;
|
|
87
|
-
|
|
88
|
-
|
|
300
|
+
getSpeedChangesChartData: ({ farmerId, mechanizationId, }: SpeedChangesChartVariables) => Promise<_mobily_ts_belt.Ok<SpeedChangesChartModel[]> | undefined>;
|
|
301
|
+
getMechanizations: ({ kindName, farmerId }: MechanizationVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationModel[]>>;
|
|
302
|
+
getMotorizedMechanizationSensors: ({ farmerId, mechanizationId, }: MotorizedMechanizationSensorsVariables) => Promise<_mobily_ts_belt.Ok<MotorizedMechanizationSensorsModel> | undefined>;
|
|
303
|
+
SubmitTrackingDeviceCode: ({ farmerId, mechanizationId, deviceCode, }: SubmitTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<SubmitTrackingDeviceModel>>;
|
|
89
304
|
};
|
|
90
305
|
};
|
|
91
306
|
};
|
|
92
307
|
|
|
93
|
-
export { type MechanizationMachineUsageKind, type MechanizationMachineUsageType, type MechanizationModel, type MechanizationSeasonProcessKind, type MechanizationSeasonProcessType, type MechanizationType, type MechanizationVariables, type MechanizationVarietyModel, type MechanizationVarietyVariables, type
|
|
308
|
+
export { type BaseResponse, type MechanizationListData, type MechanizationMachineUsageKind, type MechanizationMachineUsageType, type MechanizationModel, type MechanizationSeasonProcessKind, type MechanizationSeasonProcessType, type MechanizationType, type MechanizationVariables, type MechanizationVarietyModel, type MechanizationVarietyVariables, type MotorizedMechanizationSensorsData, type MotorizedMechanizationSensorsModel, type MotorizedMechanizationSensorsVariables, type ServerResponse, type ServiceType, type SpeedChangesChartModel, type SpeedChangesChartVariables, type Status, type StatusType, type SubmitTrackingDeviceModel, type SubmitTrackingDeviceVariables, type TaskType, type VarietyKind, createSDK };
|
package/dist/index.mjs
CHANGED
|
@@ -48,10 +48,14 @@ var mappers = {
|
|
|
48
48
|
iconURL: response.iconURL,
|
|
49
49
|
kind: response.kind,
|
|
50
50
|
seasonProcessIds: response.seasonProcessIds,
|
|
51
|
-
machineUsageIds: response.machineUsageIds
|
|
52
|
-
seasonsProcess: response.seasonsProcess
|
|
51
|
+
machineUsageIds: response.machineUsageIds
|
|
53
52
|
}),
|
|
54
53
|
getMechanizationVarietyList: (response) => response.map(mappers.getMechanizationVariety),
|
|
54
|
+
getSpeedChangesChart: (response) => ({
|
|
55
|
+
speed: response.speed,
|
|
56
|
+
date: response.date
|
|
57
|
+
}),
|
|
58
|
+
getSpeedChangesChartPointsList: (response) => response.map(mappers.getSpeedChangesChart),
|
|
55
59
|
getMechanization: (response) => ({
|
|
56
60
|
id: response.id,
|
|
57
61
|
commonName: response.commonName,
|
|
@@ -64,13 +68,24 @@ var mappers = {
|
|
|
64
68
|
variety: mappers.getMechanizationVariety(response.variety)
|
|
65
69
|
}),
|
|
66
70
|
getMechanizationsList: (response) => response.map(mappers.getMechanization),
|
|
67
|
-
|
|
71
|
+
getMotorizedMechanizationSensors: (response) => ({
|
|
68
72
|
id: response.id,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
speed: response.speed,
|
|
74
|
+
heading: response.heading,
|
|
75
|
+
latitude: response.latitude,
|
|
76
|
+
longitude: response.longitude,
|
|
77
|
+
fuelLevel: response.fuelLevel,
|
|
78
|
+
engineRpm: response.engineRpm,
|
|
79
|
+
deviceCode: response.deviceCode,
|
|
80
|
+
stateEngine: response.stateEngine,
|
|
81
|
+
engineOilPressure: response.engineOilPressure,
|
|
82
|
+
engineWaterTemperature: response.engineWaterTemperature,
|
|
83
|
+
batteryChargePercentage: response.batteryChargePercentage,
|
|
84
|
+
mechanizationId: response.mechanizationId
|
|
72
85
|
}),
|
|
73
|
-
|
|
86
|
+
SubmitTrackingDeviceData: (response) => ({
|
|
87
|
+
deviceCode: response.deviceCode
|
|
88
|
+
})
|
|
74
89
|
};
|
|
75
90
|
|
|
76
91
|
// src/services/dashboard/mechanization/mechanization.service.ts
|
|
@@ -93,10 +108,26 @@ var createMechanizationServices = (client) => ({
|
|
|
93
108
|
return R.Error(err);
|
|
94
109
|
}
|
|
95
110
|
},
|
|
96
|
-
|
|
111
|
+
getSpeedChangesChartData: async ({
|
|
112
|
+
farmerId,
|
|
113
|
+
mechanizationId
|
|
114
|
+
}) => {
|
|
115
|
+
try {
|
|
116
|
+
const { data } = await client.get(
|
|
117
|
+
`/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors/speed-changes`
|
|
118
|
+
);
|
|
119
|
+
return R.Ok(
|
|
120
|
+
mappers.getSpeedChangesChartPointsList(data.result.data.speedChanges)
|
|
121
|
+
);
|
|
122
|
+
} catch (error) {
|
|
123
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
124
|
+
console.error("SpeedChangesChartPointsList API Error:", err);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
getMechanizations: async ({ kindName, farmerId }) => {
|
|
97
128
|
try {
|
|
98
129
|
const { data } = await client.get(
|
|
99
|
-
`/farmers/
|
|
130
|
+
`/farmers/${farmerId}/mechanizations?kindName=${kindName}`
|
|
100
131
|
);
|
|
101
132
|
return R.Ok(
|
|
102
133
|
mappers.getMechanizationsList(data.result.data.mechanizations)
|
|
@@ -107,19 +138,36 @@ var createMechanizationServices = (client) => ({
|
|
|
107
138
|
return R.Error(err);
|
|
108
139
|
}
|
|
109
140
|
},
|
|
110
|
-
|
|
141
|
+
getMotorizedMechanizationSensors: async ({
|
|
142
|
+
farmerId,
|
|
143
|
+
mechanizationId
|
|
144
|
+
}) => {
|
|
111
145
|
try {
|
|
112
|
-
const { data } = await client.get(
|
|
113
|
-
"/statics/mechanizations-seasons-process-kinds"
|
|
114
|
-
);
|
|
146
|
+
const { data } = await client.get(`/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors`);
|
|
115
147
|
return R.Ok(
|
|
116
|
-
mappers.
|
|
117
|
-
data.result.data.
|
|
148
|
+
mappers.getMotorizedMechanizationSensors(
|
|
149
|
+
data.result.data.motorizedMechanizationSensors
|
|
118
150
|
)
|
|
119
151
|
);
|
|
120
152
|
} catch (error) {
|
|
121
153
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
122
|
-
console.error("
|
|
154
|
+
console.error("Mechanization API Error:", err);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
SubmitTrackingDeviceCode: async ({
|
|
158
|
+
farmerId,
|
|
159
|
+
mechanizationId,
|
|
160
|
+
deviceCode
|
|
161
|
+
}) => {
|
|
162
|
+
try {
|
|
163
|
+
const { data } = await client.put(
|
|
164
|
+
`/farmers/${farmerId}/mechanizations/${mechanizationId}/submit-device-code`,
|
|
165
|
+
{ deviceCode }
|
|
166
|
+
);
|
|
167
|
+
return R.Ok(mappers.SubmitTrackingDeviceData(data));
|
|
168
|
+
} catch (error) {
|
|
169
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
170
|
+
console.error("SubmitTrackingDevice API Error:", err);
|
|
123
171
|
return R.Error(err);
|
|
124
172
|
}
|
|
125
173
|
}
|