1
-
2
- import { timestamp , deepAccess } from '../src/utils.js' ;
1
+ import { timestamp , deepAccess , isStr , deepClone } from '../src/utils.js' ;
3
2
import { getOrigin } from '../libraries/getOrigin/index.js' ;
4
3
import { config } from '../src/config.js' ;
5
4
import { registerBidder } from '../src/adapters/bidderFactory.js' ;
5
+ import { BANNER } from '../src/mediaTypes.js' ;
6
+
6
7
const BIDDER_CODE = 'resetdigital' ;
8
+ const CURRENCY = 'USD' ;
7
9
8
10
export const spec = {
9
11
code : BIDDER_CODE ,
@@ -43,16 +45,70 @@ export const spec = {
43
45
} ;
44
46
}
45
47
48
+ if ( bidderRequest && bidderRequest . uspConsent ) {
49
+ payload . ccpa = bidderRequest . uspConsent ;
50
+ }
51
+
52
+ function getOrtb2Keywords ( ortb2Obj ) {
53
+ const fields = [ 'site.keywords' , 'site.content.keywords' , 'user.keywords' , 'app.keywords' , 'app.content.keywords' ] ;
54
+ let result = [ ] ;
55
+
56
+ fields . forEach ( path => {
57
+ let keyStr = deepAccess ( ortb2Obj , path ) ;
58
+ if ( isStr ( keyStr ) ) result . push ( keyStr ) ;
59
+ } ) ;
60
+ return result ;
61
+ }
62
+
63
+ // get the ortb2 keywords data (if it exists)
64
+ let ortb2 = deepClone ( bidderRequest && bidderRequest . ortb2 ) ;
65
+ let ortb2KeywordsList = getOrtb2Keywords ( ortb2 ) ;
66
+ // get meta keywords data (if it exists)
67
+ let metaKeywords = document . getElementsByTagName ( 'meta' ) [ 'keywords' ] ;
68
+ if ( metaKeywords && metaKeywords . content ) {
69
+ metaKeywords = metaKeywords . content . split ( ',' ) ;
70
+ }
71
+
46
72
for ( let x = 0 ; x < validBidRequests . length ; x ++ ) {
47
- let req = validBidRequests [ x ]
73
+ let req = validBidRequests [ x ] ;
74
+
75
+ let bidFloor = req . params . bidFloor ? req . params . bidFloor : null ;
76
+ let bidFloorCur = req . params . bidFloor ? req . params . bidFloorCur : null ;
77
+
78
+ if ( typeof req . getFloor === 'function' ) {
79
+ const floorInfo = req . getFloor ( {
80
+ currency : CURRENCY ,
81
+ mediaType : BANNER ,
82
+ size : '*'
83
+ } ) ;
84
+ if ( typeof floorInfo === 'object' && floorInfo . currency === CURRENCY && ! isNaN ( parseFloat ( floorInfo . floor ) ) ) {
85
+ bidFloor = parseFloat ( floorInfo . floor ) ;
86
+ bidFloorCur = CURRENCY ;
87
+ }
88
+ }
89
+
90
+ // get param kewords (if it exists)
91
+ let paramsKeywords = req . params . keywords ? req . params . keywords . split ( ',' ) : [ ] ;
92
+ // merge all keywords
93
+ let keywords = ortb2KeywordsList . concat ( paramsKeywords ) . concat ( metaKeywords ) ;
48
94
49
95
payload . imps . push ( {
50
96
pub_id : req . params . pubId ,
97
+ site_id : req . params . siteID ? req . params . siteID : null ,
98
+ placement_id : req . params . placement ? req . params . placement : null ,
99
+ position : req . params . position ? req . params . position : null ,
100
+ bid_floor : bidFloor ,
101
+ bid_floor_cur : bidFloorCur ,
102
+ lat_long : req . params . latLong ? req . params . latLong : null ,
103
+ inventory : req . params . inventory ? req . params . inventory : null ,
104
+ visitor : req . params . visitor ? req . params . visitor : null ,
105
+ keywords : keywords . join ( ',' ) ,
51
106
zone_id : req . params . zoneId ,
52
107
bid_id : req . bidId ,
53
108
imp_id : req . transactionId ,
54
109
sizes : req . sizes ,
55
110
force_bid : req . params . forceBid ,
111
+ coppa : config . getConfig ( 'coppa' ) === true ? 1 : 0 ,
56
112
media_types : deepAccess ( req , 'mediaTypes' )
57
113
} ) ;
58
114
}
@@ -62,7 +118,8 @@ export const spec = {
62
118
return {
63
119
method : 'POST' ,
64
120
url : url ,
65
- data : JSON . stringify ( payload )
121
+ data : JSON . stringify ( payload ) ,
122
+ bids : validBidRequests
66
123
} ;
67
124
} ,
68
125
interpretResponse : function ( serverResponse , bidRequest ) {
0 commit comments