Skip to content

Commit

Permalink
Relaido Bid Adapter: Add support for bids[].params.video.playerSize (p…
Browse files Browse the repository at this point in the history
…rebid#8627)

* add relaido adapter

* remove event listener

* fixed UserSyncs and e.data

* fix conflicts

* support params.video.playerSize

If mediaTypes.video.playerSize does not have a definition, but params.video.playerSize does, allow it.

* add support for playerSize is Array[number, Number]

Co-authored-by: ishigami_shingo <[email protected]>
Co-authored-by: cmertv-sishigami <[email protected]>
Co-authored-by: t_bun <[email protected]>
Co-authored-by: n.maeura <[email protected]>
  • Loading branch information
5 people authored and bwhisp committed Jul 13, 2022
1 parent 9353c7a commit a623cb9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
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

0 comments on commit a623cb9

Please sign in to comment.