Skip to content

Commit 9409959

Browse files
anand-venkatramanharpere
authored andcommitted
PulsePoint Adapter - update for ttl logic (prebid#4400)
* 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
1 parent 3f2b2c2 commit 9409959

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

modules/pulsepointBidAdapter.js

+2-11
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ function bidResponseAvailable(request, response) {
114114
creative_id: idToBidMap[id].crid,
115115
creativeId: idToBidMap[id].crid,
116116
adId: id,
117-
ttl: DEFAULT_BID_TTL,
117+
ttl: idToBidMap[id].exp || DEFAULT_BID_TTL,
118118
netRevenue: DEFAULT_NET_REVENUE,
119-
currency: DEFAULT_CURRENCY
119+
currency: idToBidMap[id].cur || DEFAULT_CURRENCY
120120
};
121121
if (idToImpMap[id]['native']) {
122122
bid['native'] = nativeResponse(idToImpMap[id], idToBidMap[id]);
@@ -135,21 +135,12 @@ function bidResponseAvailable(request, response) {
135135
bid.width = idToImpMap[id].banner.w;
136136
bid.height = idToImpMap[id].banner.h;
137137
}
138-
applyExt(bid, idToBidMap[id])
139138
bids.push(bid);
140139
}
141140
});
142141
return bids;
143142
}
144143

145-
function applyExt(bid, ortbBid) {
146-
if (ortbBid && ortbBid.ext) {
147-
bid.ttl = ortbBid.ext.ttl || bid.ttl;
148-
bid.currency = ortbBid.ext.currency || bid.currency;
149-
bid.netRevenue = ortbBid.ext.netRevenue != null ? ortbBid.ext.netRevenue : bid.netRevenue;
150-
}
151-
}
152-
153144
/**
154145
* Produces an OpenRTBImpression from a slot config.
155146
*/

test/spec/modules/pulsepointBidAdapter_spec.js

+20-11
Original file line numberDiff line numberDiff line change
@@ -200,30 +200,39 @@ describe('PulsePoint Adapter Tests', function () {
200200
expect(bid.ttl).to.equal(20);
201201
});
202202

203-
it('Verify use ttl in ext', function () {
203+
it('Verify ttl/currency applied to bid', function () {
204204
const request = spec.buildRequests(slotConfigs, bidderRequest);
205205
const ortbRequest = request.data;
206206
const ortbResponse = {
207207
seatbid: [{
208208
bid: [{
209209
impid: ortbRequest.imp[0].id,
210210
price: 1.25,
211-
adm: 'This is an Ad',
212-
ext: {
213-
ttl: 30,
214-
netRevenue: false,
215-
currency: 'INR'
216-
}
211+
adm: 'This is an Ad#1',
212+
crid: 'Creative#123',
213+
exp: 50,
214+
cur: 'GBP'
215+
}, {
216+
impid: ortbRequest.imp[1].id,
217+
price: 1.25,
218+
adm: 'This is an Ad#2',
219+
crid: 'Creative#123'
217220
}]
218221
}]
219222
};
220223
const bids = spec.interpretResponse({ body: ortbResponse }, request);
221-
expect(bids).to.have.lengthOf(1);
224+
expect(bids).to.have.lengthOf(2);
222225
// verify first bid
223226
const bid = bids[0];
224-
expect(bid.ttl).to.equal(30);
225-
expect(bid.netRevenue).to.equal(false);
226-
expect(bid.currency).to.equal('INR');
227+
expect(bid.cpm).to.equal(1.25);
228+
expect(bid.ad).to.equal('This is an Ad#1');
229+
expect(bid.ttl).to.equal(50);
230+
expect(bid.currency).to.equal('GBP');
231+
const secondBid = bids[1];
232+
expect(secondBid.cpm).to.equal(1.25);
233+
expect(secondBid.ad).to.equal('This is an Ad#2');
234+
expect(secondBid.ttl).to.equal(20);
235+
expect(secondBid.currency).to.equal('USD');
227236
});
228237

229238
it('Verify full passback', function () {

0 commit comments

Comments
 (0)