diff --git a/modules/synacormediaBidAdapter.js b/modules/synacormediaBidAdapter.js index 6608107c93f..55a91d87448 100644 --- a/modules/synacormediaBidAdapter.js +++ b/modules/synacormediaBidAdapter.js @@ -24,7 +24,7 @@ export const spec = { bid.mediaTypes.hasOwnProperty('video'); }, isBidRequestValid: function(bid) { - const hasRequiredParams = bid && bid.params && bid.params.hasOwnProperty('placementId') && bid.params.hasOwnProperty('seatId'); + const hasRequiredParams = bid && bid.params && (bid.params.hasOwnProperty('placementId') || bid.params.hasOwnProperty('tagId')) && bid.params.hasOwnProperty('seatId'); const hasAdSizes = bid && getAdUnitSizes(bid).filter(size => BLOCKED_AD_SIZES.indexOf(size.join('x')) === -1).length > 0 return !!(hasRequiredParams && hasAdSizes); }, @@ -61,7 +61,7 @@ export const spec = { } else { seatId = bid.params.seatId; } - const placementId = bid.params.placementId; + const tagIdOrplacementId = bid.params.tagId || bid.params.placementId; const bidFloor = bid.params.bidfloor ? parseFloat(bid.params.bidfloor) : null; if (isNaN(bidFloor)) { logWarn(`Synacormedia: there is an invalid bid floor: ${bid.params.bidfloor}`); @@ -77,9 +77,9 @@ export const spec = { let imps = []; if (videoOrBannerKey === 'banner') { - imps = this.buildBannerImpressions(adSizes, bid, placementId, pos, bidFloor, videoOrBannerKey); + imps = this.buildBannerImpressions(adSizes, bid, tagIdOrplacementId, pos, bidFloor, videoOrBannerKey); } else if (videoOrBannerKey === 'video') { - imps = this.buildVideoImpressions(adSizes, bid, placementId, pos, bidFloor, videoOrBannerKey); + imps = this.buildVideoImpressions(adSizes, bid, tagIdOrplacementId, pos, bidFloor, videoOrBannerKey); } if (imps.length > 0) { imps.forEach(i => openRtbBidRequest.imp.push(i)); @@ -104,7 +104,7 @@ export const spec = { } }, - buildBannerImpressions: function(adSizes, bid, placementId, pos, bidFloor, videoOrBannerKey) { + buildBannerImpressions: function (adSizes, bid, tagIdOrPlacementId, pos, bidFloor, videoOrBannerKey) { let format = []; let imps = []; adSizes.forEach((size, i) => { @@ -125,7 +125,7 @@ export const spec = { format, pos }, - tagid: placementId, + tagid: tagIdOrPlacementId, }; if (bidFloor !== null && !isNaN(bidFloor)) { imp.bidfloor = bidFloor; @@ -135,7 +135,7 @@ export const spec = { return imps; }, - buildVideoImpressions: function(adSizes, bid, placementId, pos, bidFloor, videoOrBannerKey) { + buildVideoImpressions: function(adSizes, bid, tagIdOrPlacementId, pos, bidFloor, videoOrBannerKey) { let imps = []; adSizes.forEach((size, i) => { if (!size || size.length != 2) { @@ -145,7 +145,7 @@ export const spec = { const size1 = size[1]; const imp = { id: `${videoOrBannerKey.substring(0, 1)}${bid.bidId}-${size0}x${size1}`, - tagid: placementId + tagid: tagIdOrPlacementId }; if (bidFloor !== null && !isNaN(bidFloor)) { imp.bidfloor = bidFloor; diff --git a/modules/synacormediaBidAdapter.md b/modules/synacormediaBidAdapter.md index fd71f07b3a3..523c66fd1d9 100644 --- a/modules/synacormediaBidAdapter.md +++ b/modules/synacormediaBidAdapter.md @@ -33,7 +33,7 @@ https://track.technoratimedia.com/openrtb/tags?ID=%%PATTERN:hb_cache_id_synacorm bidder: "synacormedia", params: { seatId: "prebid", - placementId: "demo1", + tagId: "demo1", bidfloor: 0.10, pos: 1 } @@ -52,7 +52,7 @@ https://track.technoratimedia.com/openrtb/tags?ID=%%PATTERN:hb_cache_id_synacorm bidder: "synacormedia", params: { seatId: "prebid", - placementId: "demo1", + tagId: "demo1", bidfloor: 0.20, pos: 1, video: { diff --git a/test/spec/modules/synacormediaBidAdapter_spec.js b/test/spec/modules/synacormediaBidAdapter_spec.js index dd40e634723..5ec8700ce89 100644 --- a/test/spec/modules/synacormediaBidAdapter_spec.js +++ b/test/spec/modules/synacormediaBidAdapter_spec.js @@ -11,12 +11,19 @@ describe('synacormediaBidAdapter ', function () { sizes: [300, 250], params: { seatId: 'prebid', - placementId: '1234' + tagId: '1234' } }; }); it('should return true when params placementId and seatId are truthy', function () { + bid.params.placementId = bid.params.tagId; + delete bid.params.tagId; + assert(spec.isBidRequestValid(bid)); + }); + + it('should return true when params tagId and seatId are truthy', function () { + delete bid.params.placementId; assert(spec.isBidRequestValid(bid)); }); @@ -35,8 +42,9 @@ describe('synacormediaBidAdapter ', function () { assert.isFalse(spec.isBidRequestValid(bid)); }); - it('should return false when placementId param is missing', function () { + it('should return false when both placementId param and tagId param are missing', function () { delete bid.params.placementId; + delete bid.params.tagId; assert.isFalse(spec.isBidRequestValid(bid)); }); @@ -53,7 +61,7 @@ describe('synacormediaBidAdapter ', function () { sizes: [[300, 250], [300, 600]], params: { seatId: 'prebid', - placementId: '1234', + tagId: '1234', bidfloor: '0.50' } }; @@ -63,7 +71,7 @@ describe('synacormediaBidAdapter ', function () { sizes: [[300, 250], [300, 600]], params: { seatId: 'prebid', - placementId: '1234', + tagId: '1234', bidfloor: '0.50' }, mediaTypes: { @@ -84,7 +92,7 @@ describe('synacormediaBidAdapter ', function () { sizes: [[640, 480]], params: { seatId: 'prebid', - placementId: '1234', + tagId: '1234', bidfloor: '0.50' }, mediaTypes: { @@ -110,7 +118,7 @@ describe('synacormediaBidAdapter ', function () { bidder: 'synacormedia', params: { seatId: 'prebid', - placementId: '1234', + tagId: '1234', video: { minduration: 30 } @@ -163,7 +171,7 @@ describe('synacormediaBidAdapter ', function () { sizes: [[300, 250], [300, 600]], params: { seatId: 'prebid', - placementId: '1234', + tagId: '1234', bidfloor: '0.50' } }; @@ -230,7 +238,7 @@ describe('synacormediaBidAdapter ', function () { sizes: [[300, 600]], params: { seatId: validBidRequest.params.seatId, - placementId: '5678', + tagId: '5678', bidfloor: '0.50' } }; @@ -262,7 +270,7 @@ describe('synacormediaBidAdapter ', function () { sizes: [[300, 250]], params: { seatId: 'somethingelse', - placementId: '5678', + tagId: '5678', bidfloor: '0.50' } }; @@ -295,7 +303,7 @@ describe('synacormediaBidAdapter ', function () { sizes: [[300, 250]], params: { seatId: 'prebid', - placementId: '1234', + tagId: '1234', bidfloor: 'abcd' } }; @@ -327,7 +335,7 @@ describe('synacormediaBidAdapter ', function () { sizes: [[300, 250]], params: { seatId: 'prebid', - placementId: '1234' + tagId: '1234' } }; let req = spec.buildRequests([badFloorBidRequest], bidderRequest); @@ -358,7 +366,7 @@ describe('synacormediaBidAdapter ', function () { sizes: [[300, 250]], params: { seatId: 'prebid', - placementId: '1234', + tagId: '1234', pos: 1 } }; @@ -390,7 +398,7 @@ describe('synacormediaBidAdapter ', function () { sizes: [[300, 250]], params: { seatId: 'prebid', - placementId: '1234', + tagId: '1234', } }; let req = spec.buildRequests([newPosBidRequest], bidderRequest); @@ -425,7 +433,7 @@ describe('synacormediaBidAdapter ', function () { sizes: [], params: { seatId: 'prebid', - placementId: '1234', + tagId: '1234', bidfloor: '0.50' } }; @@ -435,7 +443,7 @@ describe('synacormediaBidAdapter ', function () { sizes: [[300]], params: { seatId: 'prebid', - placementId: '1234', + tagId: '1234', bidfloor: '0.50' } }; @@ -457,7 +465,7 @@ describe('synacormediaBidAdapter ', function () { bidder: 'synacormedia', params: { seatId: 'prebid', - placementId: '1234', + tagId: '1234', video: { minduration: 30, maxduration: 45, @@ -515,7 +523,7 @@ describe('synacormediaBidAdapter ', function () { bidder: 'synacormedia', params: { seatId: 'prebid', - placementId: '1234', + tagId: '1234', video: { minduration: 30, maxduration: 45, @@ -582,12 +590,74 @@ describe('synacormediaBidAdapter ', function () { }) }); + describe('Bid Requests with placementId should be backward compatible ', function () { + let validVideoBidReq = { + bidder: 'synacormedia', + params: { + seatId: 'prebid', + placementId: 'demo1', + pos: 1, + video: {} + }, + renderer: { + url: '../syncOutstreamPlayer.js' + }, + mediaTypes: { + video: { + playerSize: [[300, 250]], + context: 'outstream' + } + }, + adUnitCode: 'div-1', + transactionId: '0869f34e-090b-4b20-84ee-46ff41405a39', + sizes: [[300, 250]], + bidId: '22b3a2268d9f0e', + bidderRequestId: '1d195910597e13', + auctionId: '3375d336-2aea-4ee7-804c-6d26b621ad20', + src: 'client', + bidRequestsCount: 1, + bidderRequestsCount: 1, + bidderWinsCount: 0 + }; + + let validBannerBidRequest = { + bidId: '9876abcd', + sizes: [[300, 250]], + params: { + seatId: 'prebid', + placementId: '1234', + } + }; + + let bidderRequest = { + refererInfo: { + referer: 'http://localhost:9999/' + }, + bidderCode: 'synacormedia', + auctionId: 'f8a75621-d672-4cbb-9275-3db7d74fb110' + }; + + it('should return valid bid request for banner impression', function () { + let req = spec.buildRequests([validBannerBidRequest], bidderRequest); + expect(req).to.have.property('method', 'POST'); + expect(req).to.have.property('url'); + expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + }); + + it('should return valid bid request for video impression', function () { + let req = spec.buildRequests([validVideoBidReq], bidderRequest); + expect(req).to.have.property('method', 'POST'); + expect(req).to.have.property('url'); + expect(req.url).to.contain('//prebid.technoratimedia.com/openrtb/bids/prebid?src=$$REPO_AND_VERSION$$'); + }); + }); + describe('Bid Requests with schain object ', function() { let validBidReq = { bidder: 'synacormedia', params: { seatId: 'prebid', - placementId: 'demo1', + tagId: 'demo1', pos: 1, video: {} }, @@ -634,7 +704,7 @@ describe('synacormediaBidAdapter ', function () { bidder: 'synacormedia', params: { seatId: 'prebid', - placementId: 'demo1', + tagId: 'demo1', pos: 1, video: {} }, @@ -914,8 +984,8 @@ describe('synacormediaBidAdapter ', function () { }); let resp = spec.interpretResponse(serverRespVideo, bidRequest); - sandbox.restore(); - expect(resp[0].videoCacheKey).to.not.exist; + sandbox.restore(); + expect(resp[0].videoCacheKey).to.not.exist; }); it('should use video bid request height and width if not present in response', function () {