Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No bid version 1.2.9 #5794

Merged
merged 12 commits into from
Nov 9, 2020
21 changes: 20 additions & 1 deletion modules/nobidBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getStorageManager } from '../src/storageManager.js';

const storage = getStorageManager();
const BIDDER_CODE = 'nobid';
window.nobidVersion = '1.2.8';
window.nobidVersion = '1.2.9';
window.nobid = window.nobid || {};
window.nobid.bidResponses = window.nobid.bidResponses || {};
window.nobid.timeoutTotal = 0;
Expand Down Expand Up @@ -114,6 +114,23 @@ function nobidBuildRequests(bids, bidderRequest) {
utils.logWarn('Could not parse screen dimensions, error details:', e);
}
}
var getEIDs = function(eids) {
if (utils.isArray(eids) && eids.length > 0) {
let src = [];
eids.forEach((eid) => {
let ids = [];
if (eid.uids) {
eid.uids.forEach(value => {
ids.push({'id': value.id + ''});
});
}
if (eid.source && ids.length > 0) {
src.push({source: eid.source, uids: ids});
}
});
return src;
}
}
var state = {};
state['sid'] = siteId;
state['l'] = topLocation(bidderRequest);
Expand All @@ -131,6 +148,8 @@ function nobidBuildRequests(bids, bidderRequest) {
if (sch) state['schain'] = sch;
const cop = coppa();
if (cop) state['coppa'] = cop;
const eids = getEIDs(utils.deepAccess(bids, '0.userIdAsEids'));
if (eids && eids.length > 0) state['eids'] = eids;
return state;
}
function newAdunit(adunitObject, adunits) {
Expand Down
69 changes: 69 additions & 0 deletions test/spec/modules/nobidBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,75 @@ describe('Nobid Adapter', function () {
});
});

describe('buildRequestsEIDs', function () {
const SITE_ID = 2;
const REFERER = 'https://www.examplereferer.com';
let bidRequests = [
{
'bidder': 'nobid',
'params': {
'siteId': SITE_ID
},
'adUnitCode': 'adunit-code',
'sizes': [[300, 250]],
'bidId': '30b31c1838de1e',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475',
'userIdAsEids': [
{
'source': 'criteo.com',
'uids': [
{
'id': 'CRITEO_ID',
'atype': 1
}
]
},
{
'source': 'id5-sync.com',
'uids': [
{
'id': 'ID5_ID',
'atype': 1
}
],
'ext': {
'linkType': 0
}
},
{
'source': 'adserver.org',
'uids': [
{
'id': 'TD_ID',
'atype': 1,
'ext': {
'rtiPartner': 'TDID'
}
}
]
}
]
}
];

let bidderRequest = {
refererInfo: {referer: REFERER}
}

it('should criteo eid', function () {
const request = spec.buildRequests(bidRequests, bidderRequest);
const payload = JSON.parse(request.data);
expect(payload.sid).to.exist.and.to.equal(2);
expect(payload.eids[0].source).to.exist.and.to.equal('criteo.com');
expect(payload.eids[0].uids[0].id).to.exist.and.to.equal('CRITEO_ID');
expect(payload.eids[1].source).to.exist.and.to.equal('id5-sync.com');
expect(payload.eids[1].uids[0].id).to.exist.and.to.equal('ID5_ID');
expect(payload.eids[2].source).to.exist.and.to.equal('adserver.org');
expect(payload.eids[2].uids[0].id).to.exist.and.to.equal('TD_ID');
});
});

describe('buildRequests', function () {
const SITE_ID = 2;
const REFERER = 'https://www.examplereferer.com';
Expand Down