diff --git a/modules/beachfrontBidAdapter.js b/modules/beachfrontBidAdapter.js index ee46195b766..fc191e306d4 100644 --- a/modules/beachfrontBidAdapter.js +++ b/modules/beachfrontBidAdapter.js @@ -1,14 +1,17 @@ import * as utils from 'src/utils'; import { registerBidder } from 'src/adapters/bidderFactory'; +import { Renderer } from 'src/Renderer'; import { VIDEO, BANNER } from 'src/mediaTypes'; import find from 'core-js/library/fn/array/find'; import includes from 'core-js/library/fn/array/includes'; const ADAPTER_VERSION = '1.1'; const ADAPTER_NAME = 'BFIO_PREBID'; +const OUTSTREAM = 'outstream'; export const VIDEO_ENDPOINT = '//reachms.bfmio.com/bid.json?exchange_id='; export const BANNER_ENDPOINT = '//display.bfmio.com/prebid_display'; +export const OUTSTREAM_SRC = '//player-cdn.beachfrontmedia.com/playerapi/loader/outstream.js'; export const VIDEO_TARGETING = ['mimes']; export const DEFAULT_MIMES = ['video/mp4', 'application/javascript']; @@ -53,6 +56,7 @@ export const spec = { return []; } let size = getFirstSize(bidRequest); + let context = utils.deepAccess(bidRequest, 'mediaTypes.video.context'); return { requestId: bidRequest.bidId, bidderCode: spec.code, @@ -61,6 +65,7 @@ export const spec = { width: size.w, height: size.h, creativeId: response.cmpId, + renderer: context === OUTSTREAM ? createRenderer(bidRequest) : null, mediaType: VIDEO, currency: 'USD', netRevenue: true, @@ -91,6 +96,30 @@ export const spec = { } }; +function createRenderer(bidRequest) { + const renderer = Renderer.install({ + id: bidRequest.bidId, + url: OUTSTREAM_SRC, + loaded: false + }); + + renderer.setRender(outstreamRender); + + return renderer; +} + +function outstreamRender(bid) { + bid.renderer.push(() => { + window.Beachfront.Player(bid.adUnitCode, { + ad_tag_url: bid.vastUrl, + width: bid.width, + height: bid.height, + expand_in_view: false, + collapse_on_complete: true + }); + }); +} + function getSizes(bid) { return utils.parseSizesInput(bid.sizes).map(size => { let [ width, height ] = size.split('x'); diff --git a/test/spec/modules/beachfrontBidAdapter_spec.js b/test/spec/modules/beachfrontBidAdapter_spec.js index 9ca375d7e20..ddd93f8406d 100644 --- a/test/spec/modules/beachfrontBidAdapter_spec.js +++ b/test/spec/modules/beachfrontBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec, VIDEO_ENDPOINT, BANNER_ENDPOINT, DEFAULT_MIMES } from 'modules/beachfrontBidAdapter'; +import { spec, VIDEO_ENDPOINT, BANNER_ENDPOINT, OUTSTREAM_SRC, DEFAULT_MIMES } from 'modules/beachfrontBidAdapter'; import * as utils from 'src/utils'; describe('BeachfrontAdapter', () => { @@ -267,12 +267,28 @@ describe('BeachfrontAdapter', () => { vastUrl: serverResponse.url, width: width, height: height, + renderer: null, mediaType: 'video', currency: 'USD', netRevenue: true, ttl: 300 }); }); + + it('should return a renderer for outstream video bids', () => { + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { video: { context: 'outstream' } }; + const serverResponse = { + bidPrice: 5.00, + url: 'http://reachms.bfmio.com/getmu?aid=bid:19c4a196-fb21-4c81-9a1a-ecc5437a39da', + cmpId: '123abc' + }; + const bidResponse = spec.interpretResponse({ body: serverResponse }, { bidRequest }); + expect(bidResponse.renderer).to.deep.contain({ + id: bidRequest.bidId, + url: OUTSTREAM_SRC + }); + }); }); describe('for banner bids', () => {