-
Notifications
You must be signed in to change notification settings - Fork 2.2k
aniview V3 support #4583
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
Merged
Merged
aniview V3 support #4583
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
38f3d5b
Support new aniview bid adapter
itaynave d50f498
Support new aniview bid adapter
itaynave ee8b463
Support new aniview bid adapter
itaynave 7a4f754
Support new aniview bid adapter
itaynave 9350489
Fix Consent parameters
itaynave 1d4c5ed
Merge remote-tracking branch 'upstream/master'
itaynave 4713801
Update aniviewBidAdapter.js
itaynave a0aa080
Update aniviewBidAdapter.js
itaynave 5727d7b
Update aniviewBidAdapter.js
itaynave 25064d2
Update aniviewBidAdapter.js
itaynave 6f354e8
Update aniviewBidAdapter.js
itaynave f34d645
Update aniviewBidAdapter.js
itaynave cdfa67b
Update aniviewBidAdapter.js
itaynave 7dac778
Update aniviewBidAdapter.js
itaynave 3b853d5
Update aniviewBidAdapter.js
itaynave a24e96e
Update aniviewBidAdapter.js
itaynave 25d24a5
Fix size and sample
itaynave 83d3f80
Fix tabs
itaynave df2c8b5
Fix sizes
itaynave 972cc66
Recheck
itaynave 3f87a8e
Add tgt parameter
itaynave b7d25ef
Update sample
itaynave File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
import { VIDEO } from '../src/mediaTypes'; | ||
import { registerBidder } from '../src/adapters/bidderFactory'; | ||
import { Renderer } from '../src/Renderer'; | ||
|
||
const BIDDER_CODE = 'aniview'; | ||
const TTL = 600; | ||
|
||
function avRenderer(bid) { | ||
bid.renderer.push(function() { | ||
let eventCallback = bid && bid.renderer && bid.renderer.handleVideoEvent ? bid.renderer.handleVideoEvent : null; | ||
window.aniviewRenderer.renderAd({ | ||
id: bid.adUnitCode + '_' + bid.adId, | ||
debug: window.location.href.indexOf('pbjsDebug') >= 0, | ||
placement: bid.adUnitCode, | ||
width: bid.width, | ||
height: bid.height, | ||
vastUrl: bid.vastUrl, | ||
vastXml: bid.vastXml, | ||
config: bid.params[0].rendererConfig, | ||
eventsCallback: eventCallback, | ||
bid: bid | ||
}); | ||
}); | ||
} | ||
|
||
function newRenderer(bidRequest) { | ||
const renderer = Renderer.install({ | ||
url: 'https://player.aniview.com/script/6.1/prebidRenderer.js', | ||
config: {}, | ||
loaded: false, | ||
}); | ||
|
||
try { | ||
renderer.setRender(avRenderer); | ||
} catch (err) { | ||
} | ||
|
||
return renderer; | ||
} | ||
|
||
function isBidRequestValid(bid) { | ||
if (!bid.params || !bid.params.AV_PUBLISHERID || !bid.params.AV_CHANNELID) { return false; } | ||
|
||
return true; | ||
} | ||
|
||
function buildRequests(validBidRequests, bidderRequest) { | ||
let bidRequests = []; | ||
|
||
for (let i = 0; i < validBidRequests.length; i++) { | ||
let bidRequest = validBidRequests[i]; | ||
|
||
if (!bidRequest.sizes || !bidRequest.sizes.length) { | ||
bidRequest.sizes = [[640, 480]]; | ||
} | ||
|
||
if (bidRequest.sizes.length === 2 && typeof bidRequest.sizes[0] === 'number' && typeof bidRequest.sizes[1] === 'number') { | ||
let adWidth = bidRequest.sizes[0]; | ||
let adHeight = bidRequest.sizes[1]; | ||
bidRequest.sizes = [[adWidth, adHeight]]; | ||
} | ||
|
||
for (let j = 0; j < bidRequest.sizes.length; j++) { | ||
let size = bidRequest.sizes[j]; | ||
let playerWidth; | ||
let playerHeight; | ||
if (size && size.length == 2) { | ||
playerWidth = size[0]; | ||
playerHeight = size[1]; | ||
} else { | ||
playerWidth = 640; | ||
playerHeight = 480; | ||
} | ||
|
||
let s2sParams = {}; | ||
|
||
for (var attrname in bidRequest.params) { | ||
if (bidRequest.params.hasOwnProperty(attrname) && attrname.indexOf('AV_') == 0) { | ||
s2sParams[attrname] = bidRequest.params[attrname]; | ||
} | ||
}; | ||
|
||
if (s2sParams.AV_APPPKGNAME && !s2sParams.AV_URL) { s2sParams.AV_URL = s2sParams.AV_APPPKGNAME; } | ||
if (!s2sParams.AV_IDFA && !s2sParams.AV_URL) { | ||
if (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.referer) { | ||
s2sParams.AV_URL = bidderRequest.refererInfo.referer; | ||
} else { | ||
s2sParams.AV_URL = window.location.href; | ||
} | ||
} | ||
if (s2sParams.AV_IDFA && !s2sParams.AV_AID) { s2sParams.AV_AID = s2sParams.AV_IDFA; } | ||
if (s2sParams.AV_AID && !s2sParams.AV_IDFA) { s2sParams.AV_IDFA = s2sParams.AV_AID; } | ||
|
||
s2sParams.pbjs = 1; | ||
s2sParams.cb = Math.floor(Math.random() * 999999999); | ||
s2sParams.AV_WIDTH = playerWidth; | ||
s2sParams.AV_HEIGHT = playerHeight; | ||
s2sParams.bidWidth = playerWidth; | ||
s2sParams.bidHeight = playerHeight; | ||
s2sParams.bidId = bidRequest.bidId; | ||
s2sParams.s2s = '1'; | ||
|
||
if (bidderRequest && bidderRequest.gdprConsent) { | ||
if (bidderRequest.gdprConsent.gdprApplies) { | ||
s2sParams.AV_GDPR = 1; | ||
s2sParams.AV_CONSENT = bidderRequest.gdprConsent.consentString; | ||
} | ||
} | ||
if (bidderRequest && bidderRequest.uspConsent) { | ||
s2sParams.AV_CCPA = bidderRequest.uspConsent; | ||
} | ||
|
||
let serverDomain = bidRequest.params && bidRequest.params.serverDomain ? bidRequest.params.serverDomain : 'gov.aniview.com'; | ||
let servingUrl = 'https://' + serverDomain + '/api/adserver/vast3/'; | ||
|
||
bidRequests.push({ | ||
method: 'GET', | ||
url: servingUrl, | ||
data: s2sParams, | ||
bidRequest | ||
}); | ||
} | ||
} | ||
|
||
return bidRequests; | ||
} | ||
function getCpmData(xml) { | ||
let ret = {cpm: 0, currency: 'USD'}; | ||
if (xml) { | ||
let ext = xml.getElementsByTagName('Extensions'); | ||
if (ext && ext.length > 0) { | ||
ext = ext[0].getElementsByTagName('Extension'); | ||
if (ext && ext.length > 0) { | ||
for (var i = 0; i < ext.length; i++) { | ||
if (ext[i].getAttribute('type') == 'ANIVIEW') { | ||
let price = ext[i].getElementsByTagName('Cpm'); | ||
if (price && price.length == 1) { | ||
ret.cpm = price[0].textContent; | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return ret; | ||
} | ||
function interpretResponse(serverResponse, bidRequest) { | ||
let bidResponses = []; | ||
if (serverResponse && serverResponse.body) { | ||
if (serverResponse.error) { | ||
return bidResponses; | ||
} else { | ||
try { | ||
let bidResponse = {}; | ||
if (bidRequest && bidRequest.data && bidRequest.data.bidId && bidRequest.data.bidId !== '') { | ||
let xmlStr = serverResponse.body; | ||
let xml = new window.DOMParser().parseFromString(xmlStr, 'text/xml'); | ||
if (xml && xml.getElementsByTagName('parsererror').length == 0) { | ||
let cpmData = getCpmData(xml); | ||
if (cpmData && cpmData.cpm > 0) { | ||
bidResponse.requestId = bidRequest.data.bidId; | ||
bidResponse.bidderCode = BIDDER_CODE; | ||
bidResponse.ad = ''; | ||
bidResponse.cpm = cpmData.cpm; | ||
bidResponse.width = bidRequest.data.AV_WIDTH; | ||
bidResponse.height = bidRequest.data.AV_HEIGHT; | ||
bidResponse.ttl = TTL; | ||
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; | ||
if (bidRequest.bidRequest && bidRequest.bidRequest.mediaTypes && bidRequest.bidRequest.mediaTypes.video && bidRequest.bidRequest.mediaTypes.video.context === 'outstream') { bidResponse.renderer = newRenderer(bidRequest); } | ||
|
||
bidResponses.push(bidResponse); | ||
} | ||
} else {} | ||
} else {} | ||
} catch (e) {} | ||
} | ||
} else {} | ||
|
||
return bidResponses; | ||
} | ||
|
||
export const spec = { | ||
code: BIDDER_CODE, | ||
supportedMediaTypes: [VIDEO], | ||
isBidRequestValid, | ||
buildRequests, | ||
interpretResponse | ||
} | ||
|
||
registerBidder(spec); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
import { spec } from 'modules/aniviewBidAdapter'; | ||
import { newBidder } from 'src/adapters/bidderFactory'; | ||
const { expect } = require('chai'); | ||
|
||
describe('ANIVIEW Bid Adapter Test', function () { | ||
const adapter = newBidder(spec); | ||
|
||
describe('inherited functions', function () { | ||
it('exists and is a function', function () { | ||
expect(adapter.callBids).to.exist.and.to.be.a('function'); | ||
}); | ||
}); | ||
|
||
describe('isBidRequestValid', function () { | ||
let bid = { | ||
'bidder': 'aniview', | ||
'params': { | ||
'AV_PUBLISHERID': '123456', | ||
'AV_CHANNELID': '123456' | ||
}, | ||
'adUnitCode': 'video1', | ||
'sizes': [[300, 250], [640, 480]], | ||
'bidId': '30b31c1838de1e', | ||
'bidderRequestId': '22edbae2733bf6', | ||
'requestId': 'a09c66c3-53e3-4428-b296-38fc08e7cd2a', | ||
'transactionId': 'd6f6b392-54a9-454c-85fb-a2fd882c4a2d', | ||
}; | ||
|
||
it('should return true when required params found', function () { | ||
expect(spec.isBidRequestValid(bid)).to.equal(true); | ||
}); | ||
|
||
it('should return false when required params are not passed', function () { | ||
let bid = Object.assign({}, bid); | ||
delete bid.params; | ||
bid.params = { | ||
something: 'is wrong' | ||
}; | ||
expect(spec.isBidRequestValid(bid)).to.equal(false); | ||
}); | ||
}); | ||
|
||
describe('buildRequests', function () { | ||
const ENDPOINT = 'https://v.lkqd.net/ad'; | ||
let bid2Requests = [ | ||
{ | ||
'bidder': 'aniview', | ||
'params': { | ||
'AV_PUBLISHERID': '123456', | ||
'AV_CHANNELID': '123456' | ||
}, | ||
'adUnitCode': 'test1', | ||
'sizes': [[300, 250], [640, 480]], | ||
'bidId': '30b31c1838de1e', | ||
'bidderRequestId': '22edbae2733bf6', | ||
'requestId': 'a09c66c3-53e3-4428-b296-38fc08e7cd2a', | ||
'transactionId': 'd6f6b392-54a9-454c-85fb-a2fd882c4a2d', | ||
} | ||
]; | ||
let bid1Request = [ | ||
{ | ||
'bidder': 'aniview', | ||
'params': { | ||
'AV_PUBLISHERID': '123456', | ||
'AV_CHANNELID': '123456' | ||
}, | ||
'adUnitCode': 'test1', | ||
'sizes': [640, 480], | ||
'bidId': '30b31c1838de1e', | ||
'bidderRequestId': '22edbae2733bf6', | ||
'requestId': 'a09c66c3-53e3-4428-b296-38fc08e7cd2a', | ||
'transactionId': 'd6f6b392-54a9-454c-85fb-a2fd882c4a2d', | ||
} | ||
]; | ||
|
||
it('Test 2 requests', function () { | ||
const requests = spec.buildRequests(bid2Requests); | ||
expect(requests.length).to.equal(2); | ||
const r1 = requests[0]; | ||
const d1 = requests[0].data; | ||
expect(d1).to.have.property('AV_PUBLISHERID'); | ||
expect(d1.AV_PUBLISHERID).to.equal('123456'); | ||
expect(d1).to.have.property('AV_CHANNELID'); | ||
expect(d1.AV_CHANNELID).to.equal('123456'); | ||
expect(d1).to.have.property('AV_WIDTH'); | ||
expect(d1.AV_WIDTH).to.equal(300); | ||
expect(d1).to.have.property('AV_HEIGHT'); | ||
expect(d1.AV_HEIGHT).to.equal(250); | ||
expect(d1).to.have.property('AV_URL'); | ||
expect(d1).to.have.property('cb'); | ||
expect(d1).to.have.property('s2s'); | ||
expect(d1.s2s).to.equal('1'); | ||
expect(d1).to.have.property('pbjs'); | ||
expect(d1.pbjs).to.equal(1); | ||
expect(r1).to.have.property('url'); | ||
expect(r1.url).to.contain('https://gov.aniview.com/api/adserver/vast3/'); | ||
const r2 = requests[1]; | ||
const d2 = requests[1].data; | ||
expect(d2).to.have.property('AV_PUBLISHERID'); | ||
expect(d2.AV_PUBLISHERID).to.equal('123456'); | ||
expect(d2).to.have.property('AV_CHANNELID'); | ||
expect(d2.AV_CHANNELID).to.equal('123456'); | ||
expect(d2).to.have.property('AV_WIDTH'); | ||
expect(d2.AV_WIDTH).to.equal(640); | ||
expect(d2).to.have.property('AV_HEIGHT'); | ||
expect(d2.AV_HEIGHT).to.equal(480); | ||
expect(d2).to.have.property('AV_URL'); | ||
expect(d2).to.have.property('cb'); | ||
expect(d2).to.have.property('s2s'); | ||
expect(d2.s2s).to.equal('1'); | ||
expect(d2).to.have.property('pbjs'); | ||
expect(d2.pbjs).to.equal(1); | ||
expect(r2).to.have.property('url'); | ||
expect(r2.url).to.contain('https://gov.aniview.com/api/adserver/vast3/'); | ||
}); | ||
|
||
it('Test 1 request', function () { | ||
const requests = spec.buildRequests(bid1Request); | ||
expect(requests.length).to.equal(1); | ||
const r = requests[0]; | ||
const d = requests[0].data; | ||
expect(d).to.have.property('AV_PUBLISHERID'); | ||
expect(d.AV_PUBLISHERID).to.equal('123456'); | ||
expect(d).to.have.property('AV_CHANNELID'); | ||
expect(d.AV_CHANNELID).to.equal('123456'); | ||
expect(d).to.have.property('AV_WIDTH'); | ||
expect(d.AV_WIDTH).to.equal(640); | ||
expect(d).to.have.property('AV_HEIGHT'); | ||
expect(d.AV_HEIGHT).to.equal(480); | ||
expect(d).to.have.property('AV_URL'); | ||
expect(d).to.have.property('cb'); | ||
expect(d).to.have.property('s2s'); | ||
expect(d.s2s).to.equal('1'); | ||
expect(d).to.have.property('pbjs'); | ||
expect(d.pbjs).to.equal(1); | ||
expect(r).to.have.property('url'); | ||
expect(r.url).to.contain('https://gov.aniview.com/api/adserver/vast3/'); | ||
}); | ||
}); | ||
|
||
describe('interpretResponse', function () { | ||
let bidRequest = { | ||
'url': 'https://gov.aniview.com/api/adserver/vast3/', | ||
'data': { | ||
'bidId': '253dcb69fb2577', | ||
AV_PUBLISHERID: '55b78633181f4603178b4568', | ||
AV_CHANNELID: '55b7904d181f46410f8b4568', | ||
} | ||
}; | ||
let serverResponse = {}; | ||
serverResponse.body = '<?xml version="1.0" encoding="UTF-8"?><VAST version="2.0"><Ad id="FORD"><InLine><AdSystem>FORD</AdSystem><AdTitle>FORD</AdTitle><Impression><![CDATA[http://manage.newmanage.aniview.com/track?d=&cou=IL&cos=Android&r=play.aniview.com&rs=play.aniview.com&sid=71720&t=1549448635&cip=46.116.196.171&sn=&tgt=0&osv=6&bv=&brn=Chrome&wi=640&he=480&app=&AV_PUBLISHERID=55b78633181f4603178b4568&test=&aafaid=&cb=4293171175&asid=55b78d94181f46290f8b456a&pid=55b78633181f4603178b4568&cid=55b7904d181f46410f8b4568&h=b304444f9f8c28b12421555fef487f08e954c587&e=impression]]></Impression><Creatives><Creative><Linear><Duration>00:00:15</Duration><TrackingEvents><Tracking event="start"><![CDATA[http://manage.newmanage.aniview.com/track?d=&cou=IL&cos=Android&r=play.aniview.com&rs=play.aniview.com&sid=71720&t=1549448635&cip=46.116.196.171&sn=&tgt=0&osv=6&bv=&brn=Chrome&wi=640&he=480&app=&AV_PUBLISHERID=55b78633181f4603178b4568&test=&aafaid=&cb=4293171175&asid=55b78d94181f46290f8b456a&pid=55b78633181f4603178b4568&cid=55b7904d181f46410f8b4568&h=b304444f9f8c28b12421555fef487f08e954c587&e=start]]></Tracking><Tracking event="firstQuartile"><![CDATA[http://manage.newmanage.aniview.com/track?d=&cou=IL&cos=Android&r=play.aniview.com&rs=play.aniview.com&sid=71720&t=1549448635&cip=46.116.196.171&sn=&tgt=0&osv=6&bv=&brn=Chrome&wi=640&he=480&app=&AV_PUBLISHERID=55b78633181f4603178b4568&test=&aafaid=&cb=4293171175&asid=55b78d94181f46290f8b456a&pid=55b78633181f4603178b4568&cid=55b7904d181f46410f8b4568&h=b304444f9f8c28b12421555fef487f08e954c587&e=firstQuartile]]></Tracking><Tracking event="midpoint"><![CDATA[http://manage.newmanage.aniview.com/track?d=&cou=IL&cos=Android&r=play.aniview.com&rs=play.aniview.com&sid=71720&t=1549448635&cip=46.116.196.171&sn=&tgt=0&osv=6&bv=&brn=Chrome&wi=640&he=480&app=&AV_PUBLISHERID=55b78633181f4603178b4568&test=&aafaid=&cb=4293171175&asid=55b78d94181f46290f8b456a&pid=55b78633181f4603178b4568&cid=55b7904d181f46410f8b4568&h=b304444f9f8c28b12421555fef487f08e954c587&e=midpoint]]></Tracking><Tracking event="thirdQuartile"><![CDATA[http://manage.newmanage.aniview.com/track?d=&cou=IL&cos=Android&r=play.aniview.com&rs=play.aniview.com&sid=71720&t=1549448635&cip=46.116.196.171&sn=&tgt=0&osv=6&bv=&brn=Chrome&wi=640&he=480&app=&AV_PUBLISHERID=55b78633181f4603178b4568&test=&aafaid=&cb=4293171175&asid=55b78d94181f46290f8b456a&pid=55b78633181f4603178b4568&cid=55b7904d181f46410f8b4568&h=b304444f9f8c28b12421555fef487f08e954c587&e=thirdQuartile]]></Tracking><Tracking event="complete"><![CDATA[http://manage.newmanage.aniview.com/track?d=&cou=IL&cos=Android&r=play.aniview.com&rs=play.aniview.com&sid=71720&t=1549448635&cip=46.116.196.171&sn=&tgt=0&osv=6&bv=&brn=Chrome&wi=640&he=480&app=&AV_PUBLISHERID=55b78633181f4603178b4568&test=&aafaid=&cb=4293171175&asid=55b78d94181f46290f8b456a&pid=55b78633181f4603178b4568&cid=55b7904d181f46410f8b4568&h=b304444f9f8c28b12421555fef487f08e954c587&e=complete]]></Tracking><Tracking event="mute"><![CDATA[http://manage.newmanage.aniview.com/track?d=&cou=IL&cos=Android&r=play.aniview.com&rs=play.aniview.com&sid=71720&t=1549448635&cip=46.116.196.171&sn=&tgt=0&osv=6&bv=&brn=Chrome&wi=640&he=480&app=&AV_PUBLISHERID=55b78633181f4603178b4568&test=&aafaid=&cb=4293171175&asid=55b78d94181f46290f8b456a&pid=55b78633181f4603178b4568&cid=55b7904d181f46410f8b4568&h=b304444f9f8c28b12421555fef487f08e954c587&e=mute]]></Tracking><Tracking event="unmute"><![CDATA[http://manage.newmanage.aniview.com/track?d=&cou=IL&cos=Android&r=play.aniview.com&rs=play.aniview.com&sid=71720&t=1549448635&cip=46.116.196.171&sn=&tgt=0&osv=6&bv=&brn=Chrome&wi=640&he=480&app=&AV_PUBLISHERID=55b78633181f4603178b4568&test=&aafaid=&cb=4293171175&asid=55b78d94181f46290f8b456a&pid=55b78633181f4603178b4568&cid=55b7904d181f46410f8b4568&h=b304444f9f8c28b12421555fef487f08e954c587&e=unmute]]></Tracking><Tracking event="pause"><![CDATA[http://manage.newmanage.aniview.com/track?d=&cou=IL&cos=Android&r=play.aniview.com&rs=play.aniview.com&sid=71720&t=1549448635&cip=46.116.196.171&sn=&tgt=0&osv=6&bv=&brn=Chrome&wi=640&he=480&app=&AV_PUBLISHERID=55b78633181f4603178b4568&test=&aafaid=&cb=4293171175&asid=55b78d94181f46290f8b456a&pid=55b78633181f4603178b4568&cid=55b7904d181f46410f8b4568&h=b304444f9f8c28b12421555fef487f08e954c587&e=pause]]></Tracking><Tracking event="resume"><![CDATA[http://manage.newmanage.aniview.com/track?d=&cou=IL&cos=Android&r=play.aniview.com&rs=play.aniview.com&sid=71720&t=1549448635&cip=46.116.196.171&sn=&tgt=0&osv=6&bv=&brn=Chrome&wi=640&he=480&app=&AV_PUBLISHERID=55b78633181f4603178b4568&test=&aafaid=&cb=4293171175&asid=55b78d94181f46290f8b456a&pid=55b78633181f4603178b4568&cid=55b7904d181f46410f8b4568&h=b304444f9f8c28b12421555fef487f08e954c587&e=resume]]></Tracking><Tracking event="fullscreen"><![CDATA[http://manage.newmanage.aniview.com/track?d=&cou=IL&cos=Android&r=play.aniview.com&rs=play.aniview.com&sid=71720&t=1549448635&cip=46.116.196.171&sn=&tgt=0&osv=6&bv=&brn=Chrome&wi=640&he=480&app=&AV_PUBLISHERID=55b78633181f4603178b4568&test=&aafaid=&cb=4293171175&asid=55b78d94181f46290f8b456a&pid=55b78633181f4603178b4568&cid=55b7904d181f46410f8b4568&h=b304444f9f8c28b12421555fef487f08e954c587&e=fullscreen]]></Tracking></TrackingEvents><VideoClicks><ClickTracking><![CDATA[http://manage.newmanage.aniview.com/track?d=&cou=IL&cos=Android&r=play.aniview.com&rs=play.aniview.com&sid=71720&t=1549448635&cip=46.116.196.171&sn=&tgt=0&osv=6&bv=&brn=Chrome&wi=640&he=480&app=&AV_PUBLISHERID=55b78633181f4603178b4568&test=&aafaid=&cb=4293171175&asid=55b78d94181f46290f8b456a&pid=55b78633181f4603178b4568&cid=55b7904d181f46410f8b4568&h=b304444f9f8c28b12421555fef487f08e954c587&e=click]]></ClickTracking><ClickThrough id="VideoHub"><![CDATA[http://www.ford.com/]]></ClickThrough></VideoClicks><MediaFiles><MediaFile height="360" width="480" bitrate="527" type="video/mp4" delivery="progressive"><![CDATA[https://play.aniview.com/clients/ford2.mp4]]></MediaFile></MediaFiles></Linear></Creative></Creatives><Extensions><Extension type="ANIVIEW"><AdServingData><Asid><![CDATA[55b78d94181f46290f8b456a]]></Asid><Nasid><![CDATA[55b78d94181f46290f8b456a]]></Nasid><Cpm><![CDATA[2]]></Cpm><PlayerSettings><![CDATA[{"vpp":1,"fp":0,"maxRPM":0,"vit":3,"nc":"1","mips":0,"mrqs":0,"vpm":0,"vi":0,"t": 1,"res": 5}]]></PlayerSettings></AdServingData></Extension></Extensions></InLine></Ad></VAST>'; | ||
|
||
it('Check bid interpretResponse', function () { | ||
const BIDDER_CODE = 'aniview'; | ||
let bidResponses = spec.interpretResponse(serverResponse, bidRequest); | ||
expect(bidResponses.length).to.equal(1); | ||
let bidResponse = bidResponses[0]; | ||
expect(bidResponse.requestId).to.equal(bidRequest.data.bidId); | ||
expect(bidResponse.bidderCode).to.equal(BIDDER_CODE); | ||
expect(bidResponse.cpm).to.equal('2'); | ||
expect(bidResponse.ttl).to.equal(600); | ||
expect(bidResponse.currency).to.equal('USD'); | ||
expect(bidResponse.netRevenue).to.equal(true); | ||
expect(bidResponse.mediaType).to.equal('video'); | ||
}); | ||
|
||
it('safely handles XML parsing failure from invalid bid response', function () { | ||
let invalidServerResponse = {}; | ||
invalidServerResponse.body = '<Ad id="677477"><InLine></AdSystem></InLine></Ad>'; | ||
|
||
let result = spec.interpretResponse(invalidServerResponse, bidRequest); | ||
expect(result.length).to.equal(0); | ||
}); | ||
|
||
it('handles nobid responses', function () { | ||
let nobidResponse = {}; | ||
nobidResponse.body = '<?xml version=\'1.0\' encoding=\'UTF-8\'?><VAST version=\'2.0\'></VAST>'; | ||
|
||
let result = spec.interpretResponse(nobidResponse, bidRequest); | ||
expect(result.length).to.equal(0); | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bidRequest.sizes may be deprecated in the next major release. Alternative is to use the new bidRequest.mediaTypes object.