From aa72e2520c3994e979fab5966302e4c123d50687 Mon Sep 17 00:00:00 2001 From: Anton Baranov Date: Wed, 11 Aug 2021 13:02:36 -0700 Subject: [PATCH] Multiple changes added * Video request schain support * Optional device.ip param support * gpid support added --- modules/yieldmoBidAdapter.js | 24 +++++++++-- test/spec/modules/yieldmoBidAdapter_spec.js | 45 +++++++++++++++++++-- 2 files changed, 62 insertions(+), 7 deletions(-) diff --git a/modules/yieldmoBidAdapter.js b/modules/yieldmoBidAdapter.js index 654e7236210..a959ab92b61 100644 --- a/modules/yieldmoBidAdapter.js +++ b/modules/yieldmoBidAdapter.js @@ -182,6 +182,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, @@ -196,6 +197,9 @@ function addPlacement(request) { placementInfo.bidFloor = bidfloor; } } + if (gpid) { + placementInfo.gpid = gpid; + } return JSON.stringify(placementInfo); } @@ -315,12 +319,13 @@ 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: { @@ -329,6 +334,10 @@ function openRtbRequest(bidRequests, bidderRequest) { ats_envelope: bidRequests[0].params.lr_env, }; + if (schain) { + openRtbRequest.schain = schain; + } + populateOpenRtbGdpr(openRtbRequest, bidderRequest); return openRtbRequest; @@ -339,6 +348,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, @@ -372,6 +382,9 @@ function openRtbImpression(bidRequest) { imp.video.startdelay = DEFAULT_START_DELAY; imp.video.playbackmethod = [ DEFAULT_PLAYBACK_METHOD ]; } + if (gpid) { + imp.ext.gpid = gpid; + } return imp; } @@ -433,11 +446,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; } /** diff --git a/test/spec/modules/yieldmoBidAdapter_spec.js b/test/spec/modules/yieldmoBidAdapter_spec.js index 378c5d89113..f96ec5e32a3 100644 --- a/test/spec/modules/yieldmoBidAdapter_spec.js +++ b/test/spec/modules/yieldmoBidAdapter_spec.js @@ -328,6 +328,23 @@ describe('YieldmoAdapter', function () { localWindow.document.title = originalTitle; }); + + it('should add ats_envelope to banner bid request', function() { + const envelope = 'test_envelope'; + const requests = build([mockBannerBid({}, { lr_env: envelope })]); + + expect(requests[0].data.ats_envelope).to.equal(envelope); + }); + + 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 () { @@ -439,11 +456,31 @@ describe('YieldmoAdapter', function () { expect(requests[0].data.ats_envelope).to.equal(envelope); }); - it('should add ats_envelope to banner bid request', function() { - const envelope = 'test_envelope'; - const requests = build([mockBannerBid({}, { lr_env: envelope })]); + 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); + }); - expect(requests[0].data.ats_envelope).to.equal(envelope); + 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); }); }); });