Skip to content
Open
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
24 changes: 21 additions & 3 deletions modules/yieldmoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ function hasVideoMediaType(bidRequest) {
* @param request bid request
*/
function addPlacement(request) {
const gpid = utils.deepAccess(request, 'ortb2Imp.ext.data.pbadslot');
const placementInfo = {
placement_id: request.adUnitCode,
callback_id: request.bidId,
Expand All @@ -193,6 +194,9 @@ function addPlacement(request) {
placementInfo.bidFloor = bidfloor;
}
}
if (gpid) {
placementInfo.gpid = gpid;
}
return JSON.stringify(placementInfo);
}

Expand Down Expand Up @@ -312,19 +316,24 @@ function getId(request, idType) {
* @return Object OpenRTB request object
*/
function openRtbRequest(bidRequests, bidderRequest) {
const schain = bidRequests[0].schain;
let openRtbRequest = {
id: bidRequests[0].bidderRequestId,
at: 1,
imp: bidRequests.map(bidRequest => openRtbImpression(bidRequest)),
site: openRtbSite(bidRequests[0], bidderRequest),
device: openRtbDevice(),
device: openRtbDevice(bidRequests[0]),
badv: bidRequests[0].params.badv || [],
bcat: bidRequests[0].params.bcat || [],
ext: {
prebid: '$prebid.version$',
}
};

if (schain) {
openRtbRequest.schain = schain;
}

populateOpenRtbGdpr(openRtbRequest, bidderRequest);

return openRtbRequest;
Expand All @@ -335,6 +344,7 @@ function openRtbRequest(bidRequests, bidderRequest) {
* @return Object OpenRTB's 'imp' (impression) object
*/
function openRtbImpression(bidRequest) {
const gpid = utils.deepAccess(bidRequest, 'ortb2Imp.ext.data.pbadslot');
const size = extractPlayerSize(bidRequest);
const imp = {
id: bidRequest.bidId,
Expand Down Expand Up @@ -368,6 +378,9 @@ function openRtbImpression(bidRequest) {
imp.video.startdelay = DEFAULT_START_DELAY;
imp.video.playbackmethod = [ DEFAULT_PLAYBACK_METHOD ];
}
if (gpid) {
imp.ext.gpid = gpid;
}
return imp;
}

Expand Down Expand Up @@ -429,11 +442,16 @@ function openRtbSite(bidRequest, bidderRequest) {
/**
* @return Object OpenRTB's 'device' object
*/
function openRtbDevice() {
return {
function openRtbDevice(bidRequest) {
const ip = utils.deepAccess(bidRequest, 'params.device.ip');
const deviceObj = {
ua: navigator.userAgent,
language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage),
};
if (ip) {
deviceObj.ip = ip;
}
return deviceObj;
}

/**
Expand Down
37 changes: 37 additions & 0 deletions test/spec/modules/yieldmoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,16 @@ describe('YieldmoAdapter', function () {

localWindow.document.title = originalTitle;
});

it('should add gpid to the banner bid request', function () {
let bidArray = [mockBannerBid({
ortb2Imp: {
ext: { data: { pbadslot: '/6355419/Travel/Europe/France/Paris' } },
}
})];
let placementInfo = buildAndGetPlacementInfo(bidArray);
expect(placementInfo).to.include('"gpid":"/6355419/Travel/Europe/France/Paris"');
});
});

describe('Instream video:', function () {
Expand Down Expand Up @@ -431,6 +441,33 @@ describe('YieldmoAdapter', function () {
const requests = build([mockVideoBid()]);
expect(requests[0].data.imp[0].bidfloor).to.equal(0);
});

it('should add schain if it is in the bidRequest', () => {
const schain = {
ver: '1.0',
complete: 1,
nodes: [{
asi: 'indirectseller.com',
sid: '00001',
hp: 1
}],
};
expect(buildAndGetData([mockVideoBid({schain})]).schain).to.deep.equal(schain);
});

it('should add ip to the video bidRequest', () => {
const device = {
ip: '111.222.333.444'
};
expect(buildAndGetData([mockVideoBid(null, {device})]).device.ip).to.be.equal(device.ip);
});

it('should add gpid to the video request', function () {
const ortb2Imp = {
ext: { data: { pbadslot: '/6355419/Travel/Europe/France/Paris' } },
};
expect(buildAndGetData([mockVideoBid({ortb2Imp})]).imp[0].ext.gpid).to.be.equal(ortb2Imp.ext.data.pbadslot);
});
});
});

Expand Down