forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipromBidAdapter.js
82 lines (70 loc) · 2.14 KB
/
ipromBidAdapter.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
import { logError } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
const BIDDER_CODE = 'iprom';
const ENDPOINT_URL = 'https://core.iprom.net/programmatic';
const VERSION = 'v1.0.3';
const DEFAULT_CURRENCY = 'EUR';
const DEFAULT_NETREVENUE = true;
const DEFAULT_TTL = 360;
const IAB_GVL_ID = 811;
export const spec = {
code: BIDDER_CODE,
gvlid: IAB_GVL_ID,
isBidRequestValid: function ({ bidder, params = {} } = {}) {
// id parameter checks
if (!params.id) {
logError(`${bidder}: Parameter 'id' missing`);
return false;
} else if (typeof params.id !== 'string') {
logError(`${bidder}: Parameter 'id' needs to be a string`);
return false;
}
// dimension parameter checks
if (!params.dimension) {
logError(`${bidder}: Required parameter 'dimension' missing`);
return false;
} else if (typeof params.dimension !== 'string') {
logError(`${bidder}: Parameter 'dimension' needs to be a string`);
return false;
}
return true;
},
buildRequests: function (validBidRequests, bidderRequest) {
const payload = {
bids: validBidRequests,
// TODO: please do not send internal data structures over the network
referer: bidderRequest.refererInfo.legacy,
version: VERSION
};
const payloadString = JSON.stringify(payload);
return {
method: 'POST',
url: ENDPOINT_URL,
data: payloadString
};
},
interpretResponse: function (serverResponse, request) {
let bids = serverResponse.body;
const bidResponses = [];
bids.forEach(bid => {
const b = {
ad: bid.ad,
requestId: bid.requestId,
cpm: bid.cpm,
width: bid.width,
height: bid.height,
creativeId: bid.creativeId,
currency: bid.currency || DEFAULT_CURRENCY,
netRevenue: bid.netRevenue || DEFAULT_NETREVENUE,
ttl: bid.ttl || DEFAULT_TTL,
meta: {},
};
if (bid.aDomains && bid.aDomains.length) {
b.meta.advertiserDomains = bid.aDomains;
}
bidResponses.push(b);
});
return bidResponses;
},
}
registerBidder(spec);