openrtb_native1/
data_asset_type.rs

1/// 7.4 Data Asset Types
2///
3/// Below is a list of common asset element types of native advertising at the time of writing this
4/// spec. This list is non-exhaustive and intended to be extended by the buyers and sellers as the
5/// format evolves.
6///
7/// An implementing exchange may not support all asset variants or introduce new ones unique to that
8/// system.
9#[derive(Debug, PartialEq, Eq, Clone, Copy)]
10pub enum DataAssetType {
11    /// Sponsored By message where response should contain the brand name of the sponsor.
12    /// required; text; -; Max 25 or longer
13    Sponsored,
14    /// Descriptive text associated with the product or service being advertised. Longer length of
15    /// text in response may be truncated or ellipsed by the exchange.
16    /// recommended; text; -; Max 25 or longer
17    Desc,
18    /// Rating of the product being offered to the user. For example an app’s rating in an app
19    /// store from 0-5.
20    /// optional; number formatted as string; -; 0-5 integer formatted as string
21    Rating,
22    /// Number of social ratings or “likes” of the product being offered to the user.
23    /// -; number formatted as string;
24    Likes,
25    /// Number downloads/installs of this product.
26    /// -; number formatted as string;
27    Downloads,
28    /// Price for product / app / in-app purchase. Value should include currency symbol in
29    /// localised format.
30    /// -; number formatted as string;
31    Price,
32    /// Sale price that can be used together with price to indicate a discounted price compared to
33    /// a regular price. Value should include currency symbol in localised format.
34    /// -; number formatted as string;
35    SalePrice,
36    /// Phone number.
37    /// -; formatted string
38    Phone,
39    /// Address.
40    /// -; text
41    Address,
42    /// Additional descriptive text associated text with the product or service being advertised.
43    /// -; text
44    Desc2,
45    /// Display URL for the text ad. To be used when sponsoring entity doesn’t own the content. IE
46    /// sponsored by BRAND on SITE (where SITE is transmitted in this field).
47    /// -; text
48    DisplayUrl,
49    /// CTA description - descriptive text describing a ‘call to action’ button for the destination
50    /// URL.
51    /// optional; text; -; Max 15 or longer
52    CtaText,
53    /// Reserved for Exchange specific usage numbered above 500
54    /// -; unknown
55    ExchangeSpecific(i32),
56}
57
58crate::impl_enum_serde!(
59    #[exchange(ident = ExchangeSpecific, greater = 500)]
60    DataAssetType {
61        Sponsored = 1,
62        Desc = 2,
63        Rating = 3,
64        Likes = 4,
65        Downloads = 5,
66        Price = 6,
67        SalePrice = 7,
68        Phone = 8,
69        Address = 9,
70        Desc2 = 10,
71        DisplayUrl = 11,
72        CtaText = 12,
73    }
74);
75
76#[cfg(test)]
77mod test {
78    use super::*;
79
80    #[test]
81    fn json() -> serde_json::Result<()> {
82        assert!(serde_json::from_str::<DataAssetType>("0").is_err());
83        assert!(serde_json::from_str::<DataAssetType>("500").is_err());
84
85        let json = "[1,2,501]";
86        let e1: Vec<DataAssetType> = serde_json::from_str(json)?;
87        assert_eq!(serde_json::to_string(&e1)?, json);
88        assert_eq!(
89            e1,
90            vec![
91                DataAssetType::Sponsored,
92                DataAssetType::Desc,
93                DataAssetType::ExchangeSpecific(501),
94            ]
95        );
96
97        Ok(())
98    }
99}