@@ -25,6 +25,7 @@ impl Input {
25
25
let spec = & self . global . channel . spec ;
26
26
27
27
match key {
28
+ // AdView scope, accessible only on the AdView
28
29
"adView.secondsSinceCampaignImpression" => self
29
30
. ad_view
30
31
. as_ref ( )
@@ -35,9 +36,22 @@ impl Input {
35
36
. as_ref ( )
36
37
. map ( |ad_view| Value :: Bool ( ad_view. has_custom_preferences ) )
37
38
. ok_or ( Error :: UnknownVariable ) ,
39
+ "adView.navigatorLanguage" => self
40
+ . ad_view
41
+ . as_ref ( )
42
+ . map ( |ad_view| Value :: String ( ad_view. navigator_language . clone ( ) ) )
43
+ . ok_or ( Error :: UnknownVariable ) ,
44
+ // Global scope, accessible everywhere
38
45
"adSlotId" => Ok ( Value :: String ( self . global . ad_slot_id . clone ( ) ) ) ,
39
46
"adSlotType" => Ok ( Value :: String ( self . global . ad_slot_type . clone ( ) ) ) ,
40
47
"publisherId" => Ok ( Value :: String ( self . global . publisher_id . to_checksum ( ) ) ) ,
48
+ "country" => self
49
+ . global
50
+ . country
51
+ . clone ( )
52
+ . ok_or ( Error :: UnknownVariable )
53
+ . map ( Value :: String ) ,
54
+ "eventType" => Ok ( Value :: String ( self . global . event_type . clone ( ) ) ) ,
41
55
"secondsSinceEpoch" => Ok ( Value :: Number ( self . global . seconds_since_epoch . into ( ) ) ) ,
42
56
"userAgentOS" => self
43
57
. global
@@ -51,7 +65,7 @@ impl Input {
51
65
. clone ( )
52
66
. map ( Value :: String )
53
67
. ok_or ( Error :: UnknownVariable ) ,
54
-
68
+ // Global scope, accessible everywhere, campaign-dependant
55
69
"adUnitId" => {
56
70
let ipfs = self
57
71
. global
@@ -113,6 +127,7 @@ impl Input {
113
127
114
128
Ok ( Value :: BigNum ( earned) )
115
129
}
130
+ // adSlot scope, accessible on Supermarket and AdView
116
131
"adSlot.categories" => self
117
132
. ad_slot
118
133
. as_ref ( )
@@ -221,12 +236,15 @@ impl Output {
221
236
"boost" => {
222
237
let boost = Number :: from_f64 ( self . boost ) . ok_or ( Error :: TypeError ) ?;
223
238
Ok ( Value :: Number ( boost) )
224
- } ,
239
+ }
225
240
price_key if price_key. starts_with ( "price." ) => {
226
- let price = self . price . get ( price_key. trim_start_matches ( "price." ) ) . ok_or ( Error :: UnknownVariable ) ?;
241
+ let price = self
242
+ . price
243
+ . get ( price_key. trim_start_matches ( "price." ) )
244
+ . ok_or ( Error :: UnknownVariable ) ?;
227
245
Ok ( Value :: BigNum ( price. clone ( ) ) )
228
- } ,
229
- _ => Err ( Error :: UnknownVariable )
246
+ }
247
+ _ => Err ( Error :: UnknownVariable ) ,
230
248
}
231
249
}
232
250
}
@@ -352,7 +370,12 @@ mod test {
352
370
} ;
353
371
354
372
assert_eq ! ( Ok ( Value :: Bool ( false ) ) , output. try_get( "show" ) ) ;
355
- assert_eq ! ( Ok ( Value :: Number ( Number :: from_f64( 5.5 ) . expect( "Should make a number" ) ) ) , output. try_get( "boost" ) ) ;
373
+ assert_eq ! (
374
+ Ok ( Value :: Number (
375
+ Number :: from_f64( 5.5 ) . expect( "Should make a number" )
376
+ ) ) ,
377
+ output. try_get( "boost" )
378
+ ) ;
356
379
assert_eq ! ( Ok ( Value :: BigNum ( 100 . into( ) ) ) , output. try_get( "price.one" ) ) ;
357
380
assert_eq ! ( Err ( Error :: UnknownVariable ) , output. try_get( "price.unknown" ) ) ;
358
381
assert_eq ! ( Err ( Error :: UnknownVariable ) , output. try_get( "unknown" ) ) ;
0 commit comments