1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
/// 5.8 Event Tracker Response Object /// /// The event trackers response is an array of objects and specifies the types of events the bidder /// wishes to track and the URLs/information to track them. Bidder must only respond with methods /// indicated as available in the request. Note that most javascript trackers expect to be loaded at /// impression time, so it’s not generally recommended for the buyer to respond with javascript /// trackers on other events, but the appropriateness of this is up to each buyer. #[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Clone)] pub struct EventTracker<'a> { /// required; integer; - /// Type of event to track. See Event Types table. pub event: crate::EventType, /// required; integer; - /// Type of tracking requested. See Event Tracking Methods table. pub method: crate::EventTrackingMethod, /// optional; text; - /// The URL of the image or js. Required for image or js, optional for custom. #[serde(borrow, default, skip_serializing_if = "Option::is_none")] pub url: Option<std::borrow::Cow<'a, str>>, /// optional; object containing key:value pairs; - /// To be agreed individually with the exchange, an array of key:value objects for custom /// tracking, for example the account number of the DSP with a tracking company. IE /// `{“accountnumber”:”123”}`. #[serde(borrow, default, skip_serializing_if = "Option::is_none")] pub customdata: Option<json_ext::Object<'a>>, /// optional; object; - /// This object is a placeholder that may contain custom JSON agreed to by the parties to /// support flexibility beyond the standard defined in this specification. #[serde(borrow, default, skip_serializing_if = "Option::is_none")] pub ext: Option<json_ext::Object<'a>>, } #[cfg(test)] mod test { use super::*; #[test] fn json() -> serde_json::Result<()> { let json = r#"{"event":1,"method":1}"#; let o1 = EventTracker { event: crate::EventType::Impression, method: crate::EventTrackingMethod::Img, url: None, customdata: None, ext: None, }; assert_eq!(serde_json::to_string(&o1)?, json); assert_eq!(o1, serde_json::from_str::<EventTracker>(json)?); Ok(()) } }