Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add skip params to Beachfront adapter #5847

Merged
merged 3 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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