Skip to content

Commit 7f7f6ed

Browse files
anand-venkatramanjsnellbaker
authored andcommitted
PulsePoint Bid Adapter: Support for schain (prebid#4433)
* 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 * ET-5938 SupplyChain Object Support * Formatting * Code review * Code review * Fix to currency parsing on response
1 parent 10de409 commit 7f7f6ed

File tree

2 files changed

+66
-5
lines changed

2 files changed

+66
-5
lines changed

modules/pulsepointBidAdapter.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export const spec = {
4747
badv: bidRequests[0].params.badv,
4848
user: user(bidRequests[0], bidderRequest),
4949
regs: regs(bidderRequest),
50+
source: source(bidRequests[0].schain),
5051
};
5152
return {
5253
method: 'POST',
@@ -116,7 +117,7 @@ function bidResponseAvailable(request, response) {
116117
adId: id,
117118
ttl: idToBidMap[id].exp || DEFAULT_BID_TTL,
118119
netRevenue: DEFAULT_NET_REVENUE,
119-
currency: idToBidMap[id].cur || DEFAULT_CURRENCY
120+
currency: bidResponse.cur || DEFAULT_CURRENCY
120121
};
121122
if (idToImpMap[id]['native']) {
122123
bid['native'] = nativeResponse(idToImpMap[id], idToBidMap[id]);
@@ -428,6 +429,18 @@ function regs(bidderRequest) {
428429
return null;
429430
}
430431

432+
/**
433+
* Creates source object with supply chain
434+
*/
435+
function source(schain) {
436+
if (schain) {
437+
return {
438+
ext: { schain }
439+
};
440+
}
441+
return null;
442+
}
443+
431444
/**
432445
* Parses the native response from the Bid given.
433446
*/

test/spec/modules/pulsepointBidAdapter_spec.js

+52-4
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,35 @@ describe('PulsePoint Adapter Tests', function () {
138138
}
139139
}
140140
}];
141+
142+
const schainParamsSlotConfig = [{
143+
placementCode: '/DfpAccount1/slot1',
144+
bidId: 'bid12345',
145+
params: {
146+
cp: 'p10000',
147+
ct: 't10000',
148+
cf: '1x1',
149+
bcat: ['IAB-1', 'IAB-20'],
150+
battr: [1, 2, 3],
151+
bidfloor: 1.5,
152+
badv: ['cocacola.com', 'lays.com']
153+
},
154+
schain: {
155+
'ver': '1.0',
156+
'complete': 1,
157+
'nodes': [
158+
{
159+
'asi': 'exchange1.com',
160+
'sid': '1234',
161+
'hp': 1,
162+
'rid': 'bid-request-1',
163+
'name': 'publisher',
164+
'domain': 'publisher.com'
165+
}
166+
]
167+
},
168+
}];
169+
141170
const bidderRequest = {
142171
refererInfo: {
143172
referer: 'https://publisher.com/home'
@@ -210,15 +239,15 @@ describe('PulsePoint Adapter Tests', function () {
210239
price: 1.25,
211240
adm: 'This is an Ad#1',
212241
crid: 'Creative#123',
213-
exp: 50,
214-
cur: 'GBP'
242+
exp: 50
215243
}, {
216244
impid: ortbRequest.imp[1].id,
217245
price: 1.25,
218246
adm: 'This is an Ad#2',
219247
crid: 'Creative#123'
220248
}]
221-
}]
249+
}],
250+
cur: 'GBP'
222251
};
223252
const bids = spec.interpretResponse({ body: ortbResponse }, request);
224253
expect(bids).to.have.lengthOf(2);
@@ -232,7 +261,7 @@ describe('PulsePoint Adapter Tests', function () {
232261
expect(secondBid.cpm).to.equal(1.25);
233262
expect(secondBid.ad).to.equal('This is an Ad#2');
234263
expect(secondBid.ttl).to.equal(20);
235-
expect(secondBid.currency).to.equal('USD');
264+
expect(secondBid.currency).to.equal('GBP');
236265
});
237266

238267
it('Verify full passback', function () {
@@ -485,6 +514,25 @@ describe('PulsePoint Adapter Tests', function () {
485514
expect(ortbRequest.imp[1].ext).to.be.null;
486515
});
487516

517+
it('Verify schain parameters', function () {
518+
const request = spec.buildRequests(schainParamsSlotConfig, bidderRequest);
519+
const ortbRequest = request.data;
520+
expect(ortbRequest).to.not.equal(null);
521+
expect(ortbRequest.source).to.not.equal(null);
522+
expect(ortbRequest.source.ext).to.not.equal(null);
523+
expect(ortbRequest.source.ext.schain).to.not.equal(null);
524+
expect(ortbRequest.source.ext.schain.complete).to.equal(1);
525+
expect(ortbRequest.source.ext.schain.ver).to.equal('1.0');
526+
expect(ortbRequest.source.ext.schain.nodes).to.not.equal(null);
527+
expect(ortbRequest.source.ext.schain.nodes).to.lengthOf(1);
528+
expect(ortbRequest.source.ext.schain.nodes[0].asi).to.equal('exchange1.com');
529+
expect(ortbRequest.source.ext.schain.nodes[0].sid).to.equal('1234');
530+
expect(ortbRequest.source.ext.schain.nodes[0].hp).to.equal(1);
531+
expect(ortbRequest.source.ext.schain.nodes[0].rid).to.equal('bid-request-1');
532+
expect(ortbRequest.source.ext.schain.nodes[0].name).to.equal('publisher');
533+
expect(ortbRequest.source.ext.schain.nodes[0].domain).to.equal('publisher.com');
534+
});
535+
488536
it('Verify outstream renderer', function () {
489537
const bidderRequestOutstream = Object.assign({}, bidderRequest, {bids: [outstreamSlotConfig[0]]});
490538
const request = spec.buildRequests(outstreamSlotConfig, bidderRequestOutstream);

0 commit comments

Comments
 (0)