Skip to content

Commit

Permalink
TTD Bid Adapter: add support for video.plcmt and imp.rwdd (prebid#9762)
Browse files Browse the repository at this point in the history
* Update ttdBidAdapter.js

* Update ttdBidAdapter_spec.js

* Update ttdBidAdapter_spec.js

* Update ttdBidAdapter_spec.js

* Update ttdBidAdapter_spec.js

* Update ttdBidAdapter.js

* Update ttdBidAdapter_spec.js
  • Loading branch information
patmmccann authored and jorgeluisrocha committed May 18, 2023
1 parent 9352fef commit ec08097
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
11 changes: 9 additions & 2 deletions modules/ttdBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,18 @@ function getImpression(bidRequest) {

const gpid = utils.deepAccess(bidRequest, 'ortb2Imp.ext.gpid');
const tid = utils.deepAccess(bidRequest, 'ortb2Imp.ext.tid');
const rwdd = utils.deepAccess(bidRequest, 'ortb2Imp.rwdd');
if (gpid || tid) {
impression.ext = {}
if (gpid) { impression.ext.gpid = gpid }
if (tid) { impression.ext.tid = tid }
}

if (rwdd) {
impression.rwdd = rwdd;
}
const tagid = gpid || bidRequest.params.placementId;
if (tagid) {
impression.tagid = tagid
impression.tagid = tagid;
}

const mediaTypesVideo = utils.deepAccess(bidRequest, 'mediaTypes.video');
Expand Down Expand Up @@ -251,6 +254,7 @@ function video(bid) {
const api = utils.deepAccess(bid, 'mediaTypes.video.api');
const mimes = utils.deepAccess(bid, 'mediaTypes.video.mimes');
const placement = utils.deepAccess(bid, 'mediaTypes.video.placement');
const plcmt = utils.deepAccess(bid, 'mediaTypes.video.plcmt');
const protocols = utils.deepAccess(bid, 'mediaTypes.video.protocols');
const playbackmethod = utils.deepAccess(bid, 'mediaTypes.video.playbackmethod');
const pos = utils.deepAccess(bid, 'mediaTypes.video.pos');
Expand Down Expand Up @@ -286,6 +290,9 @@ function video(bid) {
if (playbackmethod) {
video.playbackmethod = playbackmethod;
}
if (plcmt) {
video.plcmt = plcmt;
}
if (pos) {
video.pos = pos;
}
Expand Down
23 changes: 23 additions & 0 deletions test/spec/modules/ttdBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,21 @@ describe('ttdBidAdapter', function () {
expect(requestBody.imp[0].ext.gpid).to.equal(gpid);
});

it('sends rwdd in imp.rwdd if present', function () {
let clonedBannerRequests = deepClone(baseBannerBidRequests);
const gpid = '/1111/home#header';
const rwdd = 1;
clonedBannerRequests[0].ortb2Imp = {
rwdd: rwdd,
ext: {
gpid: gpid
}
};
const requestBody = testBuildRequests(clonedBannerRequests, baseBidderRequest).data;
expect(requestBody.imp[0].rwdd).to.be.not.null;
expect(requestBody.imp[0].rwdd).to.equal(1);
});

it('sends auction id in source.tid', function () {
const requestBody = testBuildRequests(baseBannerBidRequests, baseBidderRequest).data;
expect(requestBody.source).to.be.not.null;
Expand Down Expand Up @@ -877,6 +892,14 @@ describe('ttdBidAdapter', function () {
const requestBody = testBuildRequests(clonedVideoRequests, baseBidderRequest).data;
expect(requestBody.imp[0].video.placement).to.equal(3);
});

it('sets plcmt correctly if sent', function () {
let clonedVideoRequests = deepClone(baseVideoBidRequests);
clonedVideoRequests[0].mediaTypes.video.plcmt = 3;

const requestBody = testBuildRequests(clonedVideoRequests, baseBidderRequest).data;
expect(requestBody.imp[0].video.plcmt).to.equal(3);
});
});

describe('interpretResponse-empty', function () {
Expand Down

0 comments on commit ec08097

Please sign in to comment.