Skip to content

Commit

Permalink
Aniview Bid Adapter: add support for BANNER (#7162)
Browse files Browse the repository at this point in the history
* Support new aniview bid adapter

* Support new aniview bid adapter

* Support new aniview bid adapter

* Support new aniview bid adapter

* Fix Consent parameters

* Update aniviewBidAdapter.js

V3 support

* Update aniviewBidAdapter.js

* Update aniviewBidAdapter.js

Update refererInfo

* Update aniviewBidAdapter.js

Fix tabs and spaces

* Update aniviewBidAdapter.js

fixes

* Update aniviewBidAdapter.js

* Update aniviewBidAdapter.js

Add ccpa support

* Update aniviewBidAdapter.js

Typo

* Update aniviewBidAdapter.js

* Update aniviewBidAdapter.js

* Fix size and sample

Fixed sizes from playerSize
Updated md sample

* Fix tabs

* Fix sizes

* Recheck

* Add tgt parameter

* Update sample

* Add support for cookie sync + tests

* Add support for cookie sync + tests

* Add support for cookie sync + tests

* Support aliases

Support aliases

* Update

Update

* Fix lint

Fix lint

* Update spec

Update spec

* Aniview Bid Adapter: Added the new alias

* Aniview Bid Adapter: Added the new configs for the renderer

* Aniview Bid Adapter: Added unit tests for the renderer

* Aniview Bid Adapter: Have added gvlid

* Aniview Bid Adapter: added meta.advertiserDomains to bidResponse and extended cookie sync logic

* Support BANNER mediaType

Support BANNER mediaType

* Aniview BANNER support

Fix spaces

Co-authored-by: Roman Shevchenko <iroman.via@gmail.com>
  • Loading branch information
itaynave and roshecode committed Jul 12, 2021
1 parent dcd2789 commit b6318de
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 11 deletions.
52 changes: 41 additions & 11 deletions modules/aniviewBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { VIDEO } from '../src/mediaTypes.js';
import { VIDEO, BANNER } from '../src/mediaTypes.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { Renderer } from '../src/Renderer.js';
import * as utils from '../src/utils.js';

const BIDDER_CODE = 'aniview';
const GVLID = 780;
Expand Down Expand Up @@ -172,6 +173,22 @@ function getCpmData(xml) {
}
return ret;
}
function buildBanner(xmlStr, bidRequest, bidResponse) {
var rendererData = JSON.stringify({
id: bidRequest.adUnitCode,
debug: window.location.href.indexOf('pbjsDebug') >= 0,
placement: bidRequest.bidRequest.adUnitCode,
width: bidResponse.width,
height: bidResponse.height,
vastXml: xmlStr,
bid: bidResponse,
config: bidRequest.bidRequest.params.rendererConfig
});
var playerDomain = bidRequest.bidRequest.params.playerDomain || 'player.aniview.com';
var ad = '<script src="https://' + playerDomain + '/script/6.1/prebidRenderer.js"></script>';
ad += '<script> window.aniviewRenderer.renderAd(' + rendererData + ') </script>'
return ad;
}
function interpretResponse(serverResponse, bidRequest) {
let bidResponses = [];
if (serverResponse && serverResponse.body) {
Expand All @@ -181,6 +198,10 @@ function interpretResponse(serverResponse, bidRequest) {
try {
let bidResponse = {};
if (bidRequest && bidRequest.data && bidRequest.data.bidId && bidRequest.data.bidId !== '') {
let mediaType = VIDEO;
if (bidRequest.bidRequest && bidRequest.bidRequest.mediaTypes && !bidRequest.bidRequest.mediaTypes[VIDEO]) {
mediaType = BANNER;
}
let xmlStr = serverResponse.body;
let xml = new window.DOMParser().parseFromString(xmlStr, 'text/xml');
if (xml && xml.getElementsByTagName('parsererror').length == 0) {
Expand All @@ -195,18 +216,27 @@ function interpretResponse(serverResponse, bidRequest) {
bidResponse.creativeId = xml.getElementsByTagName('Ad') && xml.getElementsByTagName('Ad')[0] && xml.getElementsByTagName('Ad')[0].getAttribute('id') ? xml.getElementsByTagName('Ad')[0].getAttribute('id') : 'creativeId';
bidResponse.currency = cpmData.currency;
bidResponse.netRevenue = true;
var blob = new Blob([xmlStr], {
type: 'application/xml'
});
bidResponse.vastUrl = window.URL.createObjectURL(blob);
bidResponse.vastXml = xmlStr;
bidResponse.mediaType = VIDEO;
bidResponse.mediaType = mediaType;
if (mediaType === VIDEO) {
try {
var blob = new Blob([xmlStr], {
type: 'application/xml'
});
bidResponse.vastUrl = window.URL.createObjectURL(blob);
} catch (ex) {
utils.logError('Aniview Debug create vastXml error:\n\n' + ex);
}
bidResponse.vastXml = xmlStr;
if (bidRequest.bidRequest && bidRequest.bidRequest.mediaTypes && bidRequest.bidRequest.mediaTypes.video && bidRequest.bidRequest.mediaTypes.video.context === 'outstream') {
bidResponse.renderer = newRenderer(bidRequest);
}
} else {
bidResponse.ad = buildBanner(xmlStr, bidRequest, bidResponse);
}
bidResponse.meta = {
advertiserDomains: []
};

if (bidRequest.bidRequest && bidRequest.bidRequest.mediaTypes && bidRequest.bidRequest.mediaTypes.video && bidRequest.bidRequest.mediaTypes.video.context === 'outstream') { bidResponse.renderer = newRenderer(bidRequest); }

bidResponses.push(bidResponse);
}
} else {}
Expand Down Expand Up @@ -279,8 +309,8 @@ function getUserSyncs(syncOptions, serverResponses) {
export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
aliases: ['avantisvideo', 'selectmediavideo'],
supportedMediaTypes: [VIDEO],
aliases: ['avantisvideo', 'selectmediavideo', 'vidcrunch'],
supportedMediaTypes: [VIDEO, BANNER],
isBidRequestValid,
buildRequests,
interpretResponse,
Expand Down
23 changes: 23 additions & 0 deletions test/spec/modules/aniviewBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,29 @@ describe('ANIVIEW Bid Adapter Test', function () {
expect(bidResponse.renderer.loaded).to.equal(false)
expect(bidResponse.width).to.equal(640)
expect(bidResponse.height).to.equal(480)
});

it('Support banner format', function () {
const bidRequest = spec.buildRequests([
{
bidId: '253dcb69fb2577',
params: {
playerDomain: 'example.com',
AV_PUBLISHERID: '55b78633181f4603178b4568',
AV_CHANNELID: '55b7904d181f46410f8b4568'
},
mediaTypes: {
banner: {
sizes: [[640, 480]],
}
}
}
])[0]
const bidResponse = spec.interpretResponse(serverResponse, bidRequest)[0]

expect(bidResponse.ad).to.have.string('https://example.com/script/6.1/prebidRenderer.js');
expect(bidResponse.width).to.equal(640)
expect(bidResponse.height).to.equal(480)
})
});

Expand Down

0 comments on commit b6318de

Please sign in to comment.