@agroyaar/sdk 1.1.4-2 → 1.1.5

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,33 @@ 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,
116
+ mechanization: mappers.getMechanization(response.mechanization)
92
117
  })
93
118
  };
94
119
 
@@ -112,20 +137,36 @@ var createMechanizationServices = (client) => ({
112
137
  return import_ts_belt.R.Error(err);
113
138
  }
114
139
  },
115
- SubmitTrackingDeviceResData: async ({
140
+ getMechanizations: async ({ farmerId, kindName }) => {
141
+ try {
142
+ const { data } = await client.get(
143
+ `/farmers/${farmerId}/mechanizations?kindName=${kindName}`
144
+ );
145
+ return import_ts_belt.R.Ok(
146
+ mappers.getMechanizationsList(data.result.data.mechanizations)
147
+ );
148
+ } catch (error) {
149
+ const err = error instanceof Error ? error : new Error(String(error));
150
+ console.error("Mechanization API Error:", err);
151
+ return import_ts_belt.R.Error(err);
152
+ }
153
+ },
154
+ getMotorizedMechanizationSensors: async ({
116
155
  farmerId,
117
- mechanizationId,
118
- deviceCode
156
+ mechanizationId
119
157
  }) => {
120
158
  try {
121
- const { data } = await client.put(
122
- `/farmers/${farmerId}/mechanizations/${mechanizationId}/submit-device-code`,
123
- { deviceCode }
159
+ const { data } = await client.get(
160
+ `/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors`
161
+ );
162
+ return import_ts_belt.R.Ok(
163
+ mappers.getMotorizedMechanizationSensors(
164
+ data.result.data.mechanizations
165
+ )
124
166
  );
125
- return import_ts_belt.R.Ok(mappers.SubmitTrackingDeviceData(data));
126
167
  } catch (error) {
127
168
  const err = error instanceof Error ? error : new Error(String(error));
128
- console.error("SubmitTrackingDevice API Error:", err);
169
+ console.error("Mechanization API Error:", err);
129
170
  return import_ts_belt.R.Error(err);
130
171
  }
131
172
  }
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,28 @@ 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;
85
+ mechanization: MechanizationModel;
71
86
  };
72
- type SubmitTrackingDeviceVariables = {
87
+ type MotorizedMechanizationSensorsVariables = {
73
88
  farmerId: string;
74
89
  mechanizationId: string;
75
- deviceCode: string;
76
90
  };
77
91
 
78
92
  type ClientConfig = {
@@ -84,9 +98,10 @@ declare const createSDK: (config: ClientConfig, middlewares?: Parameters<typeof
84
98
  dashboardServices: {
85
99
  mechanization: {
86
100
  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>>;
101
+ getMechanizations: ({ farmerId, kindName }: MechanizationVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MechanizationModel[]>>;
102
+ getMotorizedMechanizationSensors: ({ farmerId, mechanizationId, }: MotorizedMechanizationSensorsVariables) => Promise<_mobily_ts_belt.Error<Error> | _mobily_ts_belt.Ok<MotorizedMechanizationSensorsModel>>;
88
103
  };
89
104
  };
90
105
  };
91
106
 
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 };
107
+ 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,33 @@ 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,
80
+ mechanization: mappers.getMechanization(response.mechanization)
56
81
  })
57
82
  };
58
83
 
@@ -76,20 +101,36 @@ var createMechanizationServices = (client) => ({
76
101
  return R.Error(err);
77
102
  }
78
103
  },
79
- SubmitTrackingDeviceResData: async ({
104
+ getMechanizations: async ({ farmerId, kindName }) => {
105
+ try {
106
+ const { data } = await client.get(
107
+ `/farmers/${farmerId}/mechanizations?kindName=${kindName}`
108
+ );
109
+ return R.Ok(
110
+ mappers.getMechanizationsList(data.result.data.mechanizations)
111
+ );
112
+ } catch (error) {
113
+ const err = error instanceof Error ? error : new Error(String(error));
114
+ console.error("Mechanization API Error:", err);
115
+ return R.Error(err);
116
+ }
117
+ },
118
+ getMotorizedMechanizationSensors: async ({
80
119
  farmerId,
81
- mechanizationId,
82
- deviceCode
120
+ mechanizationId
83
121
  }) => {
84
122
  try {
85
- const { data } = await client.put(
86
- `/farmers/${farmerId}/mechanizations/${mechanizationId}/submit-device-code`,
87
- { deviceCode }
123
+ const { data } = await client.get(
124
+ `/farmers/${farmerId}/mechanizations/${mechanizationId}/sensors`
125
+ );
126
+ return R.Ok(
127
+ mappers.getMotorizedMechanizationSensors(
128
+ data.result.data.mechanizations
129
+ )
88
130
  );
89
- return R.Ok(mappers.SubmitTrackingDeviceData(data));
90
131
  } catch (error) {
91
132
  const err = error instanceof Error ? error : new Error(String(error));
92
- console.error("SubmitTrackingDevice API Error:", err);
133
+ console.error("Mechanization API Error:", err);
93
134
  return R.Error(err);
94
135
  }
95
136
  }
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.5",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",