Skip to content

Commit

Permalink
Pulsepoint adapter: fixing bid rejection due to missing mandatory bid…
Browse files Browse the repository at this point in the history
… params. (prebid#1823)

* 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

* Fixing review comment

* Applying values from "ext" as applicable
  • Loading branch information
anand-venkatraman authored and matthewlane committed Nov 14, 2017
1 parent 72df57e commit bd8d8ba
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
16 changes: 16 additions & 0 deletions modules/pulsepointLiteBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ const NATIVE_DEFAULTS = {
ICON_MIN: 50,
};

const DEFAULT_BID_TTL = 20;
const DEFAULT_CURRENCY = 'USD';
const DEFAULT_NET_REVENUE = true;

/**
* PulsePoint "Lite" Adapter. This adapter implementation is lighter than the
* alternative/original PulsePointAdapter because it has no external
Expand Down Expand Up @@ -89,6 +93,9 @@ function bidResponseAvailable(bidRequest, bidResponse) {
creative_id: id,
creativeId: id,
adId: id,
ttl: DEFAULT_BID_TTL,
netRevenue: DEFAULT_NET_REVENUE,
currency: DEFAULT_CURRENCY
};
if (idToImpMap[id]['native']) {
bid['native'] = nativeResponse(idToImpMap[id], idToBidMap[id]);
Expand All @@ -98,12 +105,21 @@ function bidResponseAvailable(bidRequest, bidResponse) {
bid.width = idToImpMap[id].banner.w;
bid.height = idToImpMap[id].banner.h;
}
applyExt(bid, idToBidMap[id])
bids.push(bid);
}
});
return bids;
}

function applyExt(bid, ortbBid) {
if (ortbBid && ortbBid.ext) {
bid.ttl = ortbBid.ext.ttl || bid.ttl;
bid.currency = ortbBid.ext.currency || bid.currency;
bid.netRevenue = ortbBid.ext.netRevenue != null ? ortbBid.ext.netRevenue : bid.netRevenue;
}
}

/**
* Produces an OpenRTBImpression from a slot config.
*/
Expand Down
29 changes: 29 additions & 0 deletions test/spec/modules/pulsepointLiteBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,35 @@ describe('PulsePoint Lite Adapter Tests', () => {
expect(bid.adId).to.equal('bid12345');
expect(bid.creative_id).to.equal('bid12345');
expect(bid.creativeId).to.equal('bid12345');
expect(bid.netRevenue).to.equal(true);
expect(bid.currency).to.equal('USD');
expect(bid.ttl).to.equal(20);
});

it('Verify use ttl in ext', () => {
const request = spec.buildRequests(slotConfigs);
const ortbRequest = JSON.parse(request.data);
const ortbResponse = {
seatbid: [{
bid: [{
impid: ortbRequest.imp[0].id,
price: 1.25,
adm: 'This is an Ad',
ext: {
ttl: 30,
netRevenue: false,
currency: 'INR'
}
}]
}]
};
const bids = spec.interpretResponse({ body: ortbResponse }, request);
expect(bids).to.have.lengthOf(1);
// verify first bid
const bid = bids[0];
expect(bid.ttl).to.equal(30);
expect(bid.netRevenue).to.equal(false);
expect(bid.currency).to.equal('INR');
});

it('Verify full passback', () => {
Expand Down

0 comments on commit bd8d8ba

Please sign in to comment.