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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug)]
pub struct ResponseConnections {
    pub status: i32,
    pub data: Vec<Connection>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ConnectionGraphResponse {
    pub status: i32,
    pub data: ConnectionGraphData,
    pub ticket: Ticket,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct Connection {
    pub id: String,
    #[serde(rename = "patientId")]
    pub patient_id: String,
    pub country: String,
    pub status: i32,
    #[serde(rename = "firstName")]
    pub first_name: String,
    #[serde(rename = "lastName")]
    pub last_name: String,
    #[serde(rename = "targetLow")]
    pub target_low: i32,
    #[serde(rename = "targetHigh")]
    pub target_high: i32,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct Sensor {
    #[serde(rename = "deviceId")]
    pub device_id: String,
    pub sn: String,
    pub a: i64,
    pub w: i32,
    pub pt: i32,
    pub s: bool,
    pub lj: bool,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct Device {
    pub did: String,
    pub dtid: i32,
    pub v: String,
    pub ll: i32,
    pub hl: i32,
    #[serde(rename = "fixedLowAlarmValues")]
    pub fixed_low_alarm_values: FixedLowAlarmValues,
    pub alarms: bool,
    #[serde(rename = "fixedLowThreshold")]
    pub fixed_low_threshold: i32,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct FixedLowAlarmValues {
    pub mgdl: i32,
    pub mmoll: f32,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct Ticket {
    pub token: String,
    pub expires: u64,
    pub duration: u64,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ConnectionGraphData {
    pub connection: Connection,
    #[serde(rename = "activeSensors")]
    pub active_sensors: Vec<ActiveSensor>,
    #[serde(rename = "graphData")]
    pub graph_data: Vec<GraphData>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct GraphData {
    #[serde(rename = "FactoryTimestamp")]
    pub factory_timestamp: String,
    #[serde(rename = "Timestamp")]
    pub timestamp: String,
    #[serde(rename = "type")]
    pub _type: i32,
    #[serde(rename = "ValueInMgPerDl")]
    pub value_in_mg_per_dl: i32,
    #[serde(rename = "MeasurementColor")]
    pub measurement_color: i32,
    #[serde(rename = "GlucoseUnits")]
    pub glucose_units: i32,
    #[serde(rename = "Value")]
    pub value: i32,
    #[serde(rename = "isHigh")]
    pub is_high: bool,
    #[serde(rename = "isLow")]
    pub is_low: bool,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ActiveSensor {
    pub sensor: Sensor,
    pub device: Device,
}