Skip to content

Commit

Permalink
Support schain module and send bidfloor param in Sharethrough adapter (
Browse files Browse the repository at this point in the history
…#4271)

* Add support for supply chain object module

Story: [#168742394](https://www.pivotaltracker.com/story/show/168742394)

Co-authored-by: Josh Becker <jbecker@sharethrough.com>

* Add bidfloor parameter to bid request sent to STX

Story: [#168742573](https://www.pivotaltracker.com/story/show/168742573)
  • Loading branch information
madma authored and Mike Chowla committed Oct 15, 2019
1 parent f498ba8 commit b363e97
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
8 changes: 8 additions & 0 deletions modules/sharethroughBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ export const sharethroughAdapterSpec = {
query.ttduid = bidRequest.userId.tdid;
}

if (bidRequest.schain) {
query.schain = JSON.stringify(bidRequest.schain);
}

if (bidRequest.bidfloor) {
query.bidfloor = parseFloat(bidRequest.bidfloor);
}

// Data that does not need to go to the server,
// but we need as part of interpretResponse()
const strData = {
Expand Down
38 changes: 38 additions & 0 deletions test/spec/modules/sharethroughBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,44 @@ describe('sharethrough adapter spec', function () {
}
});
});

it('should add a supply chain parameter if schain is present', function() {
// shallow copy of the first bidRequest obj, so we don't mutate
const bidRequest = Object.assign({}, bidRequests[0]);
bidRequest['schain'] = {
ver: '1.0',
complete: 1,
nodes: [
{
asi: 'directseller.com',
sid: '00001',
rid: 'BidRequest1',
hp: 1
}
]
};

const builtBidRequest = spec.buildRequests([bidRequest])[0];
expect(builtBidRequest.data.schain).to.eq(JSON.stringify(bidRequest.schain));
});

it('should not add a supply chain parameter if schain is missing', function() {
const bidRequest = spec.buildRequests(bidRequests)[0];
expect(bidRequest.data).to.not.include.any.keys('schain');
});

it('should include the bidfloor parameter if it is present in the bid request', function() {
const bidRequest = Object.assign({}, bidRequests[0]);
bidRequest['bidfloor'] = 0.50;
const builtBidRequest = spec.buildRequests([bidRequest])[0];
expect(builtBidRequest.data.bidfloor).to.eq(0.5);
});

it('should not include the bidfloor parameter if it is missing in the bid request', function() {
const bidRequest = Object.assign({}, bidRequests[0]);
const builtBidRequest = spec.buildRequests([bidRequest])[0];
expect(builtBidRequest.data).to.not.include.any.keys('bidfloor');
});
});

describe('.interpretResponse', function () {
Expand Down

0 comments on commit b363e97

Please sign in to comment.