Skip to content

Commit

Permalink
PulsePoint Adapter: Fixing issue with multi-format requests (prebid#5995
Browse files Browse the repository at this point in the history
)

* ET-1691: Pulsepoint Analytics adapter for Prebid. (#1)

* ET-1691: Adding pulsepoint analytics and tests for pulsepoint adapter

* ET-1691: Adding pulsepoint analytics and tests for pulsepoint adapter

* ET-1691: cleanup

* ET-1691: minor

* ET-1691: revert package.json change

* Adding bidRequest to bidFactory.createBid method as per prebid#509

* ET-1765: Adding support for additional params in PulsePoint adapter (#2)

* ET-1850: Fixing prebid#866

* Minor fix

* Adding mandatory parameters to Bid

* APPS-3793: Fixing multi-format request issue

* Added test
  • Loading branch information
anand-venkatraman authored Nov 20, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 578213c commit c98a633
Showing 2 changed files with 59 additions and 5 deletions.
10 changes: 5 additions & 5 deletions modules/pulsepointBidAdapter.js
Original file line number Diff line number Diff line change
@@ -121,10 +121,7 @@ function bidResponseAvailable(request, response) {
netRevenue: DEFAULT_NET_REVENUE,
currency: bidResponse.cur || DEFAULT_CURRENCY
};
if (idToImpMap[id]['native']) {
bid['native'] = nativeResponse(idToImpMap[id], idToBidMap[id]);
bid.mediaType = 'native';
} else if (idToImpMap[id].video) {
if (idToImpMap[id].video) {
// for outstream, a renderer is specified
if (idToSlotConfig[id] && utils.deepAccess(idToSlotConfig[id], 'mediaTypes.video.context') === 'outstream') {
bid.renderer = outstreamRenderer(utils.deepAccess(idToSlotConfig[id], 'renderer.options'), utils.deepAccess(idToBidMap[id], 'ext.outstream'));
@@ -133,10 +130,13 @@ function bidResponseAvailable(request, response) {
bid.mediaType = 'video';
bid.width = idToBidMap[id].w;
bid.height = idToBidMap[id].h;
} else {
} else if (idToImpMap[id].banner) {
bid.ad = idToBidMap[id].adm;
bid.width = idToBidMap[id].w || idToImpMap[id].banner.w;
bid.height = idToBidMap[id].h || idToImpMap[id].banner.h;
} else if (idToImpMap[id]['native']) {
bid['native'] = nativeResponse(idToImpMap[id], idToBidMap[id]);
bid.mediaType = 'native';
}
bids.push(bid);
}
54 changes: 54 additions & 0 deletions test/spec/modules/pulsepointBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -724,4 +724,58 @@ describe('PulsePoint Adapter Tests', function () {
expect(bid.width).to.equal(728);
expect(bid.height).to.equal(90);
});
it('Verify multi-format response', function () {
const bidRequests = deepClone(slotConfigs);
bidRequests[0].mediaTypes['native'] = {
title: {
required: true
},
image: {
required: true
},
sponsoredBy: {
required: true
}
};
bidRequests[1].params.video = {
w: 400,
h: 300,
minduration: 5,
maxduration: 10,
};
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request).to.be.not.null;
expect(request.data).to.be.not.null;
const ortbRequest = request.data;
expect(ortbRequest.imp).to.have.lengthOf(2);
// adsize on response
const ortbResponse = {
seatbid: [{
bid: [{
impid: ortbRequest.imp[0].id,
price: 1.25,
adm: 'This is an Ad',
crid: 'Creative#123',
w: 728,
h: 90
}, {
impid: ortbRequest.imp[1].id,
price: 2.5,
adm: '<vast url="http://ad.com/video"></vast>',
crid: 'Creative#234',
w: 728,
h: 90
}]
}]
};
// request has both types - banner and native, response is parsed as banner.
// for impression#2, response is parsed as video
const bids = spec.interpretResponse({ body: ortbResponse }, request);
expect(bids).to.have.lengthOf(2);
const bid = bids[0];
expect(bid.width).to.equal(728);
expect(bid.height).to.equal(90);
const secondBid = bids[1];
expect(secondBid.vastXml).to.equal('<vast url="http://ad.com/video"></vast>');
});
});

0 comments on commit c98a633

Please sign in to comment.