Skip to content

Commit

Permalink
PulsePoint Bid Adapter: Support for schain (prebid#4433)
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

* ET-5938 SupplyChain Object Support

* Formatting

* Code review

* Code review

* Fix to currency parsing on response
  • Loading branch information
anand-venkatraman authored and jsnellbaker committed Nov 8, 2019
1 parent 10de409 commit 7f7f6ed
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 5 deletions.
15 changes: 14 additions & 1 deletion modules/pulsepointBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const spec = {
badv: bidRequests[0].params.badv,
user: user(bidRequests[0], bidderRequest),
regs: regs(bidderRequest),
source: source(bidRequests[0].schain),
};
return {
method: 'POST',
Expand Down Expand Up @@ -116,7 +117,7 @@ function bidResponseAvailable(request, response) {
adId: id,
ttl: idToBidMap[id].exp || DEFAULT_BID_TTL,
netRevenue: DEFAULT_NET_REVENUE,
currency: idToBidMap[id].cur || DEFAULT_CURRENCY
currency: bidResponse.cur || DEFAULT_CURRENCY
};
if (idToImpMap[id]['native']) {
bid['native'] = nativeResponse(idToImpMap[id], idToBidMap[id]);
Expand Down Expand Up @@ -428,6 +429,18 @@ function regs(bidderRequest) {
return null;
}

/**
* Creates source object with supply chain
*/
function source(schain) {
if (schain) {
return {
ext: { schain }
};
}
return null;
}

/**
* Parses the native response from the Bid given.
*/
Expand Down
56 changes: 52 additions & 4 deletions test/spec/modules/pulsepointBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,35 @@ describe('PulsePoint Adapter Tests', function () {
}
}
}];

const schainParamsSlotConfig = [{
placementCode: '/DfpAccount1/slot1',
bidId: 'bid12345',
params: {
cp: 'p10000',
ct: 't10000',
cf: '1x1',
bcat: ['IAB-1', 'IAB-20'],
battr: [1, 2, 3],
bidfloor: 1.5,
badv: ['cocacola.com', 'lays.com']
},
schain: {
'ver': '1.0',
'complete': 1,
'nodes': [
{
'asi': 'exchange1.com',
'sid': '1234',
'hp': 1,
'rid': 'bid-request-1',
'name': 'publisher',
'domain': 'publisher.com'
}
]
},
}];

const bidderRequest = {
refererInfo: {
referer: 'https://publisher.com/home'
Expand Down Expand Up @@ -210,15 +239,15 @@ describe('PulsePoint Adapter Tests', function () {
price: 1.25,
adm: 'This is an Ad#1',
crid: 'Creative#123',
exp: 50,
cur: 'GBP'
exp: 50
}, {
impid: ortbRequest.imp[1].id,
price: 1.25,
adm: 'This is an Ad#2',
crid: 'Creative#123'
}]
}]
}],
cur: 'GBP'
};
const bids = spec.interpretResponse({ body: ortbResponse }, request);
expect(bids).to.have.lengthOf(2);
Expand All @@ -232,7 +261,7 @@ describe('PulsePoint Adapter Tests', function () {
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');
expect(secondBid.currency).to.equal('GBP');
});

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

it('Verify schain parameters', function () {
const request = spec.buildRequests(schainParamsSlotConfig, bidderRequest);
const ortbRequest = request.data;
expect(ortbRequest).to.not.equal(null);
expect(ortbRequest.source).to.not.equal(null);
expect(ortbRequest.source.ext).to.not.equal(null);
expect(ortbRequest.source.ext.schain).to.not.equal(null);
expect(ortbRequest.source.ext.schain.complete).to.equal(1);
expect(ortbRequest.source.ext.schain.ver).to.equal('1.0');
expect(ortbRequest.source.ext.schain.nodes).to.not.equal(null);
expect(ortbRequest.source.ext.schain.nodes).to.lengthOf(1);
expect(ortbRequest.source.ext.schain.nodes[0].asi).to.equal('exchange1.com');
expect(ortbRequest.source.ext.schain.nodes[0].sid).to.equal('1234');
expect(ortbRequest.source.ext.schain.nodes[0].hp).to.equal(1);
expect(ortbRequest.source.ext.schain.nodes[0].rid).to.equal('bid-request-1');
expect(ortbRequest.source.ext.schain.nodes[0].name).to.equal('publisher');
expect(ortbRequest.source.ext.schain.nodes[0].domain).to.equal('publisher.com');
});

it('Verify outstream renderer', function () {
const bidderRequestOutstream = Object.assign({}, bidderRequest, {bids: [outstreamSlotConfig[0]]});
const request = spec.buildRequests(outstreamSlotConfig, bidderRequestOutstream);
Expand Down

0 comments on commit 7f7f6ed

Please sign in to comment.