Skip to content

Commit

Permalink
Vidazoo Adapter: Feature/alternate-param-names (#5527)
Browse files Browse the repository at this point in the history
* 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 <shmoop207@gmail.com>
  • Loading branch information
uditalias and shmoop207 authored Jul 23, 2020
1 parent 9f7195c commit 0403ba7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
20 changes: 18 additions & 2 deletions modules/vidazooBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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}`,
Expand Down
24 changes: 22 additions & 2 deletions test/spec/modules/vidazooBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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);
Expand All @@ -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');
});
});
});

0 comments on commit 0403ba7

Please sign in to comment.