Skip to content

Commit c918034

Browse files
committed
Typo in AdSlot & targeting Input fixes
1 parent 4208916 commit c918034

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

primitives/src/ad_slot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub struct AdSlot {
5959
#[serde(default)]
6060
pub description: Option<String>,
6161
#[serde(default)]
62-
pub webiste: Option<String>,
62+
pub website: Option<String>,
6363
/// user can change it - used for filtering in platform UI
6464
#[serde(default)]
6565
pub archived: bool,

primitives/src/targeting.rs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ impl Input {
3434
"adUnitId" => Ok(Value::String(self.global.ad_unit_id.clone())),
3535
"publisherId" => Ok(Value::String(self.global.publisher_id.clone())),
3636
"advertiserId" => Ok(Value::String(self.global.advertiser_id.clone())),
37-
"country" => self.global.country.clone().map(Value::String).ok_or(Error::UnknownVariable),
37+
"country" => self
38+
.global
39+
.country
40+
.clone()
41+
.map(Value::String)
42+
.ok_or(Error::UnknownVariable),
3843
"eventType" => Ok(Value::String(self.global.event_type.clone())),
3944
"campaignId" => Ok(Value::String(self.global.campaign_id.clone())),
4045
"campaignTotalSpent" => Ok(Value::String(self.global.campaign_total_spent.clone())),
@@ -51,10 +56,18 @@ impl Input {
5156
self.global.publisher_earned_from_campaign.clone(),
5257
)),
5358
"secondsSinceEpoch" => Ok(Value::Number(self.global.seconds_since_epoch.into())),
54-
"userAgentOS" => self.global.user_agent_os.clone().map(Value::String).ok_or(Error::UnknownVariable),
55-
"userAgentBrowserFamily" => {
56-
self.global.user_agent_browser_family.clone().map(Value::String).ok_or(Error::UnknownVariable)
57-
}
59+
"userAgentOS" => self
60+
.global
61+
.user_agent_os
62+
.clone()
63+
.map(Value::String)
64+
.ok_or(Error::UnknownVariable),
65+
"userAgentBrowserFamily" => self
66+
.global
67+
.user_agent_browser_family
68+
.clone()
69+
.map(Value::String)
70+
.ok_or(Error::UnknownVariable),
5871
"adSlot.categories" => self
5972
.ad_slot
6073
.as_ref()
@@ -70,9 +83,10 @@ impl Input {
7083
"adSlot.hostname" => self
7184
.ad_slot
7285
.as_ref()
73-
.map(|ad_slot| Value::String(ad_slot.hostname.clone()))
86+
.map(|ad_slot| Value::String(ad_slot.hostname.clone().unwrap_or_default()))
7487
.ok_or(Error::UnknownVariable),
7588
"adSlot.alexaRank" => {
89+
// @TODO: Decide how to handle Alexa rank values
7690
let ad_slot = self.ad_slot.as_ref().ok_or(Error::UnknownVariable)?;
7791
let alexa_rank = ad_slot.alexa_rank.ok_or(Error::UnknownVariable)?;
7892

@@ -123,7 +137,7 @@ pub struct Global {
123137
#[cfg_attr(test, derive(Default))]
124138
pub struct AdSlot {
125139
pub categories: Vec<String>,
126-
pub hostname: String,
140+
pub hostname: Option<String>,
127141
pub alexa_rank: Option<f64>,
128142
}
129143

@@ -202,7 +216,10 @@ mod test {
202216

203217
assert_eq!(Value::BigNum(BigNum::from(50)), global_campaign_budget);
204218

205-
assert_eq!(Err(Error::UnknownVariable), input.try_get("adSlot.alexaRank"));
219+
assert_eq!(
220+
Err(Error::UnknownVariable),
221+
input.try_get("adSlot.alexaRank")
222+
);
206223
let mut ad_slot = AdSlot::default();
207224
ad_slot.alexa_rank = Some(20.0);
208225
input.ad_slot = Some(ad_slot);

0 commit comments

Comments
 (0)