forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlockerdomeBidAdapter.js
76 lines (72 loc) · 2.23 KB
/
lockerdomeBidAdapter.js
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import {BANNER} from '../src/mediaTypes.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {getBidIdParameter} from '../src/utils.js';
export const spec = {
code: 'lockerdome',
supportedMediaTypes: [BANNER],
isBidRequestValid: function(bid) {
return !!bid.params.adUnitId;
},
buildRequests: function(bidRequests, bidderRequest) {
let schain;
const adUnitBidRequests = bidRequests.map(function (bid) {
if (bid.schain) schain = schain || bid.schain;
return {
requestId: bid.bidId,
adUnitCode: bid.adUnitCode,
adUnitId: getBidIdParameter('adUnitId', bid.params),
sizes: bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes
};
});
const payload = {
bidRequests: adUnitBidRequests,
// TODO: are these the right refererInfo values?
url: encodeURIComponent(bidderRequest?.refererInfo?.canonicalUrl || ''),
referrer: encodeURIComponent(bidderRequest?.refererInfo?.topmostLocation || '')
};
if (schain) {
payload.schain = schain;
}
if (bidderRequest) {
if (bidderRequest.gdprConsent) {
payload.gdpr = {
applies: bidderRequest.gdprConsent.gdprApplies,
consent: bidderRequest.gdprConsent.consentString
};
}
if (bidderRequest.uspConsent) {
payload.us_privacy = {
consent: bidderRequest.uspConsent
}
}
}
const payloadString = JSON.stringify(payload);
return {
method: 'POST',
url: 'https://lockerdome.com/ladbid/prebid',
data: payloadString
};
},
interpretResponse: function(serverResponse, bidRequest) {
if (!serverResponse || !serverResponse.body || !serverResponse.body.bids) {
return [];
}
return serverResponse.body.bids.map(function(bid) {
return {
requestId: bid.requestId,
cpm: bid.cpm,
width: bid.width,
height: bid.height,
creativeId: bid.creativeId,
currency: bid.currency,
netRevenue: bid.netRevenue,
ad: bid.ad,
ttl: bid.ttl,
meta: {
advertiserDomains: bid.adomain && Array.isArray(bid.adomain) ? bid.adomain : []
}
};
});
},
};
registerBidder(spec);