Skip to content

Commit

Permalink
Adkernel: schain supported (#5558)
Browse files Browse the repository at this point in the history
  • Loading branch information
ckbo3hrk authored Aug 7, 2020
1 parent 46eb769 commit 54ee857
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
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

0 comments on commit 54ee857

Please sign in to comment.