openrtb_native1/response/response.rs
1/// 5.1 Native Markup Response Object
2///
3/// The native object is the top level JSON object which identifies a native response. The native
4/// object has following attributes:
5#[derive(serde::Serialize, serde::Deserialize, Default, Debug, PartialEq, Clone)]
6pub struct Response {
7 /// recommended; string; 1.2
8 /// Version of the Native Markup version in use.
9 #[serde(default)]
10 pub ver: crate::Version,
11
12 /// recommended; array of object; -
13 /// List of native ad’s assets. Required if no assetsurl. Recommended as fallback even if
14 /// assetsurl is provided.
15 #[serde(default, skip_serializing_if = "Option::is_none")]
16 pub assets: Option<Vec<crate::response::Asset>>,
17
18 /// optional; string; -
19 /// URL of an alternate source for the assets object. The expected response is a JSON object
20 /// mirroring the assets object in the bid response, subject to certain requirements as
21 /// specified in the individual objects. Where present, overrides the asset object in the
22 /// response.
23 #[serde(default, skip_serializing_if = "Option::is_none")]
24 pub assetsurl: Option<String>,
25
26 /// optional; string; -
27 /// URL where a dynamic creative specification may be found for populating this ad, per the
28 /// Dynamic Content Ads Specification. Note this is a beta option as the interpretation of the
29 /// Dynamic Content Ads Specification and how to assign those elements into a native ad is
30 /// outside the scope of this spec and must be agreed offline between the parties or as may be
31 /// specified in a future revision of the Dynamic Content Ads spec. Where present, overrides
32 /// the asset object in the response.
33 #[serde(default, skip_serializing_if = "Option::is_none")]
34 pub dcourl: Option<String>,
35
36 /// required; object; -
37 /// Destination Link. This is default link object for the ad. Individual assets can also have a
38 /// link object which applies if the asset is activated(clicked). If the asset doesn’t have a
39 /// link object, the parent link object applies. See LinkObject Definition.
40 pub link: crate::response::Link,
41
42 /// optional; array of string; -
43 /// Array of impression tracking URLs, expected to return a 1x1 image or 204 response -
44 /// typically only passed when using 3rd party trackers. To be deprecated - replaced with
45 /// eventtrackers.
46 #[serde(default, skip_serializing_if = "Option::is_none")]
47 #[deprecated = "Please use eventtrackers field instead."]
48 pub imptrackers: Option<Vec<String>>,
49
50 /// optional; string; -
51 /// Optional JavaScript impression tracker. This is a valid HTML, Javascript is already wrapped
52 /// in <script> tags. It should be executed at impression time where it can be supported. To be
53 /// deprecated - replaced with eventtrackers.
54 #[serde(default, skip_serializing_if = "Option::is_none")]
55 #[deprecated = "Please use eventtrackers field instead."]
56 pub jstracker: Option<String>,
57
58 /// optional; Array of object; -
59 /// Array of tracking objects to run with the ad, in response to the declared supported methods
60 /// in the request. Replaces imptrackers and jstracker, to be deprecated.
61 #[serde(default, skip_serializing_if = "Option::is_none")]
62 pub eventtrackers: Option<Vec<crate::response::EventTracker>>,
63
64 /// optional; string; -
65 /// If support was indicated in the request, URL of a page informing the user about the buyer’s
66 /// targeting activity.
67 #[serde(default, skip_serializing_if = "Option::is_none")]
68 pub privacy: Option<String>,
69
70 /// optional; object; -
71 /// This object is a placeholder that may contain custom JSON agreed to by the parties to
72 /// support flexibility beyond the standard defined in this specification.
73 #[serde(default, skip_serializing_if = "Option::is_none")]
74 pub ext: Option<serde_json::Map<String, serde_json::Value>>,
75}
76
77#[cfg(test)]
78mod test {
79 use super::*;
80
81 #[test]
82 fn json() -> serde_json::Result<()> {
83 let json = r#"{"ver":"1.2","link":{"url":""}}"#;
84 let o1 = Response::default();
85 assert_eq!(serde_json::to_string(&o1)?, json);
86 assert_eq!(o1, serde_json::from_str::<Response>(json)?);
87
88 Ok(())
89 }
90}