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

Eplanning Bid Adapter: verify getUserIds exists and is a function; add adomain support #6832

Merged
merged 10 commits into from
May 26, 2021
14 changes: 11 additions & 3 deletions modules/eplanningBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,12 @@ export const spec = {
if (bidderRequest && bidderRequest.uspConsent) {
params.ccpa = bidderRequest.uspConsent;
}
const userIds = (getGlobal()).getUserIds();
for (var id in userIds) {
params['e_' + id] = (typeof userIds[id] === 'object') ? encodeURIComponent(JSON.stringify(userIds[id])) : encodeURIComponent(userIds[id]);

if ((getGlobal()).getUserIds && typeof (getGlobal()).getUserIds === 'function') {
const userIds = (getGlobal()).getUserIds();
for (var id in userIds) {
params['e_' + id] = (typeof userIds[id] === 'object') ? encodeURIComponent(JSON.stringify(userIds[id])) : encodeURIComponent(userIds[id]);
}
}
}

Expand Down Expand Up @@ -114,6 +117,11 @@ export const spec = {
netRevenue: NET_REVENUE,
currency: DOLLARS,
};
if (ad.adom) {
bidResponse.meta = {
advertiserDomains: ad.adom
};
}
bidResponses.push(bidResponse);
});
}
Expand Down
53 changes: 53 additions & 0 deletions test/spec/modules/eplanningBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('E-Planning Adapter', function () {
const I_ID = '7854abc56248f873';
const CRID = '1234567890';
const TEST_ISV = 'leles.e-planning.net';
const ADOMAIN = 'adomain.com';
const validBid = {
'bidder': 'eplanning',
'bidId': BID_ID,
Expand Down Expand Up @@ -237,6 +238,39 @@ describe('E-Planning Adapter', function () {
]
}
};
const responseWithAdomain = {
body: {
'sI': {
'k': '12345'
},
'sec': {
'k': 'ROS'
},
'sp': [{
'k': CLEAN_ADUNIT_CODE,
'a': [{
'adm': ADM,
'id': '7854abc56248f874',
'i': I_ID,
'fi': '7854abc56248f872',
'ip': '45621afd87462104',
'w': W,
'h': H,
'crid': CRID,
'pr': CPM,
'adom': ADOMAIN
}],
}],
'cs': [
'http://a-sync-url.com/',
{
'u': 'http://another-sync-url.com/test.php?&partner=123456&endpoint=us-east',
'ifr': true
}
]
}
};

const responseWithNoSpace = {
body: {
'sI': {
Expand Down Expand Up @@ -520,6 +554,25 @@ describe('E-Planning Adapter', function () {
};
expect(bidResponse).to.deep.equal(expectedResponse);
});

it('should pass advertiserDomains when present', function () {
const bidResponse = spec.interpretResponse(responseWithAdomain, { adUnitToBidId: { [CLEAN_ADUNIT_CODE]: BID_ID } })[0];
const expectedResponse = {
requestId: BID_ID,
cpm: CPM,
width: W,
height: H,
ad: ADM,
ttl: 120,
creativeId: CRID,
netRevenue: true,
currency: 'USD',
meta: {
advertiserDomains: ADOMAIN
}
};
expect(bidResponse).to.deep.equal(expectedResponse);
});
});

describe('getUserSyncs', function () {
Expand Down