forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglomexBidAdapter.js
93 lines (82 loc) · 2.59 KB
/
glomexBidAdapter.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {find} from '../src/polyfill.js';
import {BANNER} from '../src/mediaTypes.js';
const ENDPOINT = 'https://prebid.mes.glomex.cloud/request-bid'
const BIDDER_CODE = 'glomex'
const GVLID = 967
export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
supportedMediaTypes: [BANNER],
isBidRequestValid: function (bid) {
if (bid && bid.params && bid.params.integrationId) {
return true
}
return false
},
buildRequests: function (validBidRequests, bidderRequest = {}) {
const refererInfo = bidderRequest.refererInfo || {};
const gdprConsent = bidderRequest.gdprConsent || {};
return {
method: 'POST',
url: `${ENDPOINT}`,
data: {
// TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781
auctionId: bidderRequest.auctionId,
refererInfo: {
// TODO: this collects everything it finds, except for canonicalUrl
isAmp: refererInfo.isAmp,
numIframes: refererInfo.numIframes,
reachedTop: refererInfo.reachedTop,
referer: refererInfo.topmostLocation,
},
gdprConsent: {
consentString: gdprConsent.consentString,
gdprApplies: gdprConsent.gdprApplies
},
bidRequests: validBidRequests.map(({ params, sizes, bidId, adUnitCode }) => ({
bidId,
adUnitCode,
params,
sizes
}))
},
options: {
withCredentials: false,
contentType: 'application/json'
},
validBidRequests: validBidRequests,
}
},
interpretResponse: function (serverResponse, originalBidRequest) {
const bidResponses = []
originalBidRequest.validBidRequests.forEach(function (bidRequest) {
if (!serverResponse.body) {
return
}
const matchedBid = find(serverResponse.body.bids, function (bid) {
return String(bidRequest.bidId) === String(bid.id)
})
if (matchedBid) {
const bidResponse = {
requestId: bidRequest.bidId,
cpm: matchedBid.cpm,
width: matchedBid.width,
height: matchedBid.height,
creativeId: matchedBid.creativeId,
dealId: matchedBid.dealId,
currency: matchedBid.currency,
netRevenue: matchedBid.netRevenue,
ttl: matchedBid.ttl,
ad: matchedBid.ad,
meta: {
advertiserDomains: matchedBid.adomain ? matchedBid.adomain : []
}
}
bidResponses.push(bidResponse)
}
})
return bidResponses
}
};
registerBidder(spec)