Skip to content

Commit

Permalink
TheMediaGrid: added support nurl field in ad response
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMediaGrid committed Sep 7, 2021
1 parent d16e2ec commit 0631d97
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 6 deletions.
15 changes: 10 additions & 5 deletions modules/gridBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ function _addBidResponse(serverBid, bidRequest, bidResponses) {
if (!serverBid) return;
let errorMessage;
if (!serverBid.auid) errorMessage = LOG_ERROR_MESS.noAuid + JSON.stringify(serverBid);
if (!serverBid.adm) errorMessage = LOG_ERROR_MESS.noAdm + JSON.stringify(serverBid);
if (!errorMessage && !serverBid.adm && !serverBid.nurl) errorMessage = LOG_ERROR_MESS.noAdm + JSON.stringify(serverBid);
else {
const bid = bidRequest.bidsMap[serverBid.impid];
if (bid) {
Expand All @@ -368,11 +368,16 @@ function _addBidResponse(serverBid, bidRequest, bidResponses) {
}

if (serverBid.content_type === 'video') {
bidResponse.vastXml = serverBid.adm;
if (serverBid.adm) {
bidResponse.vastXml = serverBid.adm;
bidResponse.adResponse = {
content: bidResponse.vastXml
};
}
if (serverBid.nurl) {
bidResponse.vastUrl = serverBid.nurl;
}
bidResponse.mediaType = VIDEO;
bidResponse.adResponse = {
content: bidResponse.vastXml
};
if (!bid.renderer && (!bid.mediaTypes || !bid.mediaTypes.video || bid.mediaTypes.video.context === 'outstream')) {
bidResponse.renderer = createRenderer(bidResponse, {
id: bid.bidId,
Expand Down
52 changes: 51 additions & 1 deletion test/spec/modules/gridBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -756,11 +756,45 @@ describe('TheMediaGrid Adapter', function () {
'context': 'instream'
}
}
},
{
'bidder': 'grid',
'params': {
'uid': '13'
},
'adUnitCode': 'adunit-code-2',
'sizes': [[300, 250], [300, 600]],
'bidId': '23312a43bc42',
'bidderRequestId': '5f2009617a7c0a',
'auctionId': '1cbd2feafe5e8b',
'mediaTypes': {
'video': {
'context': 'instream'
}
}
},
{
'bidder': 'grid',
'params': {
'uid': '14'
},
'adUnitCode': 'adunit-code-2',
'sizes': [[300, 250], [300, 600]],
'bidId': 'a74b342f8cd',
'bidderRequestId': '5f2009617a7c0a',
'auctionId': '1cbd2feafe5e8b',
'mediaTypes': {
'video': {
'context': 'instream'
}
}
}
];
const response = [
{'bid': [{'impid': '659423fff799cb', 'price': 1.15, 'adm': '<VAST version=\"3.0\">\n<Ad id=\"21341234\"><\/Ad>\n<\/VAST>', 'auid': 11, content_type: 'video', w: 300, h: 600}], 'seat': '2'},
{'bid': [{'impid': '2bc598e42b6a', 'price': 1.00, 'adm': '<VAST version=\"3.0\">\n<Ad id=\"21331274\"><\/Ad>\n<\/VAST>', 'auid': 12, content_type: 'video'}], 'seat': '2'}
{'bid': [{'impid': '2bc598e42b6a', 'price': 1.00, 'adm': '<VAST version=\"3.0\">\n<Ad id=\"21331274\"><\/Ad>\n<\/VAST>', 'auid': 12, content_type: 'video'}], 'seat': '2'},
{'bid': [{'impid': '23312a43bc42', 'price': 2.00, 'nurl': 'https://some_test_vast_url.com', 'auid': 13, content_type: 'video', 'adomain': ['example.com'], w: 300, h: 600}], 'seat': '2'},
{'bid': [{'impid': 'a74b342f8cd', 'price': 1.50, 'nurl': '', 'auid': 14, content_type: 'video'}], 'seat': '2'}
];
const request = spec.buildRequests(bidRequests);
const expectedResponse = [
Expand Down Expand Up @@ -801,6 +835,22 @@ describe('TheMediaGrid Adapter', function () {
'adResponse': {
'content': '<VAST version=\"3.0\">\n<Ad id=\"21331274\"><\/Ad>\n<\/VAST>'
}
},
{
'requestId': '23312a43bc42',
'cpm': 2.00,
'creativeId': 13,
'dealId': undefined,
'width': 300,
'height': 600,
'currency': 'USD',
'mediaType': 'video',
'netRevenue': true,
'ttl': 360,
'meta': {
advertiserDomains: ['example.com']
},
'vastUrl': 'https://some_test_vast_url.com',
}
];

Expand Down

0 comments on commit 0631d97

Please sign in to comment.