Skip to content

Commit

Permalink
PulsePoint Adapter - update for ttl logic (prebid#4400)
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

* Using the TTL from the bid.ext

* Minor refactor
  • Loading branch information
anand-venkatraman authored and harpere committed Oct 30, 2019
1 parent 3f2b2c2 commit 9409959
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
13 changes: 2 additions & 11 deletions modules/pulsepointBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ function bidResponseAvailable(request, response) {
creative_id: idToBidMap[id].crid,
creativeId: idToBidMap[id].crid,
adId: id,
ttl: DEFAULT_BID_TTL,
ttl: idToBidMap[id].exp || DEFAULT_BID_TTL,
netRevenue: DEFAULT_NET_REVENUE,
currency: DEFAULT_CURRENCY
currency: idToBidMap[id].cur || DEFAULT_CURRENCY
};
if (idToImpMap[id]['native']) {
bid['native'] = nativeResponse(idToImpMap[id], idToBidMap[id]);
Expand All @@ -135,21 +135,12 @@ function bidResponseAvailable(request, response) {
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
31 changes: 20 additions & 11 deletions test/spec/modules/pulsepointBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,30 +200,39 @@ describe('PulsePoint Adapter Tests', function () {
expect(bid.ttl).to.equal(20);
});

it('Verify use ttl in ext', function () {
it('Verify ttl/currency applied to bid', function () {
const request = spec.buildRequests(slotConfigs, bidderRequest);
const ortbRequest = 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'
}
adm: 'This is an Ad#1',
crid: 'Creative#123',
exp: 50,
cur: 'GBP'
}, {
impid: ortbRequest.imp[1].id,
price: 1.25,
adm: 'This is an Ad#2',
crid: 'Creative#123'
}]
}]
};
const bids = spec.interpretResponse({ body: ortbResponse }, request);
expect(bids).to.have.lengthOf(1);
expect(bids).to.have.lengthOf(2);
// 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');
expect(bid.cpm).to.equal(1.25);
expect(bid.ad).to.equal('This is an Ad#1');
expect(bid.ttl).to.equal(50);
expect(bid.currency).to.equal('GBP');
const secondBid = bids[1];
expect(secondBid.cpm).to.equal(1.25);
expect(secondBid.ad).to.equal('This is an Ad#2');
expect(secondBid.ttl).to.equal(20);
expect(secondBid.currency).to.equal('USD');
});

it('Verify full passback', function () {
Expand Down

0 comments on commit 9409959

Please sign in to comment.