Skip to content

Commit

Permalink
Bid request deserialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
k-bx committed Jun 27, 2020
1 parent c6b8e5f commit 59aa066
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/v2_5/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ pub struct Imp {
pub display_manager_ver: Option<String>,

#[serde(
default,
rename = "instl",
skip_serializing_if = "serde_utils::is_false",
serialize_with = "serde_utils::bool_to_u8",
deserialize_with = "serde_utils::u8_to_bool"
skip_serializing_if = "Option::is_none",
serialize_with = "serde_utils::mbool_to_u8",
deserialize_with = "serde_utils::u8_to_mbool"
)]
pub interstitial: bool,
pub interstitial: Option<bool>,

#[serde(rename = "tagid", skip_serializing_if = "Option::is_none")]
pub tag_id: Option<String>,
Expand All @@ -69,7 +70,7 @@ pub struct Imp {
// )]
// pub click_browser: Option<bool>,
#[serde(
rename = "bidfloorcur",
default,
skip_serializing_if = "Option::is_none",
serialize_with = "serde_utils::mbool_to_u8",
deserialize_with = "serde_utils::u8_to_mbool"
Expand Down Expand Up @@ -102,7 +103,7 @@ mod tests {
pmp: None,
display_manager: None,
display_manager_ver: None,
interstitial: false,
interstitial: None,
tag_id: None,
bid_floor: None,
bid_floor_cur: None,
Expand All @@ -115,4 +116,12 @@ mod tests {

assert_eq!(expected, serialized)
}

#[test]
fn check_simple() {
assert_eq!(
serde_json::from_str::<Imp>("{\"id\":\"7a5156a2-50f5-4dea-9eeb-a767f975d500\",\"banner\":{\"w\":300,\"h\":250},\"bidfloor\":0.1}").unwrap().id,
"7a5156a2-50f5-4dea-9eeb-a767f975d500",
)
}
}

0 comments on commit 59aa066

Please sign in to comment.