Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support schain module and send bidfloor param in Sharethrough adapter #4271

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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