Skip to content

Commit

Permalink
Add skip params to Beachfront adapter (#5847)
Browse files Browse the repository at this point in the history
* feat: add skip params and standard params to video bid request

* refactor: add props to exclude list

* refactor: bump adapter version

Co-authored-by: John Salis <[email protected]>
  • Loading branch information
jsalis and John Salis authored Nov 2, 2020
1 parent 640a3cd commit 78d5117
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
23 changes: 15 additions & 8 deletions modules/beachfrontBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { VIDEO, BANNER } from '../src/mediaTypes.js';
import find from 'core-js-pure/features/array/find.js';
import includes from 'core-js-pure/features/array/includes.js';

const ADAPTER_VERSION = '1.11';
const ADAPTER_VERSION = '1.12';
const ADAPTER_NAME = 'BFIO_PREBID';
const OUTSTREAM = 'outstream';

export const VIDEO_ENDPOINT = 'https://reachms.bfmio.com/bid.json?exchange_id=';
export const BANNER_ENDPOINT = 'https://display.bfmio.com/prebid_display';
export const OUTSTREAM_SRC = 'https://player-cdn.beachfrontmedia.com/playerapi/loader/outstream.js';

export const VIDEO_TARGETING = ['mimes', 'playbackmethod', 'maxduration', 'placement'];
export const VIDEO_TARGETING = ['mimes', 'playbackmethod', 'maxduration', 'placement', 'skip', 'skipmin', 'skipafter'];
export const DEFAULT_MIMES = ['video/mp4', 'application/javascript'];

let appId = '';
Expand Down Expand Up @@ -258,12 +258,19 @@ function getTopWindowReferrer() {
}

function getVideoTargetingParams(bid) {
return Object.keys(Object(bid.params.video))
.filter(param => includes(VIDEO_TARGETING, param))
.reduce((obj, param) => {
obj[ param ] = bid.params.video[ param ];
return obj;
}, {});
const result = {};
const excludeProps = ['playerSize', 'context', 'w', 'h'];
Object.keys(Object(bid.mediaTypes.video))
.filter(key => !includes(excludeProps, key))
.forEach(key => {
result[ key ] = bid.mediaTypes.video[ key ];
});
Object.keys(Object(bid.params.video))
.filter(key => includes(VIDEO_TARGETING, key))
.forEach(key => {
result[ key ] = bid.params.video[ key ];
});
return result;
}

function createVideoRequestData(bid, bidderRequest) {
Expand Down
24 changes: 20 additions & 4 deletions test/spec/modules/beachfrontBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,33 @@ describe('BeachfrontAdapter', function () {
expect(data.imp[0].video).to.deep.contain({ w: width, h: height });
});

it('must override video targeting params', function () {
it('must set video params from the standard object', function () {
const bidRequest = bidRequests[0];
const mimes = ['video/webm'];
const playbackmethod = 2;
const maxduration = 30;
const placement = 4;
bidRequest.mediaTypes = { video: {} };
bidRequest.params.video = { mimes, playbackmethod, maxduration, placement };
const skip = 1;
bidRequest.mediaTypes = {
video: { mimes, playbackmethod, maxduration, placement, skip }
};
const requests = spec.buildRequests([ bidRequest ]);
const data = requests[0].data;
expect(data.imp[0].video).to.deep.contain({ mimes, playbackmethod, maxduration, placement, skip });
});

it('must override video params from the bidder object', function () {
const bidRequest = bidRequests[0];
const mimes = ['video/webm'];
const playbackmethod = 2;
const maxduration = 30;
const placement = 4;
const skip = 1;
bidRequest.mediaTypes = { video: { placement: 3, skip: 0 } };
bidRequest.params.video = { mimes, playbackmethod, maxduration, placement, skip };
const requests = spec.buildRequests([ bidRequest ]);
const data = requests[0].data;
expect(data.imp[0].video).to.deep.contain({ mimes, playbackmethod, maxduration, placement });
expect(data.imp[0].video).to.deep.contain({ mimes, playbackmethod, maxduration, placement, skip });
});

it('must add US privacy data to the request', function () {
Expand Down

0 comments on commit 78d5117

Please sign in to comment.