Skip to content

Commit

Permalink
CadentApertureMX Bid Adapter : update gpid support (#11557)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Denton <[email protected]>
  • Loading branch information
EMXDigital and Michael Denton committed May 23, 2024
1 parent 1ebf1a6 commit b1d5237
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
11 changes: 6 additions & 5 deletions modules/cadentApertureMXBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,13 @@ export const spec = {
};

// adding gpid support
let gpid = deepAccess(bid, 'ortb2Imp.ext.data.adserver.adslot');
if (!gpid) {
gpid = deepAccess(bid, 'ortb2Imp.ext.data.pbadslot');
}
let gpid =
deepAccess(bid, 'ortb2Imp.ext.gpid') ||
deepAccess(bid, 'ortb2Imp.ext.data.adserver.adslot') ||
deepAccess(bid, 'ortb2Imp.ext.data.pbadslot');

if (gpid) {
data.ext = {gpid: gpid.toString()};
data.ext = { gpid: gpid.toString() };
}
let typeSpecifics = isVideo ? { video: cadentAdapter.buildVideo(bid) } : { banner: cadentAdapter.buildBanner(bid) };
let bidfloorObj = bidfloor > 0 ? { bidfloor, bidfloorcur: DEFAULT_CUR } : {};
Expand Down
21 changes: 19 additions & 2 deletions test/spec/modules/cadentApertureMXBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,27 @@ describe('cadent_aperture_mx Adapter', function () {
});
});

it('should add gpid to request if present', () => {
it('should add gpid to request if present in ext.gpid', () => {
const gpid = '/12345/my-gpt-tag-0';
let bid = utils.deepClone(bidderRequest.bids[0]);
bid.ortb2Imp = { ext: { gpid, data: { adserver: { adslot: gpid + '1' }, pbadslot: gpid + '2' } } };
let requestWithGPID = spec.buildRequests([bid], bidderRequest);
requestWithGPID = JSON.parse(requestWithGPID.data);
expect(requestWithGPID.imp[0].ext.gpid).to.exist.and.equal(gpid);
});

it('should add gpid to request if present in ext.data.adserver.adslot', () => {
const gpid = '/12345/my-gpt-tag-0';
let bid = utils.deepClone(bidderRequest.bids[0]);
bid.ortb2Imp = { ext: { data: { adserver: { adslot: gpid }, pbadslot: gpid + '1' } } };
let requestWithGPID = spec.buildRequests([bid], bidderRequest);
requestWithGPID = JSON.parse(requestWithGPID.data);
expect(requestWithGPID.imp[0].ext.gpid).to.exist.and.equal(gpid);
});

it('should add gpid to request if present in ext.data.pbadslot', () => {
const gpid = '/12345/my-gpt-tag-0';
let bid = utils.deepClone(bidderRequest.bids[0]);
bid.ortb2Imp = { ext: { data: { adserver: { adslot: gpid } } } };
bid.ortb2Imp = { ext: { data: { pbadslot: gpid } } };
let requestWithGPID = spec.buildRequests([bid], bidderRequest);
requestWithGPID = JSON.parse(requestWithGPID.data);
Expand Down

0 comments on commit b1d5237

Please sign in to comment.