openrtb_native1/response/link.rs
1/// 5.7 Link Response Object
2///
3/// Used for ‘call to action’ assets, or other links from the Native ad. This Object should be
4/// associated to its peer object in the parent Asset Object or as the master link in the top level
5/// Native Ad response object. When that peer object is activated (clicked) the action should take
6/// the user to the location of the link.
7#[derive(serde::Serialize, serde::Deserialize, Default, Debug, PartialEq, Clone)]
8pub struct Link {
9 /// required; string; -
10 /// Landing URL of the clickable link.
11 pub url: String,
12
13 /// optional; array of string; -
14 /// List of third-party tracker URLs to be fired on click of the URL.
15 #[serde(default, skip_serializing_if = "Option::is_none")]
16 pub clicktrackers: Option<Vec<String>>,
17
18 /// optional; string(URL); -
19 /// Fallback URL for deeplink. To be used if the URL given in url is not supported by the
20 /// device.
21 #[serde(default, skip_serializing_if = "Option::is_none")]
22 pub fallback: Option<String>,
23
24 /// optional; object; -
25 /// This object is a placeholder that may contain custom JSON agreed to by the parties to
26 /// support flexibility beyond the standard defined in this specification.
27 #[serde(default, skip_serializing_if = "Option::is_none")]
28 pub ext: Option<serde_json::Map<String, serde_json::Value>>,
29}
30
31#[cfg(test)]
32mod test {
33 use super::*;
34
35 #[test]
36 fn json() -> serde_json::Result<()> {
37 let json = r#"{"url":""}"#;
38 let o1 = Link::default();
39 assert_eq!(serde_json::to_string(&o1)?, json);
40 assert_eq!(o1, serde_json::from_str::<Link>(json)?);
41
42 Ok(())
43 }
44}