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 57 58 59
use crate::{targeting::Rules, Address, UnifiedNum, ValidatorId, IPFS};
use chrono::{
serde::{ts_milliseconds, ts_milliseconds_option},
DateTime, Utc,
};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
/// See [AdEx Protocol adSlot.md][protocol] & [adex-models AdSlot.js][adex-models] for more details.
///
/// [protocol]: https://github.com/AdExNetwork/adex-protocol/blob/master/adSlot.md
/// [adex-models]: https://github.com/AdExNetwork/adex-models/blob/master/src/models/AdSlot.js
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct AdSlot {
/// valid ipfs hash of spec props below
pub ipfs: IPFS,
/// The type of the AdSlot
/// currently, possible values are:
/// > legacy_300x250, legacy_250x250, legacy_240x400, legacy_336x280,
/// > legacy_180x150, legacy_300x100, legacy_720x300, legacy_468x60,
/// > legacy_234x60, legacy_88x31, legacy_120x90, legacy_120x60,
/// > legacy_120x240, legacy_125x125, legacy_728x90, legacy_160x600,
/// > legacy_120x600, legacy_300x600
/// see IAB ad unit guidelines and iab_flex_{adUnitName} (see IAB's new ad portfolio and PDF)
#[serde(rename = "type")]
pub ad_type: String,
/// The minimum [`IMPRESSION`] payment accepted for the slot per deposit asset (token address).
///
/// `HashMap<DepositAsset, UnifiedNum>`
///
/// [`IMPRESSION`]: crate::sentry::IMPRESSION
#[serde(default)]
pub min_per_impression: Option<HashMap<Address, UnifiedNum>>,
#[serde(default)]
pub rules: Rules,
/// Valid ipfs hash for Ad Unit object. It will be used as fallback data (optional)
#[serde(default)]
pub fallback_unit: Option<IPFS>,
/// The AdSlot owner (Publisher)
pub owner: ValidatorId,
/// UTC timestamp in milliseconds, used as nonce for escaping duplicated spec ipfs hashes
#[serde(with = "ts_milliseconds")]
pub created: DateTime<Utc>,
/// The name of the unit used in platform UI
#[serde(default)]
pub title: Option<String>,
/// arbitrary text used in platform UI
#[serde(default)]
pub description: Option<String>,
#[serde(default)]
pub website: Option<String>,
/// user can change it - used for filtering in platform UI
#[serde(default)]
pub archived: bool,
/// UTC timestamp in milliseconds, changed every time modifiable property is changed
#[serde(with = "ts_milliseconds_option")]
pub modified: Option<DateTime<Utc>>,
}