Skip to content

Commit b363e97

Browse files
madmaMike Chowla
authored andcommitted
Support schain module and send bidfloor param in Sharethrough adapter (#4271)
* Add support for supply chain object module Story: [#168742394](https://www.pivotaltracker.com/story/show/168742394) Co-authored-by: Josh Becker <[email protected]> * Add bidfloor parameter to bid request sent to STX Story: [#168742573](https://www.pivotaltracker.com/story/show/168742573)
1 parent f498ba8 commit b363e97

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

modules/sharethroughBidAdapter.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ export const sharethroughAdapterSpec = {
4141
query.ttduid = bidRequest.userId.tdid;
4242
}
4343

44+
if (bidRequest.schain) {
45+
query.schain = JSON.stringify(bidRequest.schain);
46+
}
47+
48+
if (bidRequest.bidfloor) {
49+
query.bidfloor = parseFloat(bidRequest.bidfloor);
50+
}
51+
4452
// Data that does not need to go to the server,
4553
// but we need as part of interpretResponse()
4654
const strData = {

test/spec/modules/sharethroughBidAdapter_spec.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,44 @@ describe('sharethrough adapter spec', function () {
280280
}
281281
});
282282
});
283+
284+
it('should add a supply chain parameter if schain is present', function() {
285+
// shallow copy of the first bidRequest obj, so we don't mutate
286+
const bidRequest = Object.assign({}, bidRequests[0]);
287+
bidRequest['schain'] = {
288+
ver: '1.0',
289+
complete: 1,
290+
nodes: [
291+
{
292+
asi: 'directseller.com',
293+
sid: '00001',
294+
rid: 'BidRequest1',
295+
hp: 1
296+
}
297+
]
298+
};
299+
300+
const builtBidRequest = spec.buildRequests([bidRequest])[0];
301+
expect(builtBidRequest.data.schain).to.eq(JSON.stringify(bidRequest.schain));
302+
});
303+
304+
it('should not add a supply chain parameter if schain is missing', function() {
305+
const bidRequest = spec.buildRequests(bidRequests)[0];
306+
expect(bidRequest.data).to.not.include.any.keys('schain');
307+
});
308+
309+
it('should include the bidfloor parameter if it is present in the bid request', function() {
310+
const bidRequest = Object.assign({}, bidRequests[0]);
311+
bidRequest['bidfloor'] = 0.50;
312+
const builtBidRequest = spec.buildRequests([bidRequest])[0];
313+
expect(builtBidRequest.data.bidfloor).to.eq(0.5);
314+
});
315+
316+
it('should not include the bidfloor parameter if it is missing in the bid request', function() {
317+
const bidRequest = Object.assign({}, bidRequests[0]);
318+
const builtBidRequest = spec.buildRequests([bidRequest])[0];
319+
expect(builtBidRequest.data).to.not.include.any.keys('bidfloor');
320+
});
283321
});
284322

285323
describe('.interpretResponse', function () {

0 commit comments

Comments
 (0)