1use std::fmt::Display;
2
3use serde_derive::Deserialize;
4
5use super::ApiResponse;
6
7#[derive(Deserialize, Debug)]
8pub struct Response {
9 #[serde(rename = "body")]
10 pub body: Body,
11
12 #[serde(rename = "message")]
13 pub message: String,
14
15 #[serde(rename = "statusCode")]
16 pub status_code: u32,
17}
18
19impl ApiResponse for Response {}
20
21impl Display for Response {
22 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23 let body = &self.body;
24 writeln!(f, "DeviceId: {}", body.device_id)?;
25 writeln!(f, "DeviceType: {}", body.device_type)?;
26 writeln!(f, "ElectricCurrent: {}", body.electric_current)?;
27 writeln!(f, "ElectricityOfDay: {}", body.electricity_of_day)?;
28 writeln!(f, "HubDeviceId: {}", body.hub_device_id)?;
29 writeln!(f, "Power: {}", body.power)?;
30 writeln!(f, "Voltage: {}", body.voltage)?;
31 writeln!(f, "Weight: {}", body.weight)
32 }
33}
34#[derive(Deserialize, Debug)]
35pub struct Body {
36 #[serde(rename = "deviceId")]
37 pub device_id: String,
38
39 #[serde(rename = "deviceType")]
40 pub device_type: String,
41
42 #[serde(rename = "electricCurrent")]
43 pub electric_current: i32,
44
45 #[serde(rename = "electricityOfDay")]
46 pub electricity_of_day: i32,
47
48 #[serde(rename = "hubDeviceId")]
49 pub hub_device_id: String,
50
51 #[serde(rename = "power")]
52 pub power: String,
53
54 #[serde(rename = "voltage")]
55 pub voltage: f32,
56
57 #[serde(rename = "weight")]
58 pub weight: i32,
59}