forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmissenaBidAdapter.js
89 lines (76 loc) · 2.65 KB
/
missenaBidAdapter.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
import { formatQS, logInfo } from '../src/utils.js';
import { BANNER } from '../src/mediaTypes.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
const BIDDER_CODE = 'missena';
const ENDPOINT_URL = 'https://bid.missena.io/';
export const spec = {
aliases: [BIDDER_CODE],
code: BIDDER_CODE,
gvlid: 687,
supportedMediaTypes: [BANNER],
/**
* Determines whether or not the given bid request is valid.
*
* @param {BidRequest} bid The bid params to validate.
* @return boolean True if this is a valid bid, and false otherwise.
*/
isBidRequestValid: function (bid) {
return typeof bid == 'object' && !!bid.params.apiKey;
},
/**
* Make a server request from the list of BidRequests.
*
* @param {validBidRequests[]} - an array of bids
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function (validBidRequests, bidderRequest) {
return validBidRequests.map((bidRequest) => {
const payload = {
request_id: bidRequest.bidId,
timeout: bidderRequest.timeout,
};
if (bidderRequest && bidderRequest.refererInfo) {
payload.referer = bidderRequest.refererInfo.referer;
payload.referer_canonical = bidderRequest.refererInfo.canonicalUrl;
}
if (bidderRequest && bidderRequest.gdprConsent) {
payload.consent_string = bidderRequest.gdprConsent.consentString;
payload.consent_required = bidderRequest.gdprConsent.gdprApplies;
}
return {
method: 'POST',
url: ENDPOINT_URL + '?' + formatQS({ t: bidRequest.params.apiKey }),
data: JSON.stringify(payload),
};
});
},
/**
* Unpack the response from the server into a list of bids.
*
* @param {ServerResponse} serverResponse A successful response from the server.
* @return {Bid[]} An array of bids which were nested inside the server.
*/
interpretResponse: function (serverResponse, bidRequest) {
const bidResponses = [];
const response = serverResponse.body;
if (response && !response.timeout && !!response.ad) {
bidResponses.push(response);
}
return bidResponses;
},
/**
* Register bidder specific code, which will execute if bidder timed out after an auction
* @param {data} Containing timeout specific data
*/
onTimeout: function onTimeout(timeoutData) {
logInfo('Missena - Timeout from adapter', timeoutData);
},
/**
* Register bidder specific code, which@ will execute if a bid from this bidder won the auction
* @param {Bid} The bid that won the auction
*/
onBidWon: function (bid) {
logInfo('Missena - Bid won', bid);
},
};
registerBidder(spec);