Skip to content

Commit

Permalink
vidoomy adapter: added block module (prebid#9825)
Browse files Browse the repository at this point in the history
  • Loading branch information
nimasrn authored and jorgeluisrocha committed May 18, 2023
1 parent 99abc6f commit 1470ea9
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 8 deletions.
25 changes: 19 additions & 6 deletions modules/vidoomyBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { logError, deepAccess, parseSizesInput } from '../src/utils.js';
import {deepAccess, logError, parseSizesInput} from '../src/utils.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {config} from '../src/config.js';
import { Renderer } from '../src/Renderer.js';
import { INSTREAM, OUTSTREAM } from '../src/video.js';
import {Renderer} from '../src/Renderer.js';
import {INSTREAM, OUTSTREAM} from '../src/video.js';

const ENDPOINT = `https://d.vidoomy.com/api/rtbserver/prebid/`;
const BIDDER_CODE = 'vidoomy';
Expand Down Expand Up @@ -129,6 +129,14 @@ const buildRequests = (validBidRequests, bidderRequest) => {
const bidfloor = deepAccess(bid, `params.bidfloor`, 0);
const floor = getBidFloor(bid, adType, sizes, bidfloor);

const ortb2 = bidderRequest.ortb2 || {
bcat: [],
badv: [],
bapp: [],
btype: [],
battr: []
};

let eids;
const userEids = deepAccess(bid, 'userIdAsEids');
if (Array.isArray(userEids) && userEids.length > 0) {
Expand All @@ -155,7 +163,12 @@ const buildRequests = (validBidRequests, bidderRequest) => {
sp: encodeURIComponent(bidderRequest.refererInfo.page || bidderRequest.refererInfo.topmostLocation),
usp: bidderRequest.uspConsent || '',
coppa: !!config.getConfig('coppa'),
videoContext: videoContext || ''
videoContext: videoContext || '',
bcat: ortb2.bcat || bid.params.bcat || [],
badv: ortb2.badv || bid.params.badv || [],
bapp: ortb2.bapp || bid.params.bapp || [],
btype: ortb2.btype || bid.params.btype || [],
battr: ortb2.battr || bid.params.battr || []
};

if (bidderRequest.gdprConsent) {
Expand Down Expand Up @@ -261,7 +274,7 @@ const interpretResponse = (serverResponse, bidRequest) => {
}
};

function getUserSyncs (syncOptions, responses, gdprConsent, uspConsent) {
function getUserSyncs(syncOptions, responses, gdprConsent, uspConsent) {
if (syncOptions.iframeEnabled || syncOptions.pixelEnabled) {
const pixelType = syncOptions.pixelEnabled ? 'image' : 'iframe';
const urls = deepAccess(responses, '0.body.pixels') || COOKIE_SYNC_FALLBACK_URLS;
Expand All @@ -288,7 +301,7 @@ export const spec = {

registerBidder(spec);

function getDomainWithoutSubdomain (hostname) {
function getDomainWithoutSubdomain(hostname) {
const parts = hostname.split('.');
const newParts = [];
for (let i = parts.length - 1; i >= 0; i--) {
Expand Down
14 changes: 12 additions & 2 deletions modules/vidoomyBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ var adUnits = [
params: {
id: '123123',
pid: '123123',
bidfloor: 0.5 // This is optional
bidfloor: 0.5, // This is optional
bcat: ['IAB1-1'], // Optional - default is []
badv: ['example.com'], // Optional - default is []
bapp: ['app.com'], // Optional - default is []
btype: [1, 2, 3], // Optional - default is []
battr: [1, 2, 3] // Optional - default is []
}
}
]
Expand All @@ -52,7 +57,12 @@ var adUnits = [
params: {
id: '123123',
pid: '123123',
bidfloor: 0.5 // This is optional
bidfloor: 0.5, // This is optional
bcat: ['IAB1-1'], // Optional - default is []
badv: ['example.com'], // Optional - default is []
bapp: ['app.com'], // Optional - default is []
btype: [1, 2, 3], // Optional - default is []
battr: [1, 2, 3] // Optional - default is []
}
}
]
Expand Down
49 changes: 49 additions & 0 deletions test/spec/modules/vidoomyBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,55 @@ describe('vidoomyBidAdapter', function() {
expect(bidRequest.data.bidfloor).to.equal(bidfloor);
});
});

describe('badv, bcat, bapp, btype, battr', function () {
const bidderRequestNew = {
...bidderRequest,
bcat: ['EX1', 'EX2', 'EX3'],
badv: ['site.com'],
bapp: ['app.com'],
btype: [1, 2, 3],
battr: [1, 2, 3]
}
const request = spec.buildRequests(bidRequests, bidderRequestNew);
it('should have badv, bcat, bapp, btype, battr in request', function () {
expect(request[0].data).to.include.any.keys('badv');
expect(request[0].data).to.include.any.keys('bcat');
expect(request[0].data).to.include.any.keys('bapp');
expect(request[0].data).to.include.any.keys('btype');
expect(request[0].data).to.include.any.keys('battr');
})

it('should have equal badv, bcat, bapp, btype, battr in request', function () {
expect(request[0].badv).to.deep.equal(bidderRequest.refererInfo.badv);
expect(request[0].bcat).to.deep.equal(bidderRequest.refererInfo.bcat);
expect(request[0].bapp).to.deep.equal(bidderRequest.refererInfo.bapp);
expect(request[0].btype).to.deep.equal(bidderRequest.refererInfo.btype);
expect(request[0].battr).to.deep.equal(bidderRequest.refererInfo.battr);
})
})

describe('first party data', function () {
const bidderRequest2 = {
...bidderRequest,
ortb2: {
bcat: ['EX1', 'EX2', 'EX3'],
badv: ['site.com'],
bapp: ['app.com'],
btype: [1, 2, 3],
battr: [1, 2, 3]
}
}
const request = spec.buildRequests(bidRequests, bidderRequest2);

it('should have badv, bcat, bapp, btype, battr in request and equal to bidderRequest.ortb2', function () {
expect(request[0].data.bcat).to.deep.equal(bidderRequest2.ortb2.bcat)
expect(request[0].data.badv).to.deep.equal(bidderRequest2.ortb2.badv)
expect(request[0].data.bapp).to.deep.equal(bidderRequest2.ortb2.bapp);
expect(request[0].data.btype).to.deep.equal(bidderRequest2.ortb2.btype);
expect(request[0].data.battr).to.deep.equal(bidderRequest2.ortb2.battr);
});
});
});

describe('interpretResponse', function () {
Expand Down

0 comments on commit 1470ea9

Please sign in to comment.