Skip to content

Commit

Permalink
TheMediaGrid: fix creativeId value (prebid#10130)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMediaGrid authored Jun 21, 2023
1 parent 5bfac11 commit 39cc772
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
7 changes: 3 additions & 4 deletions modules/gridBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js
export const storage = getStorageManager({ bidderCode: BIDDER_CODE });

const LOG_ERROR_MESS = {
noAuid: 'Bid from response has no auid parameter - ',
noAdid: 'Bid from response has no adid parameter - ',
noAdm: 'Bid from response has no adm parameter - ',
noBid: 'Array of bid objects is empty',
noPlacementCode: 'Can\'t find in requested bids the bid with auid - ',
emptyUids: 'Uids should be not empty',
emptySeatbid: 'Seatbid array from response has empty item',
emptyResponse: 'Response is empty',
Expand Down Expand Up @@ -507,7 +506,7 @@ function _getBidFromResponse(respItem) {
function _addBidResponse(serverBid, bidRequest, bidResponses, RendererConst, bidderCode) {
if (!serverBid) return;
let errorMessage;
if (!serverBid.auid) errorMessage = LOG_ERROR_MESS.noAuid + JSON.stringify(serverBid);
if (!serverBid.adid) errorMessage = LOG_ERROR_MESS.noAdid + JSON.stringify(serverBid);
if (!errorMessage && !serverBid.adm && !serverBid.nurl) errorMessage = LOG_ERROR_MESS.noAdm + JSON.stringify(serverBid);
else {
const bidObject = bidRequest.bidsMap ? bidRequest.bidsMap[serverBid.impid] : bidRequest.bidObject;
Expand All @@ -518,7 +517,7 @@ function _addBidResponse(serverBid, bidRequest, bidResponses, RendererConst, bid
cpm: serverBid.price,
width: serverBid.w,
height: serverBid.h,
creativeId: serverBid.auid, // bid.bidId
creativeId: serverBid.adid,
currency: 'USD',
netRevenue: true,
ttl: TIME_TO_LIVE,
Expand Down
57 changes: 29 additions & 28 deletions test/spec/modules/gridBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -911,11 +911,11 @@ describe('TheMediaGrid Adapter', function () {

describe('interpretResponse', function () {
const responses = [
{'bid': [{'impid': '659423fff799cb', 'price': 1.15, 'adm': '<div>test content 1</div>', 'auid': 1, 'h': 250, 'w': 300, 'dealid': 11}], 'seat': '1'},
{'bid': [{'impid': '4dff80cc4ee346', 'price': 0.5, 'adm': '<div>test content 2</div>', 'auid': 2, 'h': 600, 'w': 300}], 'seat': '1'},
{'bid': [{'impid': '5703af74d0472a', 'price': 0.15, 'adm': '<div>test content 3</div>', 'auid': 1, 'h': 90, 'w': 728}], 'seat': '1'},
{'bid': [{'impid': '2344da98f78b42', 'price': 0, 'auid': 3, 'h': 250, 'w': 300}], 'seat': '1'},
{'bid': [{'price': 0, 'adm': '<div>test content 5</div>', 'h': 250, 'w': 300}], 'seat': '1'},
{'bid': [{'impid': '659423fff799cb', 'adid': '13_14_4353', 'price': 1.15, 'adm': '<div>test content 1</div>', 'auid': 1, 'h': 250, 'w': 300, 'dealid': 11}], 'seat': '1'},
{'bid': [{'impid': '4dff80cc4ee346', 'adid': '13_15_6454', 'price': 0.5, 'adm': '<div>test content 2</div>', 'auid': 2, 'h': 600, 'w': 300}], 'seat': '1'},
{'bid': [{'impid': '5703af74d0472a', 'adid': '13_16_7654', 'price': 0.15, 'adm': '<div>test content 3</div>', 'auid': 1, 'h': 90, 'w': 728}], 'seat': '1'},
{'bid': [{'impid': '2344da98f78b42', 'adid': '13_17_5433', 'price': 0, 'auid': 3, 'h': 250, 'w': 300}], 'seat': '1'},
{'bid': [{'price': 0, 'adid': '13_18_34645', 'adm': '<div>test content 5</div>', 'h': 250, 'w': 300}], 'seat': '1'},
undefined,
{'bid': [], 'seat': '1'},
{'seat': '1'},
Expand All @@ -940,7 +940,7 @@ describe('TheMediaGrid Adapter', function () {
{
'requestId': '659423fff799cb',
'cpm': 1.15,
'creativeId': 1,
'creativeId': '13_14_4353',
'dealId': 11,
'width': 300,
'height': 250,
Expand Down Expand Up @@ -1000,7 +1000,7 @@ describe('TheMediaGrid Adapter', function () {
{
'requestId': '659423fff799cb',
'cpm': 1.15,
'creativeId': 1,
'creativeId': '13_14_4353',
'dealId': 11,
'width': 300,
'height': 250,
Expand All @@ -1016,7 +1016,7 @@ describe('TheMediaGrid Adapter', function () {
{
'requestId': '4dff80cc4ee346',
'cpm': 0.5,
'creativeId': 2,
'creativeId': '13_15_6454',
'dealId': undefined,
'width': 300,
'height': 600,
Expand All @@ -1032,7 +1032,7 @@ describe('TheMediaGrid Adapter', function () {
{
'requestId': '5703af74d0472a',
'cpm': 0.15,
'creativeId': 1,
'creativeId': '13_16_7654',
'dealId': undefined,
'width': 728,
'height': 90,
Expand Down Expand Up @@ -1135,18 +1135,18 @@ describe('TheMediaGrid Adapter', function () {
}
];
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': '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': '112432ab4f34', 'price': 1.80, 'adm': '<VAST version=\"3.0\">\n<Ad id=\"32115432\"><\/Ad>\n<\/VAST>', 'nurl': 'https://wrong_url.com', 'auid': 14, content_type: 'video', 'adomain': ['example.com'], w: 300, h: 600}], 'seat': '2'},
{'bid': [{'impid': 'a74b342f8cd', 'price': 1.50, 'nurl': '', 'auid': 15, content_type: 'video'}], 'seat': '2'}
{'bid': [{'impid': '659423fff799cb', 'adid': '35_56_6454', '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', 'adid': '35_57_2344', 'price': 1.00, 'adm': '<VAST version=\"3.0\">\n<Ad id=\"21331274\"><\/Ad>\n<\/VAST>', content_type: 'video'}], 'seat': '2'},
{'bid': [{'impid': '23312a43bc42', 'adid': '35_58_5345', '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': '112432ab4f34', 'adid': '35_59_56756', 'price': 1.80, 'adm': '<VAST version=\"3.0\">\n<Ad id=\"32115432\"><\/Ad>\n<\/VAST>', 'nurl': 'https://wrong_url.com', 'auid': 14, content_type: 'video', 'adomain': ['example.com'], w: 300, h: 600}], 'seat': '2'},
{'bid': [{'impid': 'a74b342f8cd', 'adid': '35_60_523452', 'price': 1.50, 'nurl': '', 'auid': 15, content_type: 'video'}], 'seat': '2'}
];
const [request] = spec.buildRequests(bidRequests);
const expectedResponse = [
{
'requestId': '659423fff799cb',
'cpm': 1.15,
'creativeId': 11,
'creativeId': '35_56_6454',
'dealId': undefined,
'width': 300,
'height': 600,
Expand All @@ -1165,7 +1165,7 @@ describe('TheMediaGrid Adapter', function () {
{
'requestId': '2bc598e42b6a',
'cpm': 1.00,
'creativeId': 12,
'creativeId': '35_57_2344',
'dealId': undefined,
'width': undefined,
'height': undefined,
Expand All @@ -1184,7 +1184,7 @@ describe('TheMediaGrid Adapter', function () {
{
'requestId': '23312a43bc42',
'cpm': 2.00,
'creativeId': 13,
'creativeId': '35_58_5345',
'dealId': undefined,
'width': 300,
'height': 600,
Expand All @@ -1200,7 +1200,7 @@ describe('TheMediaGrid Adapter', function () {
{
'requestId': '112432ab4f34',
'cpm': 1.80,
'creativeId': 14,
'creativeId': '35_59_56756',
'dealId': undefined,
'width': 300,
'height': 600,
Expand Down Expand Up @@ -1265,11 +1265,11 @@ describe('TheMediaGrid Adapter', function () {

it('complicated case', function () {
const fullResponse = [
{'bid': [{'impid': '2164be6358b9', 'price': 1.15, 'adm': '<div>test content 1</div>', 'auid': 1, 'h': 250, 'w': 300, dealid: 11}], 'seat': '1'},
{'bid': [{'impid': '4e111f1b66e4', 'price': 0.5, 'adm': '<div>test content 2</div>', 'auid': 2, 'h': 600, 'w': 300, dealid: 12}], 'seat': '1'},
{'bid': [{'impid': '26d6f897b516', 'price': 0.15, 'adm': '<div>test content 3</div>', 'auid': 1, 'h': 90, 'w': 728}], 'seat': '1'},
{'bid': [{'impid': '326bde7fbf69', 'price': 0.15, 'adm': '<div>test content 4</div>', 'auid': 1, 'h': 600, 'w': 300}], 'seat': '1'},
{'bid': [{'impid': '2234f233b22a', 'price': 0.5, 'adm': '<div>test content 5</div>', 'auid': 2, 'h': 600, 'w': 350}], 'seat': '1'},
{'bid': [{'impid': '2164be6358b9', 'adid': '32_52_7543', 'price': 1.15, 'adm': '<div>test content 1</div>', 'auid': 1, 'h': 250, 'w': 300, dealid: 11}], 'seat': '1'},
{'bid': [{'impid': '4e111f1b66e4', 'adid': '32_54_4535', 'price': 0.5, 'adm': '<div>test content 2</div>', 'auid': 2, 'h': 600, 'w': 300, dealid: 12}], 'seat': '1'},
{'bid': [{'impid': '26d6f897b516', 'adid': '32_53_75467', 'price': 0.15, 'adm': '<div>test content 3</div>', 'auid': 1, 'h': 90, 'w': 728}], 'seat': '1'},
{'bid': [{'impid': '326bde7fbf69', 'adid': '32_54_12342', 'price': 0.15, 'adm': '<div>test content 4</div>', 'auid': 1, 'h': 600, 'w': 300}], 'seat': '1'},
{'bid': [{'impid': '2234f233b22a', 'adid': '32_55_987686', 'price': 0.5, 'adm': '<div>test content 5</div>', 'auid': 2, 'h': 600, 'w': 350}], 'seat': '1'},
];
const bidRequests = [
{
Expand Down Expand Up @@ -1333,7 +1333,7 @@ describe('TheMediaGrid Adapter', function () {
{
'requestId': '2164be6358b9',
'cpm': 1.15,
'creativeId': 1,
'creativeId': '32_52_7543',
'dealId': 11,
'width': 300,
'height': 250,
Expand All @@ -1349,7 +1349,7 @@ describe('TheMediaGrid Adapter', function () {
{
'requestId': '4e111f1b66e4',
'cpm': 0.5,
'creativeId': 2,
'creativeId': '32_54_4535',
'dealId': 12,
'width': 300,
'height': 600,
Expand All @@ -1365,7 +1365,7 @@ describe('TheMediaGrid Adapter', function () {
{
'requestId': '26d6f897b516',
'cpm': 0.15,
'creativeId': 1,
'creativeId': '32_53_75467',
'dealId': undefined,
'width': 728,
'height': 90,
Expand All @@ -1381,7 +1381,7 @@ describe('TheMediaGrid Adapter', function () {
{
'requestId': '326bde7fbf69',
'cpm': 0.15,
'creativeId': 1,
'creativeId': '32_54_12342',
'dealId': undefined,
'width': 300,
'height': 600,
Expand Down Expand Up @@ -1421,6 +1421,7 @@ describe('TheMediaGrid Adapter', function () {
'price': 1.15,
'adm': '<div>test content 1</div>',
'auid': 1,
'adid': '234_6454_3453',
'h': 250,
'w': 300,
'dealid': 11,
Expand All @@ -1440,7 +1441,7 @@ describe('TheMediaGrid Adapter', function () {
{
'requestId': '26d6f897b516',
'cpm': 1.15,
'creativeId': 1,
'creativeId': '234_6454_3453',
'dealId': 11,
'width': 300,
'height': 250,
Expand Down

0 comments on commit 39cc772

Please sign in to comment.