openrtb_native1/response/asset.rs
1/// 5.2 Asset Response Object
2///
3/// Corresponds to the Asset Object in the request. The main container object for each asset
4/// requested or supported by Exchange on behalf of the rendering client. Any object that is
5/// required is to be flagged as such. Only one of the {title,img,video,data} objects should be
6/// present in each object. All others should be null/absent. The id is to be unique within the
7/// AssetObject array so that the response can be aligned.
8#[derive(serde::Serialize, serde::Deserialize, Default, Debug, PartialEq, Clone)]
9pub struct Asset {
10 /// optional; int; -
11 /// Optional if assetsurl/dcourl is being used; required if embedded asset is being used.
12 #[serde(default, skip_serializing_if = "Option::is_none")]
13 pub id: Option<i32>,
14
15 /// optional; int; 0
16 /// Set to 1 if asset is required. (bidder requires it to be displayed).
17 #[serde(
18 default,
19 skip_serializing_if = "default_ext::DefaultExt::is_default",
20 with = "crate::serde::i32_as_bool"
21 )]
22 pub required: bool,
23
24 /// recommended; array of object; -
25 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
26 pub value: Option<crate::response::AssetValue>,
27
28 /// optional; object; -
29 /// Link object for call to actions. The link object applies if the asset item is activated
30 /// (clicked). If there is no link object on the asset, the parent link object on the bid
31 /// response applies.
32 #[serde(default, skip_serializing_if = "Option::is_none")]
33 pub link: Option<crate::response::Link>,
34
35 /// optional; object; -
36 /// This object is a placeholder that may contain custom JSON agreed to by the parties to
37 /// support flexibility beyond the standard defined in this specification.
38 #[serde(default, skip_serializing_if = "Option::is_none")]
39 pub ext: Option<serde_json::Map<String, serde_json::Value>>,
40}
41
42#[cfg(test)]
43mod test {
44 use super::*;
45
46 #[test]
47 fn json() -> serde_json::Result<()> {
48 let json = r#"{}"#;
49 let o1 = Asset::default();
50 assert_eq!(serde_json::to_string(&o1)?, json);
51 assert_eq!(o1, serde_json::from_str::<Asset>(json)?);
52
53 Ok(())
54 }
55}