@agroyaar/sdk 1.1.4-2 → 1.1.6-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 CHANGED
@@ -87,8 +87,32 @@ var mappers = {
87
87
  machineUsageIds: response.machineUsageIds
88
88
  }),
89
89
  getMechanizationVarietyList: (response) => response.map(mappers.getMechanizationVariety),
90
- SubmitTrackingDeviceData: (response) => ({
91
- deviceCode: response.deviceCode
90
+ getMechanization: (response) => ({
91
+ id: response.id,
92
+ commonName: response.commonName,
93
+ model: response.model,
94
+ avatarURL: response.avatarURL,
95
+ manufactureYear: response.manufactureYear,
96
+ code: response.code,
97
+ kind: response.kind,
98
+ kindName: response.kindName,
99
+ variety: mappers.getMechanizationVariety(response.variety)
100
+ }),
101
+ getMechanizationsList: (response) => response.map(mappers.getMechanization),
102
+ getMotorizedMechanizationSensors: (response) => ({
103
+ id: response.id,
104
+ speed: response.speed,
105
+ heading: response.heading,
106
+ latitude: response.latitude,
107
+ longitude: response.longitude,
108
+ fuelLevel: response.fuelLevel,
109
+ engineRpm: response.engineRpm,
110
+ deviceCode: response.deviceCode,
111
+ stateEngine: response.stateEngine,
112
+ engineOilPressure: response.engineOilPressure,
113
+ engineWaterTemperature: response.engineWaterTemperature,
114
+ batteryChargePercentage: response.batteryChargePercentage,
115
+ mechanizationId: response.mechanizationId
92
116
  })
93
117
  };
94
118
 
@@ -112,20 +136,36 @@ var createMechanizationServices = (client) => ({
112
136
  return import_ts_belt.R.Error(err);
113
137
  }
114
138
  },
115
- SubmitTrackingDeviceResData: async ({
139
+ getMechanizations: async ({ farmerId, kindName }) => {
140
+ try {
141
+ const { data } = await client.get(
142
+ `/farmers/${farmerId}/mechanizations?kindName=${kindName}`
143
+ );
144
+ return import_ts_belt.R.Ok(
145
+ mappers.getMechanizationsList(data.result.data.mechanizations)
146
+ );
147
+ } catch (error) {
148
+ const err = error instanceof Error ? error : new Error(String(error));
149
+ console.error("Mechanization API Error:", err);
150
+ return import_ts_belt.R.Error(err);
151
+ }
152
+ },
153
+ getMotorizedMechanizationSensors: async ({
116
154
  farmerId,
117
- mechanizationId,
118
- deviceCode
155
+ mechanizationId
119
156
  }) => {
120
157
  try {
121
- const { data } = await client.put(
122
- `/farmers/${farmerId}/mechanizations/${mechanizationId}/submit-device-code`,
123
- { deviceCode }
158
+ const { data } = await client.get(
159
+ `/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors`
160
+ );
161
+ return import_ts_belt.R.Ok(
162
+ mappers.getMotorizedMechanizationSensors(
163
+ data.result.data.mechanizations
164
+ )
124
165
  );
125
- return import_ts_belt.R.Ok(mappers.SubmitTrackingDeviceData(data));
126
166
  } catch (error) {
127
167
  const err = error instanceof Error ? error : new Error(String(error));
128
- console.error("SubmitTrackingDevice API Error:", err);
168
+ console.error("Mechanization API Error:", err);
129
169
  return import_ts_belt.R.Error(err);
130
170
  }
131
171
  }
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ type Branded<T, B> = Brand<B> & T;
11
11
  declare namespace Identifiers {
12
12
  type MechanizationVarietyId = Branded<string, "mechanizationVarietyId-id">;
13
13
  type MechanizationId = Branded<string, "mechanizationId-id">;
14
+ type MotorizedMechanizationSensorsId = Branded<string, "motorized-mechanization-sensorsId-id">;
14
15
  }
15
16
 
16
17
  type ServiceType = "EXPERIMENT" | "VISIT" | "CHILLING_REQUIREMENT" | "CULTIVAR_RECOMMENDATION" | "FIRST_SAFFRON_IRRIGATION_DATE_RECOMMENDATION" | "HARVEST_DATE_RECOMMENDATION" | "QUESTIONNAIRE" | "SOWING_DATE_RECOMMENDATIONS" | "WEATHER_STATION" | "YIELD_GAP";
@@ -64,15 +65,27 @@ type MechanizationModel = {
64
65
  variety: MechanizationVarietyModel;
65
66
  };
66
67
  type MechanizationVariables = {
68
+ farmerId: string;
67
69
  kindName: MechanizationType;
68
70
  };
69
- type SubmitTrackingDeviceModel = {
71
+ type MotorizedMechanizationSensorsModel = {
72
+ id: string;
73
+ speed: number;
74
+ heading: string;
75
+ latitude: number;
76
+ longitude: number;
77
+ fuelLevel: number;
78
+ engineRpm: number;
70
79
  deviceCode: string;
80
+ stateEngine: boolean;
81
+ engineOilPressure: boolean;
82
+ engineWaterTemperature: string;
83
+ batteryChargePercentage: string;
84
+ mechanizationId: string;
71
85
  };
72
- type SubmitTrackingDeviceVariables = {
86
+ type MotorizedMechanizationSensorsVariables = {
73
87
  farmerId: string;
74
88
  mechanizationId: string;
75
- deviceCode: string;
76
89
  };
77
90
 
78
91
  type ClientConfig = {
@@ -84,9 +97,10 @@ declare const createSDK: (config: ClientConfig, middlewares?: Parameters<typeof
84
97
  dashboardServices: {
85
98
  mechanization: {
86
99
  getMechanizationVarieties: ({ kindName, }: MechanizationVarietyVariables) => Promise<_mobily_ts_belt.Ok<MechanizationVarietyModel[]> | _mobily_ts_belt.Error<Error>>;
87
- SubmitTrackingDeviceResData: ({ farmerId, mechanizationId, deviceCode, }: SubmitTrackingDeviceVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<SubmitTrackingDeviceModel>>;
100
+ getMechanizations: ({ farmerId, kindName }: MechanizationVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationModel[]>>;
101
+ getMotorizedMechanizationSensors: ({ farmerId, mechanizationId, }: MotorizedMechanizationSensorsVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MotorizedMechanizationSensorsModel>>;
88
102
  };
89
103
  };
90
104
  };
91
105
 
92
- export { type MechanizationMachineUsageKind, type MechanizationMachineUsageType, type MechanizationModel, type MechanizationSeasonProcessKind, type MechanizationSeasonProcessType, type MechanizationType, type MechanizationVariables, type MechanizationVarietyModel, type MechanizationVarietyVariables, type ServiceType, type Status, type StatusType, type SubmitTrackingDeviceModel, type SubmitTrackingDeviceVariables, type TaskType, type VarietyKind, createSDK };
106
+ export { type MechanizationMachineUsageKind, type MechanizationMachineUsageType, type MechanizationModel, type MechanizationSeasonProcessKind, type MechanizationSeasonProcessType, type MechanizationType, type MechanizationVariables, type MechanizationVarietyModel, type MechanizationVarietyVariables, type MotorizedMechanizationSensorsModel, type MotorizedMechanizationSensorsVariables, type ServiceType, type Status, type StatusType, type TaskType, type VarietyKind, createSDK };
package/dist/index.mjs CHANGED
@@ -51,8 +51,32 @@ var mappers = {
51
51
  machineUsageIds: response.machineUsageIds
52
52
  }),
53
53
  getMechanizationVarietyList: (response) => response.map(mappers.getMechanizationVariety),
54
- SubmitTrackingDeviceData: (response) => ({
55
- deviceCode: response.deviceCode
54
+ getMechanization: (response) => ({
55
+ id: response.id,
56
+ commonName: response.commonName,
57
+ model: response.model,
58
+ avatarURL: response.avatarURL,
59
+ manufactureYear: response.manufactureYear,
60
+ code: response.code,
61
+ kind: response.kind,
62
+ kindName: response.kindName,
63
+ variety: mappers.getMechanizationVariety(response.variety)
64
+ }),
65
+ getMechanizationsList: (response) => response.map(mappers.getMechanization),
66
+ getMotorizedMechanizationSensors: (response) => ({
67
+ id: response.id,
68
+ speed: response.speed,
69
+ heading: response.heading,
70
+ latitude: response.latitude,
71
+ longitude: response.longitude,
72
+ fuelLevel: response.fuelLevel,
73
+ engineRpm: response.engineRpm,
74
+ deviceCode: response.deviceCode,
75
+ stateEngine: response.stateEngine,
76
+ engineOilPressure: response.engineOilPressure,
77
+ engineWaterTemperature: response.engineWaterTemperature,
78
+ batteryChargePercentage: response.batteryChargePercentage,
79
+ mechanizationId: response.mechanizationId
56
80
  })
57
81
  };
58
82
 
@@ -76,20 +100,36 @@ var createMechanizationServices = (client) => ({
76
100
  return R.Error(err);
77
101
  }
78
102
  },
79
- SubmitTrackingDeviceResData: async ({
103
+ getMechanizations: async ({ farmerId, kindName }) => {
104
+ try {
105
+ const { data } = await client.get(
106
+ `/farmers/${farmerId}/mechanizations?kindName=${kindName}`
107
+ );
108
+ return R.Ok(
109
+ mappers.getMechanizationsList(data.result.data.mechanizations)
110
+ );
111
+ } catch (error) {
112
+ const err = error instanceof Error ? error : new Error(String(error));
113
+ console.error("Mechanization API Error:", err);
114
+ return R.Error(err);
115
+ }
116
+ },
117
+ getMotorizedMechanizationSensors: async ({
80
118
  farmerId,
81
- mechanizationId,
82
- deviceCode
119
+ mechanizationId
83
120
  }) => {
84
121
  try {
85
- const { data } = await client.put(
86
- `/farmers/${farmerId}/mechanizations/${mechanizationId}/submit-device-code`,
87
- { deviceCode }
122
+ const { data } = await client.get(
123
+ `/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors`
124
+ );
125
+ return R.Ok(
126
+ mappers.getMotorizedMechanizationSensors(
127
+ data.result.data.mechanizations
128
+ )
88
129
  );
89
- return R.Ok(mappers.SubmitTrackingDeviceData(data));
90
130
  } catch (error) {
91
131
  const err = error instanceof Error ? error : new Error(String(error));
92
- console.error("SubmitTrackingDevice API Error:", err);
132
+ console.error("Mechanization API Error:", err);
93
133
  return R.Error(err);
94
134
  }
95
135
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agroyaar/sdk",
3
- "version": "1.1.4-2",
3
+ "version": "1.1.6-0",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",