Skip to content
This repository was archived by the owner on Feb 13, 2021. It is now read-only.

Commit bd8d8ba

Browse files
anand-venkatramanmatthewlane
authored andcommitted
Pulsepoint adapter: fixing bid rejection due to missing mandatory bid 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
1 parent 72df57e commit bd8d8ba

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

modules/pulsepointLiteBidAdapter.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ const NATIVE_DEFAULTS = {
1010
ICON_MIN: 50,
1111
};
1212

13+
const DEFAULT_BID_TTL = 20;
14+
const DEFAULT_CURRENCY = 'USD';
15+
const DEFAULT_NET_REVENUE = true;
16+
1317
/**
1418
* PulsePoint "Lite" Adapter. This adapter implementation is lighter than the
1519
* alternative/original PulsePointAdapter because it has no external
@@ -89,6 +93,9 @@ function bidResponseAvailable(bidRequest, bidResponse) {
8993
creative_id: id,
9094
creativeId: id,
9195
adId: id,
96+
ttl: DEFAULT_BID_TTL,
97+
netRevenue: DEFAULT_NET_REVENUE,
98+
currency: DEFAULT_CURRENCY
9299
};
93100
if (idToImpMap[id]['native']) {
94101
bid['native'] = nativeResponse(idToImpMap[id], idToBidMap[id]);
@@ -98,12 +105,21 @@ function bidResponseAvailable(bidRequest, bidResponse) {
98105
bid.width = idToImpMap[id].banner.w;
99106
bid.height = idToImpMap[id].banner.h;
100107
}
108+
applyExt(bid, idToBidMap[id])
101109
bids.push(bid);
102110
}
103111
});
104112
return bids;
105113
}
106114

115+
function applyExt(bid, ortbBid) {
116+
if (ortbBid && ortbBid.ext) {
117+
bid.ttl = ortbBid.ext.ttl || bid.ttl;
118+
bid.currency = ortbBid.ext.currency || bid.currency;
119+
bid.netRevenue = ortbBid.ext.netRevenue != null ? ortbBid.ext.netRevenue : bid.netRevenue;
120+
}
121+
}
122+
107123
/**
108124
* Produces an OpenRTBImpression from a slot config.
109125
*/

test/spec/modules/pulsepointLiteBidAdapter_spec.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,35 @@ describe('PulsePoint Lite Adapter Tests', () => {
100100
expect(bid.adId).to.equal('bid12345');
101101
expect(bid.creative_id).to.equal('bid12345');
102102
expect(bid.creativeId).to.equal('bid12345');
103+
expect(bid.netRevenue).to.equal(true);
104+
expect(bid.currency).to.equal('USD');
105+
expect(bid.ttl).to.equal(20);
106+
});
107+
108+
it('Verify use ttl in ext', () => {
109+
const request = spec.buildRequests(slotConfigs);
110+
const ortbRequest = JSON.parse(request.data);
111+
const ortbResponse = {
112+
seatbid: [{
113+
bid: [{
114+
impid: ortbRequest.imp[0].id,
115+
price: 1.25,
116+
adm: 'This is an Ad',
117+
ext: {
118+
ttl: 30,
119+
netRevenue: false,
120+
currency: 'INR'
121+
}
122+
}]
123+
}]
124+
};
125+
const bids = spec.interpretResponse({ body: ortbResponse }, request);
126+
expect(bids).to.have.lengthOf(1);
127+
// verify first bid
128+
const bid = bids[0];
129+
expect(bid.ttl).to.equal(30);
130+
expect(bid.netRevenue).to.equal(false);
131+
expect(bid.currency).to.equal('INR');
103132
});
104133

105134
it('Verify full passback', () => {

0 commit comments

Comments
 (0)