Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vidoomy Bid Adapter: added block module #9825

Merged
merged 2 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -128,6 +128,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 @@ -154,7 +162,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 @@ -260,7 +273,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 @@ -287,7 +300,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