1
1
import { registerBidder } from '../src/adapters/bidderFactory' ;
2
+ import { deepAccess } from '../src/utils' ;
2
3
3
4
const BIDDER_CODE = 'optimera' ;
4
5
const SCORES_BASE_URL = 'https://dyv1bugovvq1g.cloudfront.net/' ;
@@ -11,12 +12,11 @@ export const spec = {
11
12
* @param {bidRequest } bid The bid params to validate.
12
13
* @return boolean True if this is a valid bid, and false otherwise.
13
14
*/
14
- isBidRequestValid : function ( bidRequest ) {
15
+ isBidRequestValid ( bidRequest ) {
15
16
if ( typeof bidRequest . params !== 'undefined' && typeof bidRequest . params . clientID !== 'undefined' ) {
16
17
return true ;
17
- } else {
18
- return false ;
19
18
}
19
+ return false ;
20
20
} ,
21
21
/**
22
22
* Make a server request from the list of BidRequests.
@@ -27,18 +27,19 @@ export const spec = {
27
27
* @param {validBidRequests[] } - an array of bids
28
28
* @return ServerRequest Info describing the request to the server.
29
29
*/
30
- buildRequests : function ( validBidRequests ) {
31
- let optimeraHost = window . location . host ;
32
- let optimeraPathName = window . location . pathname ;
30
+ buildRequests ( validBidRequests ) {
31
+ const optimeraHost = window . location . host ;
32
+ const optimeraPathName = window . location . pathname ;
33
33
if ( typeof validBidRequests [ 0 ] . params . clientID !== 'undefined' ) {
34
- let clientID = validBidRequests [ 0 ] . params . clientID ;
35
- let scoresURL = SCORES_BASE_URL + clientID + '/' + optimeraHost + optimeraPathName + ' .js' ;
34
+ const { clientID } = validBidRequests [ 0 ] . params ;
35
+ const scoresURL = ` ${ SCORES_BASE_URL + clientID } / ${ optimeraHost } ${ optimeraPathName } .js` ;
36
36
return {
37
37
method : 'GET' ,
38
38
url : scoresURL ,
39
39
payload : validBidRequests ,
40
40
} ;
41
41
}
42
+ return { } ;
42
43
} ,
43
44
/**
44
45
* Unpack the response from the server into a list of bids.
@@ -49,24 +50,25 @@ export const spec = {
49
50
* @param {* } serverResponse A successful response from the server.
50
51
* @return {Bid[] } An array of bids which were nested inside the server.
51
52
*/
52
- interpretResponse : function ( serverResponse , bidRequest ) {
53
- let validBids = bidRequest . payload ;
54
- let bidResponses = [ ] ;
53
+ interpretResponse ( serverResponse , bidRequest ) {
54
+ const validBids = bidRequest . payload ;
55
+ const bidResponses = [ ] ;
55
56
let dealId = '' ;
56
57
if ( typeof serverResponse . body !== 'undefined' ) {
57
- let scores = serverResponse . body ;
58
- for ( let i = 0 ; i < validBids . length ; i ++ ) {
58
+ const scores = serverResponse . body ;
59
+ for ( let i = 0 ; i < validBids . length ; i += 1 ) {
59
60
if ( typeof validBids [ i ] . params . clientID !== 'undefined' ) {
60
61
if ( validBids [ i ] . adUnitCode in scores ) {
61
- dealId = scores [ validBids [ i ] . adUnitCode ] ;
62
+ const deviceDealId = deepAccess ( scores , `device.${ validBids [ i ] . params . device } .${ validBids [ i ] . adUnitCode } ` ) ;
63
+ dealId = deviceDealId || scores [ validBids [ i ] . adUnitCode ] ;
62
64
}
63
- let bidResponse = {
65
+ const bidResponse = {
64
66
requestId : validBids [ i ] . bidId ,
65
67
ad : '<div></div>' ,
66
68
cpm : 0.01 ,
67
69
width : 0 ,
68
70
height : 0 ,
69
- dealId : dealId ,
71
+ dealId,
70
72
ttl : 300 ,
71
73
creativeId : '1' ,
72
74
netRevenue : '0' ,
0 commit comments