1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug)]
pub struct RefreshToken {
    pub access_token: String,
    pub expires_in: u64,
    pub token_type: String,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct AuthorizationCode {
    pub access_token: String,
    pub expires_in: u64,
    pub refresh_token: String,
    pub token_type: String,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct DeviceRegistrationRequest {
    pub device_id: String,
    pub app_id: String,
    pub app_name: String,
    pub app_version: String,
    pub device_name: String,
    pub manufacturer: String,
    pub model: String,
    pub os_name: String,
    pub os_version: String,
    pub supports_encryption: bool,
    pub app_data: AppData,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct AppData {}

#[derive(Serialize, Deserialize, Debug)]
pub struct DeviceRegistrationResponse {
    pub cloudhook_url: Option<String>,
    pub remote_ui_url: Option<String>,
    pub secret: Option<String>,
    pub webhook_id: String,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct SensorRegistrationRequest {
    pub r#type: String,
    pub data: SensorRegistrationData,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct SensorRegistrationData {
    pub device_class: Option<String>,
    pub icon: String,
    pub name: String,
    pub state: String,
    pub r#type: String,
    pub unique_id: String,
    pub unit_of_measurement: String,
    pub attributes: std::collections::HashMap<String, String>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct SensorUpdateRequest {
    pub r#type: String,
    pub data: SensorUpdateData,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct SensorUpdateData {
    pub icon: String,
    pub state: String,
    pub r#type: String,
    pub unique_id: String,
    pub attributes: std::collections::HashMap<String, String>,
}