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

BetweenBidAdapter: add video support #7594

Merged
merged 4 commits into from
Oct 19, 2021
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
22 changes: 19 additions & 3 deletions modules/betweenBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { getAdUnitSizes, parseSizesInput } from '../src/utils.js';
import { getRefererInfo } from '../src/refererDetection.js';

const BIDDER_CODE = 'between';
const ENDPOINT = 'https://ads.betweendigital.com/adjson?t=prebid';
let ENDPOINT = 'https://ads.betweendigital.com/adjson?t=prebid';
const CODE_TYPES = ['inpage', 'preroll', 'midroll', 'postroll'];

export const spec = {
code: BIDDER_CODE,
aliases: ['btw'],
supportedMediaTypes: ['banner'],
supportedMediaTypes: ['banner', 'video'],
/**
* Determines whether or not the given bid request is valid.
*
Expand All @@ -30,6 +31,8 @@ export const spec = {
const refInfo = getRefererInfo();

validBidRequests.forEach((i) => {
const video = i.mediaTypes && i.mediaTypes.video;

let params = {
eids: getUsersIds(i),
sizes: parseSizesInput(getAdUnitSizes(i)),
Expand All @@ -38,12 +41,21 @@ export const spec = {
tz: getTz(),
fl: getFl(),
rr: getRr(),
s: i.params.s,
s: i.params && i.params.s,
bidid: i.bidId,
transactionid: i.transactionId,
auctionid: i.auctionId
};

if (video) {
params.mediaType = 2;
params.maxd = video.maxd;
params.mind = video.mind;
params.pos = 'atf';
ENDPOINT += '&jst=pvc';
params.codeType = CODE_TYPES.includes(video.codeType) ? video.codeType : 'inpage';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically we still are in the "support IE 11" phase @ChrisHuie

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yah #7619

}

if (i.params.itu !== undefined) {
params.itu = i.params.itu;
}
Expand Down Expand Up @@ -94,12 +106,15 @@ export const spec = {
*/
interpretResponse: function(serverResponse, bidRequest) {
const bidResponses = [];

for (var i = 0; i < serverResponse.body.length; i++) {
let bidResponse = {
requestId: serverResponse.body[i].bidid,
cpm: serverResponse.body[i].cpm || 0,
width: serverResponse.body[i].w,
height: serverResponse.body[i].h,
vastXml: serverResponse.body[i].vastXml,
mediaType: serverResponse.body[i].mediaType,
ttl: serverResponse.body[i].ttl,
creativeId: serverResponse.body[i].creativeid,
currency: serverResponse.body[i].currency || 'RUB',
Expand All @@ -109,6 +124,7 @@ export const spec = {
advertiserDomains: serverResponse.body[i].adomain ? serverResponse.body[i].adomain : []
}
};

bidResponses.push(bidResponse);
}
return bidResponses;
Expand Down
41 changes: 41 additions & 0 deletions test/spec/modules/betweenBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,32 @@ describe('betweenBidAdapterTests', function () {
let req_data = JSON.parse(request.data)[0].data;
expect(req_data.bidid).to.equal('bid1234');
});

it('validate_video_params', function () {
let bidRequestData = [{
bidId: 'bid1234',
bidder: 'between',
params: {w: 240, h: 400, s: 1112},
mediaTypes: {
video: {
context: 'outstream',
playerSize: [970, 250],
maxd: 123,
mind: 234,
codeType: 'unknown code type'
}
},
}];
let request = spec.buildRequests(bidRequestData);
let req_data = JSON.parse(request.data)[0].data;

expect(req_data.mediaType).to.equal(2);
expect(req_data.maxd).to.equal(123);
expect(req_data.mind).to.equal(234);
expect(req_data.pos).to.equal('atf');
expect(req_data.codeType).to.equal('inpage');
});

it('validate itu param', function() {
let bidRequestData = [{
bidId: 'bid1234',
Expand Down Expand Up @@ -230,6 +256,21 @@ describe('betweenBidAdapterTests', function () {
expect(bid.requestId).to.equal('bid1234');
expect(bid.ad).to.equal('Ad html');
});

it('validate_response_video_params', function () {
let serverResponse = {
body: [{
mediaType: 2,
vastXml: 'vastXml',
}]
};
let bids = spec.interpretResponse(serverResponse);
expect(bids).to.have.lengthOf(1);
let bid = bids[0];
expect(bid.mediaType).to.equal(2);
expect(bid.vastXml).to.equal('vastXml');
});

it('validate response params without currency', function () {
let serverResponse = {
body: [{
Expand Down