diff --git a/modules/relaidoBidAdapter.js b/modules/relaidoBidAdapter.js index 0b2cdaa711e..880e826d75b 100644 --- a/modules/relaidoBidAdapter.js +++ b/modules/relaidoBidAdapter.js @@ -1,4 +1,4 @@ -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'; @@ -6,7 +6,7 @@ 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'; @@ -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; @@ -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') { @@ -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]]; + } } } } diff --git a/test/spec/modules/relaidoBidAdapter_spec.js b/test/spec/modules/relaidoBidAdapter_spec.js index cea49424b4d..ead44f96bc9 100644 --- a/test/spec/modules/relaidoBidAdapter_spec.js +++ b/test/spec/modules/relaidoBidAdapter_spec.js @@ -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'}] } }; @@ -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 = {