Skip to content

Commit b8b7461

Browse files
authored
Merge pull request #118 from spaceapi-community/add-v15-support
v15: Add linked_spaces, country_code, hint and areas
2 parents bce8b14 + d08cde0 commit b8b7461

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/status.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ use crate::sensors::Sensors;
77

88
type Extensions = BTreeMap<String, Value>;
99

10+
#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq)]
11+
pub struct Area {
12+
#[serde(skip_serializing_if = "Option::is_none")]
13+
name: Option<String>,
14+
#[serde(skip_serializing_if = "Option::is_none")]
15+
description: Option<String>,
16+
square_meters: f64,
17+
}
18+
1019
#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq)]
1120
pub struct Location {
1221
#[serde(skip_serializing_if = "Option::is_none")]
@@ -15,6 +24,12 @@ pub struct Location {
1524
pub lon: f64,
1625
#[serde(skip_serializing_if = "Option::is_none")]
1726
pub timezone: Option<String>,
27+
#[serde(skip_serializing_if = "Option::is_none")]
28+
pub country_code: Option<String>,
29+
#[serde(skip_serializing_if = "Option::is_none")]
30+
pub hint: Option<String>,
31+
#[serde(skip_serializing_if = "Option::is_none")]
32+
pub areas: Option<Vec<Area>>,
1833
}
1934

2035
#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq, Eq)]
@@ -225,6 +240,12 @@ pub enum ApiVersion {
225240
V14,
226241
}
227242

243+
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
244+
pub struct LinkedSpace {
245+
endpoint: String,
246+
website: String,
247+
}
248+
228249
/// The main SpaceAPI status object.
229250
#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq)]
230251
pub struct Status {
@@ -260,6 +281,8 @@ pub struct Status {
260281
pub links: Option<Vec<Link>>,
261282
#[serde(skip_serializing_if = "Option::is_none")]
262283
pub membership_plans: Option<Vec<MembershipPlan>>,
284+
#[serde(skip_serializing_if = "Option::is_none")]
285+
pub linked_spaces: Option<Vec<LinkedSpace>>,
263286

264287
// SpaceAPI internal usage
265288
#[serde(skip_serializing_if = "Option::is_none")]
@@ -968,6 +991,15 @@ mod test {
968991
},
969992
r#"{"ustream":"http://www.ustream.tv/channel/hackspsps"}"#
970993
);
994+
995+
test_serialize!(
996+
area,
997+
Area {
998+
square_meters: 120.0,
999+
..Area::default()
1000+
},
1001+
r#"{"square_meters":120.0}"#
1002+
);
9711003
}
9721004

9731005
mod deserialize {

0 commit comments

Comments
 (0)