Skip to content

Commit c98a633

Browse files
PulsePoint Adapter: Fixing issue with multi-format requests (prebid#5995)
* 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
1 parent 578213c commit c98a633

File tree

2 files changed

+59
-5
lines changed

2 files changed

+59
-5
lines changed

modules/pulsepointBidAdapter.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,7 @@ function bidResponseAvailable(request, response) {
121121
netRevenue: DEFAULT_NET_REVENUE,
122122
currency: bidResponse.cur || DEFAULT_CURRENCY
123123
};
124-
if (idToImpMap[id]['native']) {
125-
bid['native'] = nativeResponse(idToImpMap[id], idToBidMap[id]);
126-
bid.mediaType = 'native';
127-
} else if (idToImpMap[id].video) {
124+
if (idToImpMap[id].video) {
128125
// for outstream, a renderer is specified
129126
if (idToSlotConfig[id] && utils.deepAccess(idToSlotConfig[id], 'mediaTypes.video.context') === 'outstream') {
130127
bid.renderer = outstreamRenderer(utils.deepAccess(idToSlotConfig[id], 'renderer.options'), utils.deepAccess(idToBidMap[id], 'ext.outstream'));
@@ -133,10 +130,13 @@ function bidResponseAvailable(request, response) {
133130
bid.mediaType = 'video';
134131
bid.width = idToBidMap[id].w;
135132
bid.height = idToBidMap[id].h;
136-
} else {
133+
} else if (idToImpMap[id].banner) {
137134
bid.ad = idToBidMap[id].adm;
138135
bid.width = idToBidMap[id].w || idToImpMap[id].banner.w;
139136
bid.height = idToBidMap[id].h || idToImpMap[id].banner.h;
137+
} else if (idToImpMap[id]['native']) {
138+
bid['native'] = nativeResponse(idToImpMap[id], idToBidMap[id]);
139+
bid.mediaType = 'native';
140140
}
141141
bids.push(bid);
142142
}

test/spec/modules/pulsepointBidAdapter_spec.js

+54
Original file line numberDiff line numberDiff line change
@@ -724,4 +724,58 @@ describe('PulsePoint Adapter Tests', function () {
724724
expect(bid.width).to.equal(728);
725725
expect(bid.height).to.equal(90);
726726
});
727+
it('Verify multi-format response', function () {
728+
const bidRequests = deepClone(slotConfigs);
729+
bidRequests[0].mediaTypes['native'] = {
730+
title: {
731+
required: true
732+
},
733+
image: {
734+
required: true
735+
},
736+
sponsoredBy: {
737+
required: true
738+
}
739+
};
740+
bidRequests[1].params.video = {
741+
w: 400,
742+
h: 300,
743+
minduration: 5,
744+
maxduration: 10,
745+
};
746+
const request = spec.buildRequests(bidRequests, bidderRequest);
747+
expect(request).to.be.not.null;
748+
expect(request.data).to.be.not.null;
749+
const ortbRequest = request.data;
750+
expect(ortbRequest.imp).to.have.lengthOf(2);
751+
// adsize on response
752+
const ortbResponse = {
753+
seatbid: [{
754+
bid: [{
755+
impid: ortbRequest.imp[0].id,
756+
price: 1.25,
757+
adm: 'This is an Ad',
758+
crid: 'Creative#123',
759+
w: 728,
760+
h: 90
761+
}, {
762+
impid: ortbRequest.imp[1].id,
763+
price: 2.5,
764+
adm: '<vast url="http://ad.com/video"></vast>',
765+
crid: 'Creative#234',
766+
w: 728,
767+
h: 90
768+
}]
769+
}]
770+
};
771+
// request has both types - banner and native, response is parsed as banner.
772+
// for impression#2, response is parsed as video
773+
const bids = spec.interpretResponse({ body: ortbResponse }, request);
774+
expect(bids).to.have.lengthOf(2);
775+
const bid = bids[0];
776+
expect(bid.width).to.equal(728);
777+
expect(bid.height).to.equal(90);
778+
const secondBid = bids[1];
779+
expect(secondBid.vastXml).to.equal('<vast url="http://ad.com/video"></vast>');
780+
});
727781
});

0 commit comments

Comments
 (0)