|
| 1 | +use crate::{BigNum, TargetingTag, ValidatorId}; |
| 2 | +use chrono::serde::{ts_milliseconds, ts_milliseconds_option}; |
| 3 | +use chrono::{DateTime, Utc}; |
| 4 | +use serde::{Deserialize, Serialize}; |
| 5 | +use std::collections::HashMap; |
| 6 | + |
| 7 | +/// See [AdEx Protocol adSlot.md][protocol] & [adex-models AdSlot.js][adex-models] for more details. |
| 8 | +/// [protocol]: https://github.com/AdExNetwork/adex-protocol/blob/master/adSlot.md |
| 9 | +/// [adex-models]: https://github.com/AdExNetwork/adex-models/blob/master/src/models/AdSlot.js |
| 10 | +#[derive(Serialize, Deserialize, Debug, Clone)] |
| 11 | +#[serde(rename_all = "camelCase")] |
| 12 | +pub struct AdSlot { |
| 13 | + /// valid ipfs hash of spec props below |
| 14 | + pub ipfs: String, |
| 15 | + /// The type of the AdSlot |
| 16 | + /// currently, possible values are: |
| 17 | + /// > legacy_300x250, legacy_250x250, legacy_240x400, legacy_336x280, |
| 18 | + /// > legacy_180x150, legacy_300x100, legacy_720x300, legacy_468x60, |
| 19 | + /// > legacy_234x60, legacy_88x31, legacy_120x90, legacy_120x60, |
| 20 | + /// > legacy_120x240, legacy_125x125, legacy_728x90, legacy_160x600, |
| 21 | + /// > legacy_120x600, legacy_300x600 |
| 22 | + /// see IAB ad unit guidelines and iab_flex_{adUnitName} (see IAB's new ad portfolio and PDF) |
| 23 | + #[serde(rename = "type")] |
| 24 | + pub ad_type: String, |
| 25 | + /// A URL to the resource (usually PNG) |
| 26 | + /// * must use the ipfs:// protocol, to guarantee data immutability |
| 27 | + pub media_url: String, |
| 28 | + /// MIME type of the media. |
| 29 | + // Possible values at the moment are: |
| 30 | + /// * image/jpeg |
| 31 | + /// * image/png |
| 32 | + pub media_mime: String, |
| 33 | + /// Advertised URL |
| 34 | + pub target_url: String, |
| 35 | + /// Array of TargetingTag |
| 36 | + pub targeting: Vec<TargetingTag>, |
| 37 | + // HashMap<DepositAsset, BigNum> for the minimum payment accepted per impression |
| 38 | + #[serde(default)] |
| 39 | + pub min_per_impression: Option<HashMap<String, BigNum>>, |
| 40 | + /// Array of TargetingTag |
| 41 | + /// meant for discovery between publishers/advertisers |
| 42 | + #[serde(default)] |
| 43 | + pub tags: Vec<TargetingTag>, |
| 44 | + #[serde(default)] |
| 45 | + pub auto_tags: Vec<TargetingTag>, |
| 46 | + /// Valid ipfs hash for Ad Unit object. It will be used as fallback data (optional) |
| 47 | + pub fallback_unit: Option<String>, |
| 48 | + /// User address from the session |
| 49 | + pub owner: ValidatorId, |
| 50 | + /// UTC timestamp in milliseconds, used as nonce for escaping duplicated spec ipfs hashes |
| 51 | + #[serde(with = "ts_milliseconds")] |
| 52 | + pub created: DateTime<Utc>, |
| 53 | + /// the name of the unit used in platform UI |
| 54 | + pub title: Option<String>, |
| 55 | + /// arbitrary text used in platform UI |
| 56 | + pub description: Option<String>, |
| 57 | + #[serde(default)] |
| 58 | + pub webiste: Option<String>, |
| 59 | + /// user can change it - used for filtering in platform UI |
| 60 | + #[serde(default)] |
| 61 | + pub archived: bool, |
| 62 | + /// UTC timestamp in milliseconds, changed every time modifiable property is changed |
| 63 | + #[serde(default, with = "ts_milliseconds_option")] |
| 64 | + pub modified: Option<DateTime<Utc>>, |
| 65 | +} |
0 commit comments