forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmarthubBidAdapter.js
84 lines (76 loc) · 2.4 KB
/
smarthubBidAdapter.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
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
import {
buildPlacementProcessingFunction,
buildRequestsBase,
interpretResponseBuilder,
isBidRequestValid
} from '../libraries/teqblazeUtils/bidderUtils.js';
const BIDDER_CODE = 'smarthub';
const ALIASES = [
{code: 'attekmi'},
{code: 'markapp'},
{code: 'jdpmedia'},
{code: 'tredio'},
{code: 'felixads'},
{code: 'vimayx'},
];
const BASE_URLS = {
attekmi: 'https://prebid.attekmi.com/pbjs',
smarthub: 'https://prebid.attekmi.com/pbjs',
markapp: 'https://markapp-prebid.attekmi.com/pbjs',
jdpmedia: 'https://jdpmedia-prebid.attekmi.com/pbjs',
tredio: 'https://tredio-prebid.attekmi.com/pbjs',
felixads: 'https://felixads-prebid.attekmi.com/pbjs',
vimayx: 'https://vimayx-prebid.attekmi.com/pbjs',
};
const _getUrl = (partnerName) => {
const aliases = ALIASES.map(el => el.code);
if (aliases.includes(partnerName)) {
return BASE_URLS[partnerName];
}
return `${BASE_URLS[BIDDER_CODE]}?partnerName=${partnerName}`;
}
const getPartnerName = (bid) => String(bid.params?.partnerName || bid.bidder).toLowerCase();
const getPlacementReqData = buildPlacementProcessingFunction({
addPlacementType() {},
addCustomFieldsToPlacement(bid, bidderRequest, placement) {
const { seat, token, iabCat, minBidfloor, pos } = bid.params;
Object.assign(placement, {
partnerName: getPartnerName(bid),
seat,
token,
iabCat,
minBidfloor,
pos,
});
}
})
const buildRequests = (validBidRequests = [], bidderRequest = {}) => {
const bidsByPartner = validBidRequests.reduce((bidsByPartner, bid) => {
const partner = getPartnerName(bid);
(bidsByPartner[partner] = bidsByPartner[partner] || []).push(bid);
return bidsByPartner;
}, {});
return Object.entries(bidsByPartner).map(([partner, validBidRequests]) => {
return buildRequestsBase({
adUrl: _getUrl(partner),
bidderRequest,
validBidRequests,
placementProcessingFunction: getPlacementReqData
})
})
}
export const spec = {
code: BIDDER_CODE,
aliases: ALIASES,
supportedMediaTypes: [BANNER, VIDEO, NATIVE],
isBidRequestValid: isBidRequestValid(['seat', 'token'], 'every'),
buildRequests,
interpretResponse: interpretResponseBuilder({
addtlBidValidation(bid) {
return bid.hasOwnProperty('netRevenue')
}
})
};
registerBidder(spec);