Skip to content

Commit

Permalink
Eplanning Bid Adapter: verify getUserIds exists and is a function; ad…
Browse files Browse the repository at this point in the history
…d adomain support (#6832)
  • Loading branch information
sebaperez authored May 26, 2021
1 parent 61aadfb commit 0895e4a
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 3 deletions.
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

0 comments on commit 0895e4a

Please sign in to comment.