forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththemoneytizerBidAdapter.js
102 lines (84 loc) · 2.87 KB
/
themoneytizerBidAdapter.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
94
95
96
97
98
99
100
101
102
import { logInfo, logWarn } from '../src/utils.js';
import { BANNER } from '../src/mediaTypes.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
const BIDDER_CODE = 'themoneytizer';
const GVLID = 1265;
const ENDPOINT_URL = 'https://ads.biddertmz.com/m/';
export const spec = {
aliases: [BIDDER_CODE],
code: BIDDER_CODE,
supportedMediaTypes: [BANNER],
gvlid: GVLID,
isBidRequestValid: function (bid) {
if (!(bid && bid.params.pid)) {
logWarn('Invalid bid request - missing required bid params');
return false;
}
return true;
},
buildRequests: function (validBidRequests, bidderRequest) {
return validBidRequests.map((bidRequest) => {
const payload = {
ext: bidRequest.ortb2Imp.ext,
params: bidRequest.params,
size: bidRequest.mediaTypes,
adunit: bidRequest.adUnitCode,
request_id: bidRequest.bidId,
timeout: bidderRequest.timeout,
ortb2: bidderRequest.ortb2,
eids: bidRequest.userIdAsEids,
id: bidRequest.auctionId,
schain: bidRequest.schain,
version: '$prebid.version$',
excl_sync: window.tmzrBidderExclSync
};
const baseUrl = bidRequest.params.baseUrl || ENDPOINT_URL;
if (bidderRequest && bidderRequest.refererInfo) {
payload.referer = bidderRequest.refererInfo.topmostLocation;
payload.referer_canonical = bidderRequest.refererInfo.canonicalUrl;
}
if (bidderRequest && bidderRequest.gdprConsent) {
payload.consent_string = bidderRequest.gdprConsent.consentString;
payload.consent_required = bidderRequest.gdprConsent.gdprApplies;
}
if (bidRequest.params.test) {
payload.test = bidRequest.params.test;
}
payload.userEids = bidRequest.userIdAsEids || [];
return {
method: 'POST',
url: baseUrl,
data: JSON.stringify(payload),
};
});
},
interpretResponse: function (serverResponse, bidRequest) {
const bidResponses = [];
const response = serverResponse.body;
if (response && response.bid && !response.timeout && !!response.bid.ad) {
bidResponses.push(response.bid);
}
return bidResponses;
},
getUserSyncs: function (syncOptions, serverResponses) {
if (!syncOptions.iframeEnabled && !syncOptions.pixelEnabled) {
return [];
}
let s = [];
serverResponses.map((c) => {
if (c.body.c_sync) {
c.body.c_sync.bidder_status.map((p) => {
if (p.usersync.type === 'redirect') {
p.usersync.type = 'image';
}
s.push(p.usersync);
})
}
});
return s;
},
onTimeout: function onTimeout(timeoutData) {
logInfo('The Moneytizer - Timeout from adapter', timeoutData);
},
};
registerBidder(spec);