diff --git a/adapters.json b/adapters.json index 44e70d432b2..8e31b290afb 100644 --- a/adapters.json +++ b/adapters.json @@ -142,5 +142,10 @@ "rhythmone": { "supportedMediaTypes": ["video"] } + }, + { + "admixer": { + "supportedMediaTypes": ["video"] + } } ] diff --git a/src/adapters/admixer.js b/src/adapters/admixer.js index 944aed276ce..24cf81bf9e9 100644 --- a/src/adapters/admixer.js +++ b/src/adapters/admixer.js @@ -10,6 +10,7 @@ var utils = require('../utils.js'); */ var AdmixerAdapter = function AdmixerAdapter() { var invUrl = '//inv-nets.admixer.net/prebid.aspx'; + var invVastUrl = '//inv-nets.admixer.net/videoprebid.aspx'; function _callBids(data) { var bids = data.bids || []; @@ -21,7 +22,16 @@ var AdmixerAdapter = function AdmixerAdapter() { 'callback_uid': bid.placementCode }; if (params.zone) { - _requestBid(invUrl, params); + if (bid.mediaType === 'video') { + var videoParams = {}; + if (typeof bid.video === 'object') { + Object.assign(videoParams, bid.video); + } + Object.assign(videoParams, params); + _requestBid(invVastUrl, params); + } else { + _requestBid(invUrl, params); + } } else { var bidObject = bidfactory.createBid(2); bidObject.bidderCode = 'admixer'; @@ -48,7 +58,13 @@ var AdmixerAdapter = function AdmixerAdapter() { bidObject = bidfactory.createBid(1); bidObject.bidderCode = 'admixer'; bidObject.cpm = bid.cpm; - bidObject.ad = bid.ad; + if (bid.vastUrl) { + bidObject.mediaType = 'video'; + bidObject.vastUrl = bid.vastUrl; + bidObject.descriptionUrl = bid.vastUrl; + } else { + bidObject.ad = bid.ad; + } bidObject.width = bid.width; bidObject.height = bid.height; } else { diff --git a/test/spec/adapters/admixer_spec.js b/test/spec/adapters/admixer_spec.js index 79174390b62..45f18ce7abc 100644 --- a/test/spec/adapters/admixer_spec.js +++ b/test/spec/adapters/admixer_spec.js @@ -39,6 +39,54 @@ describe('Admixer adapter', function () { } ] }; + var validVideoData_1 = { + bids: [ + { + mediaType: 'video', + bidder: 'admixer', + bidId: 'bid_id', + params: {zone: 'zone_id'}, + placementCode: 'ad-unit-1', + sizes: [[300, 250], [300, 600]] + } + ] + }; + var validVideoData_2 = { + bids: [ + { + mediaType: 'video', + bidder: 'admixer', + bidId: 'bid_id', + params: {zone: 'zone_id'}, + placementCode: 'ad-unit-1', + sizes: [300, 250] + } + ] + }; + var validVideoData_3 = { + bids: [ + { + mediaType: 'video', + bidder: 'admixer', + bidId: 'bid_id', + params: {zone: 'zone_id', video: {skippable: true}}, + placementCode: 'ad-unit-1', + sizes: [300, 250] + } + ] + }; + var invalidVideoData = { + bids: [ + { + mediaType: 'video', + bidder: 'admixer', + bidId: 'bid_id', + params: {}, + placementCode: 'ad-unit-1', + sizes: [[300, 250], [300, 600]] + } + ] + }; var responseWithAd = JSON.stringify({ 'result': { 'cpm': 2.2, @@ -57,13 +105,38 @@ describe('Admixer adapter', function () { }, 'callback_uid': 'ad-unit-1' }); + var responseWithVideoAd = JSON.stringify({ + 'result': { + 'cpm': 2.2, + 'vastUrl': 'http://inv-nets.admixer.net/vastxml.aspx?req=9d651544-daf4-48ed-ae0c-38a60a4e1920&vk=e914f026449e49aeb6eea07b9642a2ce', + 'width': 300, + 'height': 250 + }, + 'callback_uid': 'ad-unit-1' + }); + var responseWithoutVideoAd = JSON.stringify({ + 'result': { + 'cpm': 0, + 'vastUrl': '', + 'width': 0, + 'height': 0 + }, + 'callback_uid': 'ad-unit-1' + }); var responseEmpty = ''; var invUrl = '//inv-nets.admixer.net/prebid.aspx'; + var invVastUrl = '//inv-nets.admixer.net/videoprebid.aspx'; var validJsonParams = { zone: 'zone_id', callback_uid: 'ad-unit-1', sizes: '300x250-300x600' }; + var validJsonVideoParams = { + zone: 'zone_id', + callback_uid: 'ad-unit-1', + sizes: '300x250-300x600', + skippable: true + }; describe('bid request with valid data', function () { var stubAjax; beforeEach(function () { @@ -73,19 +146,32 @@ describe('Admixer adapter', function () { afterEach(function () { stubAjax.restore(); }); - it('bid request should be called. sizes style -> [[],[]]', function () { + it('display: bid request should be called. sizes style -> [[],[]]', function () { Adapter.callBids(validData_1); sinon.assert.calledOnce(stubAjax); }); - it('bid request should be called. sizes style -> []', function () { + it('video: bid request should be called. sizes style -> [[],[]]', function () { + Adapter.callBids(validVideoData_1); + sinon.assert.calledOnce(stubAjax); + }); + it('display: bid request should be called. sizes style -> []', function () { Adapter.callBids(validData_2); sinon.assert.calledOnce(stubAjax); }); - it('ajax params should be matched', function () { + it('video: bid request should be called. sizes style -> []', function () { + Adapter.callBids(validVideoData_2); + sinon.assert.calledOnce(stubAjax); + }); + it('display: ajax params should be matched', function () { Adapter.callBids(validData_1); sinon.assert.calledWith(stubAjax, sinon.match(invUrl, function () { }, validJsonParams, {method: 'GET'})); }); + it('video: ajax params should be matched', function () { + Adapter.callBids(validVideoData_3); + sinon.assert.calledWith(stubAjax, sinon.match(invVastUrl, function () { + }, validJsonVideoParams, {method: 'GET'})); + }); }); describe('bid request with invalid data', function () { var addBidResponse, stubAjax; @@ -98,15 +184,24 @@ describe('Admixer adapter', function () { addBidResponse.restore(); stubAjax.restore(); }); - it('ajax shouldn\'t be called', function () { + it('display: ajax shouldn\'t be called', function () { Adapter.callBids(invalidData); sinon.assert.notCalled(stubAjax); }); - it('bidmanager.addBidResponse status code must to be equal "' + CONSTANTS.STATUS.NO_BID + '"', function () { + it('video: ajax shouldn\'t be called', function () { + Adapter.callBids(invalidVideoData); + sinon.assert.notCalled(stubAjax); + }); + it('display: bidmanager.addBidResponse status code must to be equal "' + CONSTANTS.STATUS.NO_BID + '"', function () { Adapter.callBids(invalidData); expect(addBidResponse.firstCall.args[1].getStatusCode()).to.equal(CONSTANTS.STATUS.NO_BID); expect(addBidResponse.firstCall.args[1].bidderCode).to.equal('admixer'); }); + it('video: bidmanager.addBidResponse status code must to be equal "' + CONSTANTS.STATUS.NO_BID + '"', function () { + Adapter.callBids(invalidVideoData); + expect(addBidResponse.firstCall.args[1].getStatusCode()).to.equal(CONSTANTS.STATUS.NO_BID); + expect(addBidResponse.firstCall.args[1].bidderCode).to.equal('admixer'); + }); }); describe('bid response', function () { var addBidResponse; @@ -116,23 +211,35 @@ describe('Admixer adapter', function () { afterEach(function () { addBidResponse.restore(); }); - it('response with ad. bidmanager.addBidResponse status code must to be equal "' + CONSTANTS.STATUS.GOOD + '"', function () { + it('display: response with ad. bidmanager.addBidResponse status code must to be equal "' + CONSTANTS.STATUS.GOOD + '"', function () { Adapter.responseCallback(responseWithAd); var arg = addBidResponse.firstCall.args[1]; expect(arg.getStatusCode()).to.equal(CONSTANTS.STATUS.GOOD); expect(arg.bidderCode).to.equal('admixer'); }); - it('response without ad. bidmanager.addBidResponse status code must to be equal "' + CONSTANTS.STATUS.NO_BID, function () { + it('video: response with ad. bidmanager.addBidResponse status code must to be equal "' + CONSTANTS.STATUS.GOOD + '"', function () { + Adapter.responseCallback(responseWithVideoAd); + var arg = addBidResponse.firstCall.args[1]; + expect(arg.getStatusCode()).to.equal(CONSTANTS.STATUS.GOOD); + expect(arg.bidderCode).to.equal('admixer'); + }); + it('display: response without ad. bidmanager.addBidResponse status code must to be equal "' + CONSTANTS.STATUS.NO_BID, function () { Adapter.responseCallback(responseWithoutAd); var arg = addBidResponse.firstCall.args[1]; expect(arg.getStatusCode()).to.equal(CONSTANTS.STATUS.NO_BID); expect(arg.bidderCode).to.equal('admixer'); }); - it('response empty. bidmanager.addBidResponse status code must to be equal "' + CONSTANTS.STATUS.NO_BID, function () { + it('video: response without ad. bidmanager.addBidResponse status code must to be equal "' + CONSTANTS.STATUS.NO_BID, function () { + Adapter.responseCallback(responseWithoutVideoAd); + var arg = addBidResponse.firstCall.args[1]; + expect(arg.getStatusCode()).to.equal(CONSTANTS.STATUS.NO_BID); + expect(arg.bidderCode).to.equal('admixer'); + }); + it('display/video: response empty. bidmanager.addBidResponse status code must to be equal "' + CONSTANTS.STATUS.NO_BID, function () { Adapter.responseCallback(responseEmpty); var arg = addBidResponse.firstCall.args[1]; expect(arg.getStatusCode()).to.equal(CONSTANTS.STATUS.NO_BID); expect(arg.bidderCode).to.equal('admixer'); - }) + }); }); });