Skip to content

Commit efe6cf0

Browse files
matthieularere-msqjorgeluisrocha
authored andcommitted
Mediasquare Bid Adapter: add video renderer + change with floors (prebid#9079)
1 parent 682ac8a commit efe6cf0

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

modules/mediasquareBidAdapter.js

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ import {config} from '../src/config.js';
33
import {registerBidder} from '../src/adapters/bidderFactory.js';
44
import {BANNER, NATIVE, VIDEO} from '../src/mediaTypes.js';
55
import { convertOrtbRequestToProprietaryNative } from '../src/native.js';
6+
import {Renderer} from '../src/Renderer.js';
67

78
const BIDDER_CODE = 'mediasquare';
89
const BIDDER_URL_PROD = 'https://pbs-front.mediasquare.fr/'
910
const BIDDER_URL_TEST = 'https://bidder-test.mediasquare.fr/'
1011
const BIDDER_ENDPOINT_AUCTION = 'msq_prebid';
1112
const BIDDER_ENDPOINT_WINNING = 'winning';
1213

14+
const OUTSTREAM_RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js';
15+
1316
export const spec = {
1417
code: BIDDER_CODE,
1518
gvlid: 791,
@@ -40,11 +43,15 @@ export const spec = {
4043
const test = config.getConfig('debug') ? 1 : 0;
4144
let adunitValue = null;
4245
Object.keys(validBidRequests).forEach(key => {
46+
floor = {};
4347
adunitValue = validBidRequests[key];
4448
if (typeof adunitValue.getFloor === 'function') {
45-
floor = adunitValue.getFloor({currency: 'EUR', mediaType: '*', size: '*'});
46-
} else {
47-
floor = {};
49+
if (Array.isArray(adunitValue.sizes)) {
50+
adunitValue.sizes.forEach(value => {
51+
let tmpFloor = adunitValue.getFloor({currency: 'USD', mediaType: '*', size: value});
52+
if (tmpFloor != {}) { floor[value.join('x')] = tmpFloor; }
53+
});
54+
}
4855
}
4956
codes.push({
5057
owner: adunitValue.params.owner,
@@ -132,6 +139,7 @@ export const spec = {
132139
if ('url' in value['video']) { bidResponse['vastUrl'] = value['video']['url'] }
133140
if ('xml' in value['video']) { bidResponse['vastXml'] = value['video']['xml'] }
134141
bidResponse['mediaType'] = 'video';
142+
bidResponse['renderer'] = createRenderer(value, OUTSTREAM_RENDERER_URL);
135143
}
136144
if (value.hasOwnProperty('deal_id')) { bidResponse['dealId'] = value['deal_id']; }
137145
bidResponses.push(bidResponse);
@@ -182,4 +190,35 @@ export const spec = {
182190
}
183191

184192
}
193+
194+
function outstreamRender(bid) {
195+
bid.renderer.push(() => {
196+
window.ANOutstreamVideo.renderAd({
197+
sizes: [bid.width, bid.height],
198+
targetId: bid.adUnitCode,
199+
adResponse: bid.adResponse,
200+
rendererOptions: {
201+
showBigPlayButton: false,
202+
showProgressBar: 'bar',
203+
showVolume: false,
204+
allowFullscreen: true,
205+
skippable: false,
206+
content: bid.vastXml
207+
}
208+
});
209+
});
210+
}
211+
212+
function createRenderer(bid, url) {
213+
const renderer = Renderer.install({
214+
id: bid.bidId,
215+
url: url,
216+
loaded: false,
217+
adUnitCode: bid.adUnitCode,
218+
targetId: bid.adUnitCode
219+
});
220+
renderer.setRender(outstreamRender);
221+
return renderer;
222+
}
223+
185224
registerBidder(spec);

test/spec/modules/mediasquareBidAdapter_spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ describe('MediaSquare bid adapter tests', function () {
7878
owner: 'test',
7979
code: 'publishername_atf_desktop_rg_pave'
8080
},
81-
getFloor: function (a) { return { currency: 'EUR', floor: 1.0 }; },
81+
sizes: [[300, 250]],
82+
getFloor: function (a) { return { currency: 'USD', floor: 1.0 }; },
8283
}];
8384
var BID_RESPONSE = {'body': {
8485
'responses': [{
@@ -142,7 +143,7 @@ describe('MediaSquare bid adapter tests', function () {
142143
const requestfloor = spec.buildRequests(FLOORS_PARAMS, DEFAULT_OPTIONS);
143144
const responsefloor = JSON.parse(requestfloor.data);
144145
expect(responsefloor.codes[0]).to.have.property('floor').exist;
145-
expect(responsefloor.codes[0].floor).to.have.property('floor').and.to.equal(1.0);
146+
expect(responsefloor.codes[0].floor).to.have.property('300x250').and.to.have.property('floor').and.to.equal(1);
146147
});
147148

148149
it('Verify parse response', function () {
@@ -239,6 +240,7 @@ describe('MediaSquare bid adapter tests', function () {
239240
const bid = response[0];
240241
expect(bid).to.have.property('vastXml');
241242
expect(bid).to.have.property('vastUrl');
243+
expect(bid).to.have.property('renderer');
242244
delete BID_RESPONSE.body.responses[0].video;
243245
});
244246
});

0 commit comments

Comments
 (0)