diff --git a/modules/synacormediaBidAdapter.js b/modules/synacormediaBidAdapter.js
index 6725f5aff74..abbae1e7354 100644
--- a/modules/synacormediaBidAdapter.js
+++ b/modules/synacormediaBidAdapter.js
@@ -172,7 +172,7 @@ export const spec = {
.filter(param => includes(VIDEO_PARAMS, param) && sourceObj[param] !== null && (!isNaN(parseInt(sourceObj[param], 10)) || !(sourceObj[param].length < 1)))
.forEach(param => destObj[param] = Array.isArray(sourceObj[param]) ? sourceObj[param] : parseInt(sourceObj[param], 10));
},
- interpretResponse: function(serverResponse) {
+ interpretResponse: function(serverResponse, bidRequest) {
const updateMacros = (bid, r) => {
return r ? r.replace(/\${AUCTION_PRICE}/g, bid.price) : r;
};
@@ -189,8 +189,33 @@ export const spec = {
seatbid.bid.forEach(bid => {
const creative = updateMacros(bid, bid.adm);
const nurl = updateMacros(bid, bid.nurl);
- const [, impType, impid, width, height] = bid.impid.match(/^([vb])(.*)-(.*)x(.*)$/);
- const isVideo = impType == 'v';
+ const [, impType, impid] = bid.impid.match(/^([vb])(.*)$/);
+ let height = bid.h;
+ let width = bid.w;
+ const isVideo = impType === 'v';
+ const isBanner = impType === 'b';
+ if ((!height || !width) && bidRequest.data && bidRequest.data.imp && bidRequest.data.imp.length > 0) {
+ bidRequest.data.imp.forEach(req => {
+ if (bid.impid === req.id) {
+ if (isVideo) {
+ height = req.video.h;
+ width = req.video.w;
+ } else if (isBanner) {
+ let bannerHeight = 1;
+ let bannerWidth = 1;
+ if (req.banner.format && req.banner.format.length > 0) {
+ bannerHeight = req.banner.format[0].h;
+ bannerWidth = req.banner.format[0].w;
+ }
+ height = bannerHeight;
+ width = bannerWidth;
+ } else {
+ height = 1;
+ width = 1;
+ }
+ }
+ });
+ }
const bidObj = {
requestId: impid,
adId: bid.id.replace(/~/g, '-'),
diff --git a/test/spec/modules/synacormediaBidAdapter_spec.js b/test/spec/modules/synacormediaBidAdapter_spec.js
index d9f6c9b7256..1521f4a2e63 100644
--- a/test/spec/modules/synacormediaBidAdapter_spec.js
+++ b/test/spec/modules/synacormediaBidAdapter_spec.js
@@ -688,21 +688,50 @@ describe('synacormediaBidAdapter ', function () {
describe('interpretResponse', function () {
let bidResponse = {
id: '10865933907263896~9998~0',
- impid: 'b9876abcd-300x250',
+ impid: 'b9876abcd',
price: 0.13,
crid: '1022-250',
adm: '',
- nurl: 'https://uat-net.technoratimedia.com/openrtb/tags?ID=k5JkFVQ1RJT05fSU1QX0lEPXYyZjczN&AUCTION_PRICE=${AUCTION_PRICE}'
+ nurl: 'https://uat-net.technoratimedia.com/openrtb/tags?ID=k5JkFVQ1RJT05fSU1QX0lEPXYyZjczN&AUCTION_PRICE=${AUCTION_PRICE}',
+ w: 300,
+ h: 250
};
let bidResponse2 = {
id: '10865933907263800~9999~0',
- impid: 'b9876abcd-300x600',
+ impid: 'b9876abcd',
price: 1.99,
crid: '9993-013',
adm: '',
- nurl: 'https://uat-net.technoratimedia.com/openrtb/tags?ID=OTk5OX4wJkFVQ1RJT05fU0VBVF9JR&AUCTION_PRICE=${AUCTION_PRICE}'
+ nurl: 'https://uat-net.technoratimedia.com/openrtb/tags?ID=OTk5OX4wJkFVQ1RJT05fU0VBVF9JR&AUCTION_PRICE=${AUCTION_PRICE}',
+ w: 300,
+ h: 600
};
+ let bidRequest = {
+ data: {
+ id: '',
+ imp: [
+ {
+ id: 'abc123',
+ banner: {
+ format: [
+ {
+ w: 400,
+ h: 350
+ }
+ ],
+ pos: 1
+ }
+ }
+ ],
+ },
+ method: 'POST',
+ options: {
+ contentType: 'application/json',
+ withCredentials: true
+ },
+ url: 'https://prebid.technoratimedia.com/openrtb/bids/prebid?src=prebid_prebid_3.27.0-pre'
+ };
let serverResponse;
beforeEach(function() {
serverResponse = {
@@ -717,6 +746,26 @@ describe('synacormediaBidAdapter ', function () {
});
it('should return 1 video bid when 1 bid is in the video response', function () {
+ bidRequest = {
+ data: {
+ id: 'abcd1234',
+ imp: [
+ {
+ video: {
+ w: 640,
+ h: 480
+ },
+ id: 'v2da7322b2df61f'
+ }
+ ]
+ },
+ method: 'POST',
+ options: {
+ contentType: 'application/json',
+ withCredentials: true
+ },
+ url: 'https://prebid.technoratimedia.com/openrtb/bids/prebid?src=prebid_prebid_3.27.0-pre'
+ };
let serverRespVideo = {
body: {
id: 'abcd1234',
@@ -725,14 +774,16 @@ describe('synacormediaBidAdapter ', function () {
bid: [
{
id: '11339128001692337~9999~0',
- impid: 'v2da7322b2df61f-640x480',
+ impid: 'v2da7322b2df61f',
price: 0.45,
nurl: 'https://uat-net.technoratimedia.com/openrtb/tags?ID=QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk&AUCTION_PRICE=${AUCTION_PRICE}',
adm: '\n\n\n\nSynacor Media Ad Server - 9999\nhttps://uat-net.technoratimedia.com/openrtb/tags?ID=QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk&AUCTION_PRICE=${AUCTION_PRICE}\n\n\n',
adomain: [ 'psacentral.org' ],
cid: 'bidder-crid',
crid: 'bidder-cid',
- cat: []
+ cat: [],
+ w: 640,
+ h: 480
}
],
seat: '9999'
@@ -742,7 +793,7 @@ describe('synacormediaBidAdapter ', function () {
};
// serverResponse.body.seatbid[0].bid.push(bidResponse);
- let resp = spec.interpretResponse(serverRespVideo);
+ let resp = spec.interpretResponse(serverRespVideo, bidRequest);
expect(resp).to.be.an('array').to.have.lengthOf(1);
expect(resp[0]).to.eql({
requestId: '2da7322b2df61f',
@@ -763,7 +814,7 @@ describe('synacormediaBidAdapter ', function () {
it('should return 1 bid when 1 bid is in the response', function () {
serverResponse.body.seatbid[0].bid.push(bidResponse);
- let resp = spec.interpretResponse(serverResponse);
+ let resp = spec.interpretResponse(serverResponse, bidRequest);
expect(resp).to.be.an('array').to.have.lengthOf(1);
expect(resp[0]).to.eql({
requestId: '9876abcd',
@@ -786,7 +837,7 @@ describe('synacormediaBidAdapter ', function () {
seat: '9999',
bid: [bidResponse2],
});
- let resp = spec.interpretResponse(serverResponse);
+ let resp = spec.interpretResponse(serverResponse, bidRequest);
expect(resp).to.be.an('array').to.have.lengthOf(2);
expect(resp[0]).to.eql({
requestId: '9876abcd',
@@ -818,7 +869,7 @@ describe('synacormediaBidAdapter ', function () {
});
it('should not return a bid when no bid is in the response', function () {
- let resp = spec.interpretResponse(serverResponse);
+ let resp = spec.interpretResponse(serverResponse, bidRequest);
expect(resp).to.be.an('array').that.is.empty;
});
@@ -837,14 +888,16 @@ describe('synacormediaBidAdapter ', function () {
bid: [
{
id: '11339128001692337~9999~0',
- impid: 'v2da7322b2df61f-640x480',
+ impid: 'v2da7322b2df61f',
price: 0.45,
nurl: 'https://uat-net.technoratimedia.com/openrtb/tags?ID=QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk&AUCTION_PRICE=${AUCTION_PRICE}',
adm: '\n\n\n\nSynacor Media Ad Server - 9999\nhttps://uat-net.technoratimedia.com/openrtb/tags?ID=QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk&AUCTION_PRICE=${AUCTION_PRICE}\n\n\n',
adomain: [ 'psacentral.org' ],
cid: 'bidder-crid',
crid: 'bidder-cid',
- cat: []
+ cat: [],
+ w: 640,
+ h: 480
}
],
seat: '9999'
@@ -860,10 +913,125 @@ describe('synacormediaBidAdapter ', function () {
return config[key];
});
- let resp = spec.interpretResponse(serverRespVideo);
+ let resp = spec.interpretResponse(serverRespVideo, bidRequest);
sandbox.restore();
expect(resp[0].videoCacheKey).to.not.exist;
});
+
+ it('should use video bid request height and width if not present in response', function () {
+ bidRequest = {
+ data: {
+ id: 'abcd1234',
+ imp: [
+ {
+ video: {
+ w: 300,
+ h: 250
+ },
+ id: 'v2da7322b2df61f'
+ }
+ ]
+ },
+ method: 'POST',
+ options: {
+ contentType: 'application/json',
+ withCredentials: true
+ },
+ url: 'https://prebid.technoratimedia.com/openrtb/bids/prebid?src=prebid_prebid_3.27.0-pre'
+ };
+
+ let serverRespVideo = {
+ body: {
+ id: 'abcd1234',
+ seatbid: [
+ {
+ bid: [
+ {
+ id: '11339128001692337~9999~0',
+ impid: 'v2da7322b2df61f',
+ price: 0.45,
+ nurl: 'https://uat-net.technoratimedia.com/openrtb/tags?ID=QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk&AUCTION_PRICE=${AUCTION_PRICE}',
+ adm: '\n\n\n\nSynacor Media Ad Server - 9999\nhttps://uat-net.technoratimedia.com/openrtb/tags?ID=QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk&AUCTION_PRICE=${AUCTION_PRICE}\n\n\n',
+ adomain: [ 'psacentral.org' ],
+ cid: 'bidder-crid',
+ crid: 'bidder-cid',
+ cat: []
+ }
+ ],
+ seat: '9999'
+ }
+ ]
+ }
+ };
+ let resp = spec.interpretResponse(serverRespVideo, bidRequest);
+ expect(resp).to.be.an('array').to.have.lengthOf(1);
+ expect(resp[0]).to.eql({
+ requestId: '2da7322b2df61f',
+ adId: '11339128001692337-9999-0',
+ cpm: 0.45,
+ width: 300,
+ height: 250,
+ creativeId: '9999_bidder-cid',
+ currency: 'USD',
+ netRevenue: true,
+ mediaType: 'video',
+ ad: '\n\n\n\nSynacor Media Ad Server - 9999\nhttps://uat-net.technoratimedia.com/openrtb/tags?ID=QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk&AUCTION_PRICE=0.45\n\n\n',
+ ttl: 60,
+ videoCacheKey: 'QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk',
+ vastUrl: 'https://uat-net.technoratimedia.com/openrtb/tags?ID=QVVDVElPTl9JRD1lOTBhYWU1My1hZDkwLTRkNDEtYTQxMC1lZDY1MjIxMDc0ZGMmQVVDVElPTl9CSURfSUQ9MTEzMzkxMjgwMDE2OTIzMzd-OTk5OX4wJkFVQ1RJT05fU0VBVF9JRD05OTk5JkFVQ1RJT05fSU1QX0lEPXYyZGE3MzIyYjJkZjYxZi02NDB4NDgwJkFDVE9SX1JFRj1ha2thLnRjcDovL2F3cy1lYXN0MUBhZHMxMy5jYXAtdXNlMS5zeW5hY29yLmNvbToyNTUxL3VzZXIvJGNMYmZiIy0xOTk4NTIzNTk3JlNFQVRfSUQ9cHJlYmlk&AUCTION_PRICE=0.45'
+ });
+ });
+
+ it('should use banner bid request height and width if not present in response', function () {
+ bidRequest = {
+ data: {
+ id: 'abc123',
+ imp: [
+ {
+ banner: {
+ format: [{
+ w: 400,
+ h: 350
+ }]
+ },
+ id: 'babc123'
+ }
+ ]
+ },
+ method: 'POST',
+ options: {
+ contentType: 'application/json',
+ withCredentials: true
+ },
+ url: 'https://prebid.technoratimedia.com/openrtb/bids/prebid?src=prebid_prebid_3.27.0-pre'
+ };
+
+ bidResponse = {
+ id: '10865933907263896~9998~0',
+ impid: 'babc123',
+ price: 0.13,
+ crid: '1022-250',
+ adm: '',
+ nurl: 'https://uat-net.technoratimedia.com/openrtb/tags?ID=k5JkFVQ1RJT05fSU1QX0lEPXYyZjczN&AUCTION_PRICE=${AUCTION_PRICE}',
+ };
+
+ serverResponse.body.seatbid[0].bid.push(bidResponse);
+ let resp = spec.interpretResponse(serverResponse, bidRequest);
+ expect(resp).to.be.an('array').to.have.lengthOf(1);
+ expect(resp[0]).to.eql({
+ requestId: 'abc123',
+ adId: '10865933907263896-9998-0',
+ cpm: 0.13,
+ width: 400,
+ height: 350,
+ creativeId: '9998_1022-250',
+ currency: 'USD',
+ netRevenue: true,
+ mediaType: BANNER,
+ ad: '',
+ ttl: 60
+ });
+ });
});
describe('getUserSyncs', function () {
it('should return a usersync when iframes is enabled', function () {