Skip to content

Commit 13b9d3f

Browse files
gchicoyeGabriel ChicoyeCopilot
authored
Revnew Bid Adapter: transfer from alias (#14212)
* revnew with own logic * Update modules/revnewBidAdapter.ts Co-authored-by: Copilot <[email protected]> * Update test/spec/modules/revnewBidAdapter_spec.js Co-authored-by: Copilot <[email protected]> * Update modules/revnewBidAdapter.ts Co-authored-by: Copilot <[email protected]> * Update test/spec/modules/revnewBidAdapter_spec.js Co-authored-by: Copilot <[email protected]> * Update test/spec/modules/revnewBidAdapter_spec.js Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Gabriel Chicoye <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent 6f6dc93 commit 13b9d3f

File tree

4 files changed

+779
-1
lines changed

4 files changed

+779
-1
lines changed

modules/nexx360BidAdapter.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ const ALIASES = [
5959
{ code: 'scoremedia', gvlid: 965 },
6060
{ code: 'movingup', gvlid: 1416 },
6161
{ code: 'glomexbidder', gvlid: 967 },
62-
{ code: 'revnew', gvlid: 1468 },
6362
{ code: 'pubxai', gvlid: 1485 },
6463
{ code: 'ybidder', gvlid: 1253 },
6564
];

modules/revnewBidAdapter.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Overview
2+
3+
```
4+
Module Name: Revnew Bid Adapter
5+
Module Type: Bidder Adapter
6+
Maintainer: [email protected]
7+
```
8+
9+
# Description
10+
11+
Connects to Revnew network for bids.
12+
13+
To use us as a bidder you must have an account and an active "tagId" or "placement" on our platform.
14+
15+
# Test Parameters
16+
17+
## Web
18+
19+
### Display
20+
```
21+
var adUnits = [
22+
// Banner adUnit
23+
{
24+
code: 'banner-div',
25+
mediaTypes: {
26+
banner: {
27+
sizes: [[300, 250], [300,600]]
28+
}
29+
},
30+
bids: [{
31+
bidder: 'revnew',
32+
params: {
33+
tagId: 'testnexx'
34+
}
35+
}]
36+
},
37+
];
38+
```
39+
40+
### Video Instream
41+
```
42+
var videoAdUnit = {
43+
code: 'video1',
44+
mediaTypes: {
45+
video: {
46+
playerSize: [640, 480],
47+
context: 'instream'
48+
}
49+
},
50+
bids: [{
51+
bidder: 'revnew',
52+
params: {
53+
placement: 'TEST_PLACEMENT'
54+
}
55+
}]
56+
};
57+
```

modules/revnewBidAdapter.ts

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import { deepSetValue, generateUUID, logError } from '../src/utils.js';
2+
import {getStorageManager} from '../src/storageManager.js';
3+
import {AdapterRequest, BidderSpec, registerBidder} from '../src/adapters/bidderFactory.js';
4+
import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
5+
import {ortbConverter} from '../libraries/ortbConverter/converter.js'
6+
7+
import { interpretResponse, enrichImp, enrichRequest, getAmxId, getLocalStorageFunctionGenerator, getUserSyncs } from '../libraries/nexx360Utils/index.js';
8+
import { BidRequest, ClientBidderRequest } from '../src/adapterManager.js';
9+
import { ORTBImp, ORTBRequest } from '../src/prebid.public.js';
10+
11+
const BIDDER_CODE = 'revnew';
12+
const REQUEST_URL = 'https://fast.nexx360.io/revnew';
13+
const PAGE_VIEW_ID = generateUUID();
14+
const BIDDER_VERSION = '1.0';
15+
const GVLID = 1468;
16+
const REVNEW_KEY = 'revnew_storage';
17+
18+
type RequireAtLeastOne<T, Keys extends keyof T = keyof T> =
19+
Omit<T, Keys> & {
20+
[K in Keys]-?: Required<Pick<T, K>> &
21+
Partial<Pick<T, Exclude<Keys, K>>>
22+
}[Keys];
23+
24+
type RevnewBidParams = RequireAtLeastOne<{
25+
tagId?: string;
26+
placement?: string;
27+
customId?: string;
28+
}, "tagId" | "placement">;
29+
30+
declare module '../src/adUnits' {
31+
interface BidderParams {
32+
[BIDDER_CODE]: RevnewBidParams;
33+
}
34+
}
35+
36+
export const STORAGE = getStorageManager({
37+
bidderCode: BIDDER_CODE,
38+
});
39+
40+
export const getRevnewLocalStorage = getLocalStorageFunctionGenerator<{ revnewId: string }>(
41+
STORAGE,
42+
BIDDER_CODE,
43+
REVNEW_KEY,
44+
'revnewId'
45+
);
46+
47+
const converter = ortbConverter({
48+
context: {
49+
netRevenue: true,
50+
ttl: 120,
51+
},
52+
imp(buildImp, bidRequest: BidRequest<typeof BIDDER_CODE>, context) {
53+
let imp:ORTBImp = buildImp(bidRequest, context);
54+
imp = enrichImp(imp, bidRequest);
55+
deepSetValue(imp, 'ext.revnew', bidRequest.params);
56+
return imp;
57+
},
58+
request(buildRequest, imps, bidderRequest, context) {
59+
let request:ORTBRequest = buildRequest(imps, bidderRequest, context);
60+
const amxId = getAmxId(STORAGE, BIDDER_CODE);
61+
request = enrichRequest(request, amxId, PAGE_VIEW_ID, BIDDER_VERSION);
62+
return request;
63+
},
64+
});
65+
66+
const isBidRequestValid = (bid:BidRequest<typeof BIDDER_CODE>): boolean => {
67+
if (!bid.params.tagId && !bid.params.placement) {
68+
logError('bid.params.tagId or bid.params.placement must be defined');
69+
return false;
70+
}
71+
return true;
72+
};
73+
74+
const buildRequests = (
75+
bidRequests: BidRequest<typeof BIDDER_CODE>[],
76+
bidderRequest: ClientBidderRequest<typeof BIDDER_CODE>,
77+
): AdapterRequest => {
78+
const data:ORTBRequest = converter.toORTB({bidRequests, bidderRequest})
79+
const adapterRequest:AdapterRequest = {
80+
method: 'POST',
81+
url: REQUEST_URL,
82+
data,
83+
}
84+
return adapterRequest;
85+
};
86+
87+
export const spec:BidderSpec<typeof BIDDER_CODE> = {
88+
code: BIDDER_CODE,
89+
gvlid: GVLID,
90+
supportedMediaTypes: [BANNER, VIDEO, NATIVE],
91+
isBidRequestValid,
92+
buildRequests,
93+
interpretResponse,
94+
getUserSyncs,
95+
};
96+
97+
registerBidder(spec);

0 commit comments

Comments
 (0)