-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Copy pathbraveBidAdapter.js
33 lines (25 loc) · 1.17 KB
/
braveBidAdapter.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
import { isStr, triggerPixel } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import { parseNative } from '../libraries/braveUtils/index.js';
import { buildRequests, interpretResponse } from '../libraries/braveUtils/buildAndInterpret.js'
/**
* @typedef {import('../src/adapters/bidderFactory.js').BidRequest} BidRequest
* @typedef {import('../src/adapters/bidderFactory.js').Bid} Bid
*/
const BIDDER_CODE = 'brave';
const DEFAULT_CUR = 'USD';
const ENDPOINT_URL = `https://point.bravegroup.tv/?t=2&partner=hash`;
export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER, VIDEO, NATIVE],
isBidRequestValid: (bid) => !!(bid.params.placementId && bid.params.placementId.toString().length === 32),
buildRequests: (validBidRequests, bidderRequest) => buildRequests(validBidRequests, bidderRequest, ENDPOINT_URL, DEFAULT_CUR),
interpretResponse: (serverResponse) => interpretResponse(serverResponse, DEFAULT_CUR, parseNative),
onBidWon: (bid) => {
if (isStr(bid.nurl) && bid.nurl !== '') {
triggerPixel(bid.nurl);
}
}
};
registerBidder(spec);