Skip to content

Commit

Permalink
Adhese Bid Adapter: mediaType in extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Pawel L committed Mar 29, 2021
1 parent 55bd9b4 commit 3065ca8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
13 changes: 4 additions & 9 deletions modules/adheseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function adResponse(bid, ad) {

const bidResponse = getbaseAdResponse({
requestId: bid.bidId,
mediaType: getMediaType(ad.cachedBodyUrl, markup),
mediaType: ad.extension.mediaType,
cpm: Number(price.amount),
currency: price.currency,
width: Number(ad.width),
Expand All @@ -111,10 +111,10 @@ function adResponse(bid, ad) {
});

if (bidResponse.mediaType === VIDEO) {
if (markup) {
bidResponse.vastXml = markup;
} else {
if (ad.cachedBodyUrl) {
bidResponse.vastUrl = ad.cachedBodyUrl
} else {
bidResponse.vastXml = markup;
}
} else {
const counter = ad.impressionCounter ? "<img src='" + ad.impressionCounter + "' style='height:1px; width:1px; margin: -1px -1px; display:none;'/>" : '';
Expand Down Expand Up @@ -177,11 +177,6 @@ function isAdheseAd(ad) {
return !ad.origin || ad.origin === 'JERLICIA';
}

function getMediaType(cachedBodyUrl, markup) {
const isVideo = cachedBodyUrl !== undefined || markup.trim().toLowerCase().match(/<\?xml|<vast/);
return isVideo ? VIDEO : BANNER;
}

function getAdMarkup(ad) {
if (!isAdheseAd(ad) || (ad.ext === 'js' && ad.body !== undefined && ad.body !== '' && ad.body.match(/<script|<SCRIPT|<html|<HTML|<\?xml/))) {
return ad.body
Expand Down
17 changes: 12 additions & 5 deletions test/spec/modules/adheseBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ describe('AdheseAdapter', function () {
body: '<div style="background-color:red; height:250px; width:300px"></div>',
tracker: 'https://hosts-demo.adhese.com/rtb_gateway/handlers/client/track/?id=a2f39296-6dd0-4b3c-be85-7baa22e7ff4a',
impressionCounter: 'https://hosts-demo.adhese.com/rtb_gateway/handlers/client/track/?id=a2f39296-6dd0-4b3c-be85-7baa22e7ff4a',
extension: {'prebid': {'cpm': {'amount': '1.000000', 'currency': 'USD'}}}
extension: {'prebid': {'cpm': {'amount': '1.000000', 'currency': 'USD'}}, mediaType: 'banner'}
}
]
};
Expand Down Expand Up @@ -233,7 +233,7 @@ describe('AdheseAdapter', function () {
width: '640',
height: '350',
body: '<?xml version="1.0" encoding="UTF-8"?><VAST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:noNamespaceSchemaLocation="vast.xsd"></VAST>',
extension: {'prebid': {'cpm': {'amount': '2.1', 'currency': 'USD'}}}
extension: {'prebid': {'cpm': {'amount': '2.1', 'currency': 'USD'}}, mediaType: 'video'}
}
]
};
Expand Down Expand Up @@ -270,7 +270,7 @@ describe('AdheseAdapter', function () {
width: '640',
height: '350',
cachedBodyUrl: 'https://ads-demo.adhese.com/content/38983ccc-4083-4c24-932c-96f798d969b3',
extension: {'prebid': {'cpm': {'amount': '2.1', 'currency': 'USD'}}}
extension: {'prebid': {'cpm': {'amount': '2.1', 'currency': 'USD'}}, mediaType: 'video'}
}
]
};
Expand Down Expand Up @@ -333,7 +333,8 @@ describe('AdheseAdapter', function () {
amount: '5.96',
currency: 'USD'
}
}
},
mediaType: 'banner'
}
}
]
Expand Down Expand Up @@ -395,7 +396,10 @@ describe('AdheseAdapter', function () {
impressionCounter: 'https://hosts-demo.adhese.com/track/742898',
origin: 'JERLICIA',
originData: {},
auctionable: true
auctionable: true,
extension: {
mediaType: 'video'
}
}
]
};
Expand Down Expand Up @@ -444,6 +448,9 @@ describe('AdheseAdapter', function () {
body: '<ADHESE_BODY>',
height: '360',
width: '640',
extension: {
mediaType: 'video'
},
cachedBodyUrl: 'https://ads-demo.adhese.com/content/38983ccc-4083-4c24-932c-96f798d969b3',
libId: '89860',
id: '742470',
Expand Down

0 comments on commit 3065ca8

Please sign in to comment.