forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrixengineBidAdapter.js
67 lines (58 loc) · 1.52 KB
/
rixengineBidAdapter.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
import { BANNER } from '../src/mediaTypes.js';
import { ortbConverter } from '../libraries/ortbConverter/converter.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
const BIDDER_CODE = 'rixengine';
let ENDPOINT = null;
let SID = null;
let TOKEN = null;
const DEFAULT_BID_TTL = 30;
const DEFAULT_CURRENCY = 'USD';
const DEFAULT_NET_REVENUE = true;
const converter = ortbConverter({
context: {
netRevenue: DEFAULT_NET_REVENUE,
ttl: DEFAULT_BID_TTL,
currency: DEFAULT_CURRENCY,
mediaType: BANNER,
},
imp(buildImp, bidRequest, context) {
const imp = buildImp(bidRequest, context);
return imp;
},
});
export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER],
isBidRequestValid: function (bid) {
if (
Boolean(bid.params.endpoint) &&
Boolean(bid.params.sid) &&
Boolean(bid.params.token)
) {
SID = bid.params.sid;
TOKEN = bid.params.token;
ENDPOINT = bid.params.endpoint + '?sid=' + SID + '&token=' + TOKEN;
return true;
}
return false;
},
buildRequests(bidRequests, bidderRequest) {
let data = converter.toORTB({ bidRequests, bidderRequest });
return [
{
method: 'POST',
url: ENDPOINT,
data,
options: { contentType: 'application/json;charset=utf-8' },
},
];
},
interpretResponse(response, request) {
const bids = converter.fromORTB({
response: response.body,
request: request.data,
}).bids;
return bids;
},
};
registerBidder(spec);