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

Adkernel: schain supported #5558

Merged
merged 1 commit into from
Aug 7, 2020
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
11 changes: 8 additions & 3 deletions modules/adkernelBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ export const spec = {
*/
buildRequests: function (bidRequests, bidderRequest) {
let impDispatch = dispatchImps(bidRequests, bidderRequest.refererInfo);
const requests = [];
let requests = [];
let schain = bidRequests[0].schain;
Object.keys(impDispatch).forEach(host => {
Object.keys(impDispatch[host]).forEach(zoneId => {
const request = buildRtbRequest(impDispatch[host][zoneId], bidderRequest);
const request = buildRtbRequest(impDispatch[host][zoneId], bidderRequest, schain);
requests.push({
method: 'POST',
url: `https://${host}/hb?zone=${zoneId}&v=${VERSION}`,
Expand Down Expand Up @@ -293,9 +294,10 @@ function getAllowedSyncMethod(bidderCode) {
* Builds complete rtb request
* @param imps {Object} Collection of rtb impressions
* @param bidderRequest {BidderRequest}
* @param schain {Object=} Supply chain config
* @return {Object} Complete rtb request
*/
function buildRtbRequest(imps, bidderRequest) {
function buildRtbRequest(imps, bidderRequest, schain) {
let {bidderCode, gdprConsent, auctionId, refererInfo, timeout, uspConsent} = bidderRequest;

let req = {
Expand Down Expand Up @@ -329,6 +331,9 @@ function buildRtbRequest(imps, bidderRequest) {
if (syncMethod) {
utils.deepSetValue(req, 'ext.adk_usersync', syncMethod);
}
if (schain) {
utils.deepSetValue(req, 'source.ext.schain', schain);
}
return req;
}

Expand Down
11 changes: 10 additions & 1 deletion test/spec/modules/adkernelBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,22 @@ describe('Adkernel adapter', function () {
cur: 'USD'
};

var sandbox;
beforeEach(function () {
sandbox = sinon.sandbox.create();
});

afterEach(function () {
sandbox.restore();
});

function buildBidderRequest(url = 'https://example.com/index.html', params = {}) {
return Object.assign({}, params, {refererInfo: {referer: url, reachedTop: true}, timeout: 3000, bidderCode: 'adkernel'});
}
const DEFAULT_BIDDER_REQUEST = buildBidderRequest();

function buildRequest(bidRequests, bidderRequest = DEFAULT_BIDDER_REQUEST, dnt = true) {
let dntmock = sinon.stub(utils, 'getDNT').callsFake(() => dnt);
let dntmock = sandbox.stub(utils, 'getDNT').callsFake(() => dnt);
let pbRequests = spec.buildRequests(bidRequests, bidderRequest);
dntmock.restore();
let rtbRequests = pbRequests.map(r => JSON.parse(r.data));
Expand Down