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

Marsmedia - Add vastXml and fix id response #5067

Merged
merged 13 commits into from
Apr 13, 2020
15 changes: 10 additions & 5 deletions modules/marsmediaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function MarsmediaAdapter() {
let SUPPORTED_VIDEO_API = [1, 2, 5];
let slotsToBids = {};
let that = this;
let version = '2.1';
let version = '2.2';

this.isBidRequestValid = function (bid) {
return !!(bid.params && bid.params.zoneId);
Expand Down Expand Up @@ -172,7 +172,7 @@ function MarsmediaAdapter() {
}
},
at: 1,
tmax: 1000,
tmax: 650,
regs: {
ext: {
gdpr: utils.deepAccess(bidderRequest, 'gdprConsent.gdprApplies') ? Boolean(bidderRequest.gdprConsent.gdprApplies & 1) : false
Expand Down Expand Up @@ -203,7 +203,7 @@ function MarsmediaAdapter() {
return [];
}

var uri = 'https://bid306.rtbsrv.com/bidder/?bid=3mhdom&zoneId=' + fallbackZoneId;
var uri = 'https://hb.azeriondigital.com/bidder/?bid=3mhdom&zoneId=' + fallbackZoneId;

var fat = /(^v|(\.0)+$)/gi;
var prebidVersion = '$prebid.version$';
Expand Down Expand Up @@ -240,7 +240,7 @@ function MarsmediaAdapter() {
let bid = responses[i];
let bidRequest = slotsToBids[bid.impid];
let bidResponse = {
requestId: bidRequest.id,
requestId: bidRequest.bidId,
bidderCode: that.code,
cpm: parseFloat(bid.price),
width: bid.w,
Expand All @@ -252,12 +252,17 @@ function MarsmediaAdapter() {
};

if (bidRequest.mediaTypes && bidRequest.mediaTypes.video) {
bidResponse.vastUrl = bid.adm;
if (bid.adm.charAt(0) === '<') {
bidResponse.vastXml = bid.adm;
} else {
bidResponse.vastUrl = bid.adm;
}
bidResponse.mediaType = 'video';
bidResponse.ttl = 600;
} else {
bidResponse.ad = bid.adm;
}

bids.push(bidResponse);
}

Expand Down
39 changes: 36 additions & 3 deletions test/spec/modules/marsmediaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('marsmedia adapter tests', function () {

var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest);

expect(bidRequest.url).to.have.string('https://bid306.rtbsrv.com/bidder/?bid=3mhdom&zoneId=9999&hbv=');
expect(bidRequest.url).to.have.string('https://hb.azeriondigital.com/bidder/?bid=3mhdom&zoneId=9999&hbv=');
expect(bidRequest.method).to.equal('POST');
const openrtbRequest = JSON.parse(bidRequest.data);
expect(openrtbRequest.site).to.not.equal(null);
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('marsmedia adapter tests', function () {

var bidRequest = r1adapter.buildRequests(bidRequestList, this.defaultBidderRequest);

expect(bidRequest.url).to.have.string('https://bid306.rtbsrv.com/bidder/?bid=3mhdom&zoneId=9999&hbv=');
expect(bidRequest.url).to.have.string('https://hb.azeriondigital.com/bidder/?bid=3mhdom&zoneId=9999&hbv=');
expect(bidRequest.method).to.equal('POST');
const openrtbRequest = JSON.parse(bidRequest.data);
expect(openrtbRequest.site).to.not.equal(null);
Expand All @@ -127,7 +127,7 @@ describe('marsmedia adapter tests', function () {
expect(openrtbRequest.imp[0].video.api).to.eql([1, 2, 5]);
});

it('interpretResponse works', function() {
it('interpretResponse with vast url works', function() {
var bidList = {
'body': [
{
Expand Down Expand Up @@ -159,6 +159,39 @@ describe('marsmedia adapter tests', function () {
expect(bid.cpm).to.equal(1.0);
expect(bid.ttl).to.equal(600);
});

it('interpretResponse with xml works', function() {
var bidList = {
'body': [
{
'impid': 'div-gpt-ad-1438287399331-1',
'price': 1,
'adm': '<?xml><VAST></VAST>',
'adomain': [
'test.com'
],
'cid': '467415',
'crid': 'cr-vid',
'w': 800,
'h': 600
}
]
};

var videoBids = r1adapter.interpretResponse(bidList);

expect(videoBids.length).to.equal(1);
const bid = videoBids[0];
expect(bid.width).to.equal(800);
expect(bid.height).to.equal(600);
expect(bid.vastXml).to.equal('<?xml><VAST></VAST>');
expect(bid.mediaType).to.equal('video');
expect(bid.creativeId).to.equal('cr-vid');
expect(bid.currency).to.equal('USD');
expect(bid.netRevenue).to.equal(true);
expect(bid.cpm).to.equal(1.0);
expect(bid.ttl).to.equal(600);
});
});

describe('misc buildRequests', function() {
Expand Down