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

Relaido Bid Adapter: Add support for bids[].params.video.playerSize #8627

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: 19 additions & 4 deletions modules/relaidoBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { deepAccess, logWarn, getBidIdParameter, parseQueryStringParameters, triggerPixel, generateUUID, isArray } from '../src/utils.js';
import { deepAccess, logWarn, getBidIdParameter, parseQueryStringParameters, triggerPixel, generateUUID, isArray, isNumber } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
import { Renderer } from '../src/Renderer.js';
import { getStorageManager } from '../src/storageManager.js';

const BIDDER_CODE = 'relaido';
const BIDDER_DOMAIN = 'api.relaido.jp';
const ADAPTER_VERSION = '1.0.7';
const ADAPTER_VERSION = '1.0.8';
const DEFAULT_TTL = 300;
const UUID_KEY = 'relaido_uuid';

Expand Down Expand Up @@ -44,7 +44,10 @@ function buildRequests(validBidRequests, bidderRequest) {
let height = 0;

if (hasVideoMediaType(bidRequest) && isVideoValid(bidRequest)) {
const playerSize = getValidSizes(deepAccess(bidRequest, 'mediaTypes.video.playerSize'));
let playerSize = getValidSizes(deepAccess(bidRequest, 'mediaTypes.video.playerSize'));
if (playerSize.length === 0) {
playerSize = getValidSizes(deepAccess(bidRequest, 'params.video.playerSize'));
}
width = playerSize[0][0];
height = playerSize[0][1];
mediaType = VIDEO;
Expand Down Expand Up @@ -253,7 +256,10 @@ function isBannerValid(bid) {
}

function isVideoValid(bid) {
const playerSize = getValidSizes(deepAccess(bid, 'mediaTypes.video.playerSize'));
let playerSize = getValidSizes(deepAccess(bid, 'mediaTypes.video.playerSize'));
if (playerSize.length === 0) {
playerSize = getValidSizes(deepAccess(bid, 'params.video.playerSize'));
}
if (playerSize.length > 0) {
const context = deepAccess(bid, 'mediaTypes.video.context');
if (context && context === 'outstream') {
Expand Down Expand Up @@ -300,6 +306,15 @@ function getValidSizes(sizes) {
if ((width >= 300 && height >= 250)) {
result.push([width, height]);
}
} else if (isNumber(sizes[i])) {
const width = sizes[0];
const height = sizes[1];
if (width == 1 && height == 1) {
return [[1, 1]];
}
if ((width >= 300 && height >= 250)) {
return [[width, height]];
}
}
}
}
Expand Down
31 changes: 29 additions & 2 deletions test/spec/modules/relaidoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ describe('RelaidoAdapter', function () {
data: {
bids: [{
bidId: bidRequest.bidId,
width: bidRequest.mediaTypes.video.playerSize[0][0],
height: bidRequest.mediaTypes.video.playerSize[0][1],
width: bidRequest.mediaTypes.video.playerSize[0][0] || bidRequest.mediaTypes.video.playerSize[0],
height: bidRequest.mediaTypes.video.playerSize[0][1] || bidRequest.mediaTypes.video.playerSize[1],
mediaType: 'video'}]
}
};
Expand All @@ -98,6 +98,33 @@ describe('RelaidoAdapter', function () {
expect(spec.isBidRequestValid(bidRequest)).to.equal(true);
});

it('should return true when not existed mediaTypes.video.playerSize and existed valid params.video.playerSize by video', function () {
bidRequest.mediaTypes = {
video: {
context: 'outstream'
}
};
bidRequest.params = {
placementId: '100000',
video: {
playerSize: [
[640, 360]
]
}
};
expect(spec.isBidRequestValid(bidRequest)).to.equal(true);
});

it('should return even true when the playerSize is Array[Number, Number] by video', function () {
bidRequest.mediaTypes = {
video: {
context: 'outstream',
playerSize: [640, 360]
}
};
expect(spec.isBidRequestValid(bidRequest)).to.equal(true);
});

it('should return true when the required params are passed by banner', function () {
setUAMobile();
bidRequest.mediaTypes = {
Expand Down