Skip to content

Commit

Permalink
TheAdx Bid Adapter : eids support added (#11681)
Browse files Browse the repository at this point in the history
* eids support added

* theadx bid adaptor new eids test added

---------

Co-authored-by: mku <[email protected]>
  • Loading branch information
mustafakemal16 and mku committed Jun 7, 2024
1 parent 203ebe5 commit 903b9ad
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 4 deletions.
45 changes: 43 additions & 2 deletions modules/theAdxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { convertOrtbRequestToProprietaryNative } from '../src/native.js';

const BIDDER_CODE = 'theadx';
const ENDPOINT_URL = 'https://ssp.theadx.com/request';
const ENDPOINT_TR_URL = 'https://ssptr.theadx.com/request';

const NATIVEASSETNAMES = {
0: 'title',
Expand Down Expand Up @@ -125,7 +126,7 @@ const NATIVEPROBS = {

export const spec = {
code: BIDDER_CODE,
aliases: ['theadx'], // short code
aliases: ['theadx', 'theAdx'], // short code
supportedMediaTypes: [BANNER, VIDEO, NATIVE],

/**
Expand Down Expand Up @@ -160,10 +161,11 @@ export const spec = {
if (!isEmpty(validBidRequests)) {
results = validBidRequests.map(
bidRequest => {
let url = `${getRegionEndPoint(bidRequest)}?tagid=${bidRequest.params.tagId}`;
return {
method: requestType,
type: requestType,
url: `${ENDPOINT_URL}?tagid=${bidRequest.params.tagId}`,
url: url,
options: {
withCredentials: true,
},
Expand Down Expand Up @@ -500,6 +502,14 @@ let generateImpBody = (bidRequest, bidderRequest) => {

return result;
}
let getRegionEndPoint = (bidRequest) => {
if (bidRequest && bidRequest.params && bidRequest.params.region) {
if (bidRequest.params.region.toLowerCase() == 'tr') {
return ENDPOINT_TR_URL;
}
}
return ENDPOINT_URL;
};

let generatePayload = (bidRequest, bidderRequest) => {
// Generate the expected OpenRTB payload
Expand All @@ -511,7 +521,38 @@ let generatePayload = (bidRequest, bidderRequest) => {
imp: [generateImpBody(bidRequest, bidderRequest)],
};
// return payload;
let eids = getEids(bidRequest);
if (Object.keys(eids).length > 0) {
payload.ext = eids;
}
return JSON.stringify(payload);
};

function getEids(bidRequest) {
let eids = {}

let uId2 = deepAccess(bidRequest, 'userId.uid2.id');
if (uId2) {
eids['uid2'] = uId2;
}

let id5 = deepAccess(bidRequest, 'userId.id5id.uid');
if (id5) {
eids['id5id'] = id5;
let id5Linktype = deepAccess(bidRequest, 'userId.id5id.ext.linkType');
if (id5Linktype) {
eids['id5_linktype'] = id5Linktype;
}
}
let netId = deepAccess(bidRequest, 'userId.netId');
if (netId) {
eids['netid'] = netId;
}
let sharedId = deepAccess(bidRequest, 'userId.sharedid.id');
if (sharedId) {
eids['sharedid'] = sharedId;
}
return eids;
};

registerBidder(spec);
42 changes: 40 additions & 2 deletions test/spec/modules/theAdxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,21 @@ describe('TheAdxAdapter', function () {
[300, 600]
]
}
}
},
userId: {
uid2: { id: 'sample-uid2' },
id5id: {
'uid': 'sample-id5id',
'ext': {
'linkType': 'abc'
}
},
netId: 'sample-netid',
sharedid: {
'id': 'sample-sharedid',
},

},
};

const sampleBidderRequest = {
Expand Down Expand Up @@ -357,6 +371,30 @@ describe('TheAdxAdapter', function () {
expect(mediaTypes.video).to.not.be.null;
expect(mediaTypes.video).to.not.be.undefined;
});

it('add eids to request', function () {
let localBidRequest = JSON.parse(JSON.stringify(sampleBidRequest));

let results = spec.buildRequests([localBidRequest], sampleBidderRequest);
let result = results.pop();
let payload = JSON.parse(result.data);
expect(payload).to.not.be.null;
expect(payload.ext).to.not.be.null;

expect(payload.ext.uid2).to.not.be.null;
expect(payload.ext.uid2.length).to.greaterThan(0);

expect(payload.ext.id5id).to.not.be.null;
expect(payload.ext.id5id.length).to.greaterThan(0);
expect(payload.ext.id5_linktype).to.not.be.null;
expect(payload.ext.id5_linktype.length).to.greaterThan(0);

expect(payload.ext.netid).to.not.be.null;
expect(payload.ext.netid.length).to.greaterThan(0);

expect(payload.ext.sharedid).to.not.be.null;
expect(payload.ext.sharedid.length).to.greaterThan(0);
});
});

describe('response interpreter', function () {
Expand Down Expand Up @@ -495,7 +533,7 @@ describe('TheAdxAdapter', function () {
banner: {}
},
requestId: incomingRequestId,
deals: [{id: dealId}]
deals: [{ id: dealId }]
};
let serverResponse = {
body: sampleResponse
Expand Down

0 comments on commit 903b9ad

Please sign in to comment.