forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanyclipBidAdapter.js
54 lines (47 loc) · 1.64 KB
/
anyclipBidAdapter.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
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {
buildRequests,
getUserSyncs,
interpretResponse,
} from '../libraries/xeUtils/bidderUtils.js';
import {deepAccess, getBidIdParameter, isArray, logError} from '../src/utils.js';
const BIDDER_CODE = 'anyclip';
const ENDPOINT = 'https://prebid.anyclip.com';
function isBidRequestValid(bid) {
if (bid && typeof bid.params !== 'object') {
logError('Params is not defined or is incorrect in the bidder settings');
return false;
}
if (!getBidIdParameter('publisherId', bid.params) || !getBidIdParameter('supplyTagId', bid.params)) {
logError('PublisherId or supplyTagId is not present in bidder params');
return false;
}
if (deepAccess(bid, 'mediaTypes.video') && !isArray(deepAccess(bid, 'mediaTypes.video.playerSize'))) {
logError('mediaTypes.video.playerSize is required for video');
return false;
}
return true;
}
export const spec = {
code: BIDDER_CODE,
aliases: ['anyclip'],
supportedMediaTypes: [BANNER, VIDEO],
isBidRequestValid,
buildRequests: (validBidRequests, bidderRequest) => {
const builtRequests = buildRequests(validBidRequests, bidderRequest, ENDPOINT)
const requests = JSON.parse(builtRequests.data)
const updatedRequests = requests.map(req => ({
...req,
env: {
publisherId: validBidRequests[0].params.publisherId,
supplyTagId: validBidRequests[0].params.supplyTagId,
floor: req.floor
},
}))
return {...builtRequests, data: JSON.stringify(updatedRequests)}
},
interpretResponse,
getUserSyncs
}
registerBidder(spec);