From 0403ba7f88ce78f23a1b6e3699730fbca50fbd20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Udi=20Talias=20=E2=9A=9B=EF=B8=8F?= Date: Thu, 23 Jul 2020 16:45:40 +0300 Subject: [PATCH] Vidazoo Adapter: Feature/alternate-param-names (#5527) * feat(module): multi size request * fix getUserSyncs added tests * update(module): package-lock.json from master * feat(client): alternate param names Co-authored-by: roman --- modules/vidazooBidAdapter.js | 20 +++++++++++++++-- test/spec/modules/vidazooBidAdapter_spec.js | 24 +++++++++++++++++++-- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/modules/vidazooBidAdapter.js b/modules/vidazooBidAdapter.js index 3eea270dc8d..b9f3297818f 100644 --- a/modules/vidazooBidAdapter.js +++ b/modules/vidazooBidAdapter.js @@ -32,16 +32,31 @@ export function createDomain(subDomain = DEFAULT_SUB_DOMAIN) { return `https://${subDomain}.cootlogix.com`; } +export function extractCID(params) { + return params.cId || params.CID || params.cID || params.CId || params.cid || params.ciD || params.Cid || params.CiD; +} + +export function extractPID(params) { + return params.pId || params.PID || params.pID || params.PId || params.pid || params.piD || params.Pid || params.PiD; +} + +export function extractSubDomain(params) { + return params.subDomain || params.SubDomain || params.Subdomain || params.subdomain || params.SUBDOMAIN || params.subDOMAIN; +} + function isBidRequestValid(bid) { const params = bid.params || {}; - return !!(params.cId && params.pId); + return !!(extractCID(params) && extractPID(params)); } function buildRequest(bid, topWindowUrl, sizes, bidderRequest) { const { params, bidId, userId, adUnitCode } = bid; - const { bidFloor, cId, pId, ext, subDomain } = params; + const { bidFloor, ext } = params; const hashUrl = hashCode(topWindowUrl); const dealId = getNextDealId(hashUrl); + const cId = extractCID(params); + const pId = extractPID(params); + const subDomain = extractSubDomain(params); let data = { url: encodeURIComponent(topWindowUrl), @@ -70,6 +85,7 @@ function buildRequest(bid, topWindowUrl, sizes, bidderRequest) { if (bidderRequest.uspConsent) { data.usPrivacy = bidderRequest.uspConsent } + const dto = { method: 'POST', url: `${createDomain(subDomain)}/prebid/multi/${cId}`, diff --git a/test/spec/modules/vidazooBidAdapter_spec.js b/test/spec/modules/vidazooBidAdapter_spec.js index b8ab83a95ae..103cb0897a7 100644 --- a/test/spec/modules/vidazooBidAdapter_spec.js +++ b/test/spec/modules/vidazooBidAdapter_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { spec as adapter, SUPPORTED_ID_SYSTEMS, createDomain } from 'modules/vidazooBidAdapter.js'; +import { spec as adapter, SUPPORTED_ID_SYSTEMS, createDomain, extractPID, extractCID, extractSubDomain } from 'modules/vidazooBidAdapter.js'; import * as utils from 'src/utils.js'; import { version } from 'package.json'; @@ -220,7 +220,7 @@ describe('VidazooBidAdapter', function () { }); }); - describe(`user id system`, function () { + describe('user id system', function () { Object.keys(SUPPORTED_ID_SYSTEMS).forEach((idSystemProvider) => { const id = Date.now().toString(); const bid = utils.deepClone(BID); @@ -243,4 +243,24 @@ describe('VidazooBidAdapter', function () { }); }); }); + + describe('alternate param names extractors', function () { + it('should return undefined when param not supported', function () { + const cid = extractCID({ 'c_id': '1' }); + const pid = extractPID({ 'p_id': '1' }); + const subDomain = extractSubDomain({ 'sub_domain': 'prebid' }); + expect(cid).to.be.undefined; + expect(pid).to.be.undefined; + expect(subDomain).to.be.undefined; + }); + + it('should return value when param supported', function () { + const cid = extractCID({ 'cID': '1' }); + const pid = extractPID({ 'Pid': '2' }); + const subDomain = extractSubDomain({ 'subDOMAIN': 'prebid' }); + expect(cid).to.be.equal('1'); + expect(pid).to.be.equal('2'); + expect(subDomain).to.be.equal('prebid'); + }); + }); });