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

IX Bid Adapter: Adding support for GPT Pre-Auction Module #6861

Merged
merged 1 commit into from
May 28, 2021
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
9 changes: 9 additions & 0 deletions modules/ixBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ function bidToVideoImp(bid) {
return imp;
}

/**
* Converts an incoming PBJS bid to an IX Impression
* @param {object} bid PBJS bid object
* @returns {object} IX impression object
*/
function bidToImp(bid) {
const imp = {};

Expand All @@ -127,6 +132,10 @@ function bidToImp(bid) {
imp.ext.sid = `${bid.params.size[0]}x${bid.params.size[1]}`;
}

const dfpAdUnitCode = utils.deepAccess(bid, 'ortb2Imp.ext.data.adserver.adslot');
if (dfpAdUnitCode) {
imp.ext.dfp_ad_unit_code = dfpAdUnitCode;
}
return imp;
}

Expand Down
26 changes: 26 additions & 0 deletions test/spec/modules/ixBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,32 @@ describe('IndexexchangeAdapter', function () {
expect(query.nf).not.to.exist;
});

it('should send dfp_adunit_code in request if ortb2Imp.ext.data.adserver.adslot exists', function () {
const AD_UNIT_CODE = '/19968336/some-adunit-path';
const validBids = utils.deepClone(DEFAULT_BANNER_VALID_BID);
validBids[0].ortb2Imp = {
ext: {
data: {
adserver: {
name: 'gam',
adslot: AD_UNIT_CODE
}
}
}
};
const requests = spec.buildRequests(validBids, DEFAULT_OPTION);
const { dfp_ad_unit_code } = JSON.parse(requests[0].data.r).imp[0].ext;
expect(dfp_ad_unit_code).to.equal(AD_UNIT_CODE);
});

it('should not send dfp_adunit_code in request if ortb2Imp.ext.data.adserver.adslot does not exists', function () {
const validBids = utils.deepClone(DEFAULT_BANNER_VALID_BID);
const requests = spec.buildRequests(validBids, DEFAULT_OPTION);
const { dfp_ad_unit_code } = JSON.parse(requests[0].data.r).imp[0].ext;

expect(dfp_ad_unit_code).to.not.exist;
});

it('payload should have correct format and value', function () {
const payload = JSON.parse(query.r);
expect(payload.id).to.equal(DEFAULT_BANNER_VALID_BID[0].bidderRequestId);
Expand Down