forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinnityBidAdapter.js
62 lines (60 loc) · 1.93 KB
/
innityBidAdapter.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
import { parseSizesInput, timestamp } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
const BIDDER_CODE = 'innity';
const ENDPOINT = 'https://as.innity.com/synd/';
export const spec = {
code: BIDDER_CODE,
isBidRequestValid: function(bid) {
return !!(bid.params && bid.params.pub && bid.params.zone);
},
buildRequests: function(validBidRequests, bidderRequest) {
return validBidRequests.map(bidRequest => {
let parseSized = parseSizesInput(bidRequest.sizes);
let arrSize = parseSized[0].split('x');
return {
method: 'GET',
url: ENDPOINT,
data: {
cb: timestamp(),
ver: 2,
hb: 1,
output: 'js',
pub: bidRequest.params.pub,
zone: bidRequest.params.zone,
url: bidderRequest && bidderRequest.refererInfo ? encodeURIComponent(bidderRequest.refererInfo.page) : '',
width: arrSize[0],
height: arrSize[1],
vpw: window.screen.width,
vph: window.screen.height,
callback: 'json',
callback_uid: bidRequest.bidId,
// TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781
auction: bidRequest.auctionId,
},
};
});
},
interpretResponse: function(serverResponse, request) {
const res = serverResponse.body;
if (Object.keys(res).length === 0) {
return [];
}
const bidResponse = {
requestId: res.callback_uid,
cpm: parseFloat(res.cpm) / 100,
width: res.width,
height: res.height,
creativeId: res.creative_id,
currency: 'USD',
netRevenue: true,
ttl: 60,
ad: '<script src="https://cdn.innity.net/frame_util.js"></script>' + res.tag,
meta: {
advertiserDomains: res.adomain && res.adomain.length ? res.adomain : [],
mediaType: res.mediaType,
}
};
return [bidResponse];
}
}
registerBidder(spec);