From 0cf7c75d2019d0be566a15bd3af951c298781801 Mon Sep 17 00:00:00 2001 From: Fatih Kaya Date: Mon, 1 May 2023 14:27:13 +0300 Subject: [PATCH] AdMatic Bid Adapter: added Video / Banner params (#9856) * Admatic Bidder Adaptor * Update admaticBidAdapter.md * Update admaticBidAdapter.md * remove floor parameter * Update admaticBidAdapter.js * Admatic Bid Adapter: alias and bid floor features activated * Admatic adapter: host param control changed * Alias name changed. * Revert "Admatic adapter: host param control changed" This reverts commit de7ac85981b1ba3ad8c5d1dc95c5dadbdf5b9895. * added alias feature and host param * Revert "added alias feature and host param" This reverts commit 6ec8f4539ea6be403a0d7e08dad5c7a5228f28a1. * Revert "Alias name changed." This reverts commit 661c54f9b2397e8f25c257144d73161e13466281. * Revert "Admatic Bid Adapter: alias and bid floor features activated" This reverts commit 7a2e0e29c49e2f876b68aafe886b336fe2fe6fcb. * Revert "Update admaticBidAdapter.js" This reverts commit 7a845b7151bbb08addfb58ea9bd5b44167cc8a4e. * Revert "remove floor parameter" This reverts commit 7a23b055ccd4ea23d23e73248e82b21bc6f69d90. * Admatic adapter: host param control && Add new Bidder * Revert "Admatic adapter: host param control && Add new Bidder" This reverts commit 3c797b120c8e0fe2b851381300ac5c4b1f92c6e2. * commit new features * Update admaticBidAdapter.js * updated for coverage * sync updated * Update adloader.js * AdMatic Bidder: development of user sync url * Update admaticBidAdapter.js * Set currency for AdserverCurrency: bug fix * Update admaticBidAdapter.js * update * admatic adapter video params update * Update admaticBidAdapter.js * update * Update admaticBidAdapter.js * update * update * Update admaticBidAdapter_spec.js * Update admaticBidAdapter.js * Update admaticBidAdapter.js * Revert "Update admaticBidAdapter.js" This reverts commit 1216892fe55e5ab24dda8e045ea007ee6bb40ff8. * Revert "Update admaticBidAdapter.js" This reverts commit b1929ece33bb4040a3bcd6b9332b50335356829c. * Revert "Update admaticBidAdapter_spec.js" This reverts commit 1ca659798b0c9b912634b1673e15e54e547b81e7. * Revert "update" This reverts commit 689ce9d21e08c27be49adb35c5fd5205aef5c35c. * Revert "update" This reverts commit f381a453f9389bebd58dcfa719e9ec17f939f338. * Revert "Update admaticBidAdapter.js" This reverts commit 38fd7abec701d8a4750f9e95eaeb40fb67e9f0e6. * Revert "update" This reverts commit a5316e74b612a5b2cd16cf42586334321fc87770. * Revert "Update admaticBidAdapter.js" This reverts commit 60a28cae302b711366dab0bff9f49b11862fb8ee. * Revert "admatic adapter video params update" This reverts commit 31e69e88fd9355e143f736754ac2e47fe49b65b6. * update --- modules/admaticBidAdapter.js | 37 ++++- test/spec/modules/admaticBidAdapter_spec.js | 175 ++++++++++++++++++-- 2 files changed, 196 insertions(+), 16 deletions(-) diff --git a/modules/admaticBidAdapter.js b/modules/admaticBidAdapter.js index c216c66c78e..027f924ac5d 100644 --- a/modules/admaticBidAdapter.js +++ b/modules/admaticBidAdapter.js @@ -34,7 +34,7 @@ export const spec = { */ buildRequests: (validBidRequests, bidderRequest) => { const bids = validBidRequests.map(buildRequestObject); - const blacklist = bidderRequest.ortb2 || {}; + const blacklist = bidderRequest.ortb2; const networkId = getValue(validBidRequests[0].params, 'networkId'); const host = getValue(validBidRequests[0].params, 'host'); const currency = config.getConfig('currency.adServerCurrency') || 'TRY'; @@ -93,7 +93,7 @@ export const spec = { * @return {Bid[]} */ interpretResponse: (response, request) => { - const body = response.body || response; + const body = response.body; const bidResponses = []; if (body && body?.data && isArray(body.data)) { body.data.forEach(bid => { @@ -104,13 +104,23 @@ export const spec = { height: bid.height, currency: body.cur || 'TRY', netRevenue: true, - ad: bid.party_tag, creativeId: bid.creative_id, meta: { advertiserDomains: bid && bid.adomain ? bid.adomain : [] }, - ttl: 360, - bidder: bid.bidder + bidder: bid.bidder, + mediaType: bid.type, + ttl: 60 + }; + + if (resbid.mediaType === 'video' && isUrl(bid.party_tag)) { + resbid.vastUrl = bid.party_tag; + resbid.vastImpUrl = bid.iurl; + } else if (resbid.mediaType === 'video') { + resbid.vastXml = bid.party_tag; + resbid.vastImpUrl = bid.iurl; + } else if (resbid.mediaType === 'banner') { + resbid.ad = bid.party_tag; }; bidResponses.push(resbid); @@ -120,6 +130,15 @@ export const spec = { } }; +function isUrl(str) { + try { + URL(str); + return true; + } catch (error) { + return false; + } +}; + function enrichSlotWithFloors(slot, bidRequest) { try { const slotFloors = {}; @@ -168,6 +187,14 @@ function parseSize(size) { function buildRequestObject(bid) { const reqObj = {}; reqObj.size = getSizes(bid); + if (bid.mediaTypes?.banner) { + reqObj.type = 'banner'; + reqObj.mediatype = {}; + } + if (bid.mediaTypes?.video) { + reqObj.type = 'video'; + reqObj.mediatype = bid.mediaTypes.video; + } reqObj.id = getBidIdParameter('bidId', bid); enrichSlotWithFloors(reqObj, bid); diff --git a/test/spec/modules/admaticBidAdapter_spec.js b/test/spec/modules/admaticBidAdapter_spec.js index ce4a4a2f0fb..1d2fb1e79cb 100644 --- a/test/spec/modules/admaticBidAdapter_spec.js +++ b/test/spec/modules/admaticBidAdapter_spec.js @@ -22,11 +22,13 @@ describe('admaticBidAdapter', () => { 'host': 'layer.serve.admatic.com.tr' }, 'adUnitCode': 'adunit-code', + 'mediaType': 'banner', 'sizes': [[300, 250], [300, 600]], 'bidId': '30b31c1838de1e', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', - 'creativeId': 'er2ee' + 'creativeId': 'er2ee', + 'ortb2': { 'badv': ['admatic.com.tr'] } }; it('should return true when required params found', function() { @@ -34,15 +36,11 @@ describe('admaticBidAdapter', () => { }); it('should return false when required params are not passed', function() { - let bid = Object.assign({}, bid); - delete bid.params; - - bid.params = { - 'networkId': 0, - 'host': 'layer.serve.admatic.com.tr' + let bid2 = {}; + bid2.params = { + 'someIncorrectParam': 0 }; - - expect(spec.isBidRequestValid(bid)).to.equal(false); + expect(spec.isBidRequestValid(bid2)).to.equal(false); }); }); @@ -54,6 +52,7 @@ describe('admaticBidAdapter', () => { 'networkId': 10433394, 'host': 'layer.serve.admatic.com.tr' }, + 'ortb2': { 'badv': ['admatic.com.tr'] }, 'mediaTypes': { 'banner': { 'sizes': [[300, 250], [728, 90]] @@ -98,6 +97,8 @@ describe('admaticBidAdapter', () => { 'h': 90 } ], + 'mediatype': {}, + 'type': 'banner', 'id': '2205da7a81846b', 'floors': { 'banner': { @@ -105,6 +106,49 @@ describe('admaticBidAdapter', () => { '728x90': { 'currency': 'USD', 'floor': 2 } } } + }, + { + 'size': [ + { + 'w': 338, + 'h': 280 + } + ], + 'type': 'video', + 'mediatype': { + 'context': 'instream', + 'mimes': [ + 'video/mp4' + ], + 'maxduration': 240, + 'api': [ + 1, + 2 + ], + 'playerSize': [ + [ + 338, + 280 + ] + ], + 'protocols': [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + 'skip': 1, + 'playbackmethod': [ + 2 + ], + 'linearity': 1, + 'placement': 2 + }, + 'id': '45e86fc7ce7fc93' } ], 'ext': { @@ -118,6 +162,7 @@ describe('admaticBidAdapter', () => { 'networkId': 10433394, 'host': 'layer.serve.admatic.com.tr' }, + 'ortb2': { 'badv': ['admatic.com.tr'] }, 'mediaTypes': { 'banner': { 'sizes': [[300, 250], [728, 90]] @@ -163,12 +208,57 @@ describe('admaticBidAdapter', () => { } ], 'id': '2205da7a81846b', + 'mediatype': {}, + 'type': 'banner', 'floors': { 'banner': { '300x250': { 'currency': 'USD', 'floor': 1 }, '728x90': { 'currency': 'USD', 'floor': 2 } } } + }, + { + 'size': [ + { + 'w': 338, + 'h': 280 + } + ], + 'type': 'video', + 'mediatype': { + 'context': 'instream', + 'mimes': [ + 'video/mp4' + ], + 'maxduration': 240, + 'api': [ + 1, + 2 + ], + 'playerSize': [ + [ + 338, + 280 + ] + ], + 'protocols': [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + 'skip': 1, + 'playbackmethod': [ + 2 + ], + 'linearity': 1, + 'placement': 2 + }, + 'id': '45e86fc7ce7fc93' } ], 'ext': { @@ -194,6 +284,7 @@ describe('admaticBidAdapter', () => { 'sizes': [[300, 250], [728, 90]] } }, + 'ortb2': { 'badv': ['admatic.com.tr'] }, getFloor: inputParams => { if (inputParams.mediaType === BANNER && inputParams.size[0] === 300 && inputParams.size[1] === 250) { return { @@ -217,6 +308,7 @@ describe('admaticBidAdapter', () => { 'networkId': 10433394, 'host': 'layer.serve.admatic.com.tr' }, + 'ortb2': { 'badv': ['admatic.com.tr'] }, 'adUnitCode': 'adunit-code', 'sizes': [[300, 250], [728, 90]], 'bidId': '30b31c1838de1e', @@ -249,9 +341,35 @@ describe('admaticBidAdapter', () => { 'width': 300, 'height': 250, 'price': 0.01, + 'type': 'banner', 'bidder': 'admatic', 'adomain': ['admatic.com.tr'], - 'party_tag': '
' + 'party_tag': '
', + 'iurl': 'https://www.admatic.com.tr' + }, + { + 'id': 2, + 'creative_id': '3741', + 'width': 300, + 'height': 250, + 'price': 0.01, + 'type': 'video', + 'bidder': 'admatic', + 'adomain': ['admatic.com.tr'], + 'party_tag': '', + 'iurl': 'https://www.admatic.com.tr' + }, + { + 'id': 3, + 'creative_id': '3741', + 'width': 300, + 'height': 250, + 'price': 0.01, + 'type': 'video', + 'bidder': 'admatic', + 'adomain': ['admatic.com.tr'], + 'party_tag': 'https://www.admatic.com.tr', + 'iurl': 'https://www.admatic.com.tr' } ], 'queryId': 'cdnbh24rlv0hhkpfpln0', @@ -265,13 +383,48 @@ describe('admaticBidAdapter', () => { width: 300, height: 250, currency: 'TRY', + mediaType: 'banner', netRevenue: true, ad: '
', creativeId: '374', meta: { advertiserDomains: ['admatic.com.tr'] }, - ttl: 360, + ttl: 60, + bidder: 'admatic' + }, + { + requestId: 2, + cpm: 0.01, + width: 300, + height: 250, + currency: 'TRY', + mediaType: 'video', + netRevenue: true, + vastImpUrl: 'https://www.admatic.com.tr', + vastXml: '', + creativeId: '3741', + meta: { + advertiserDomains: ['admatic.com.tr'] + }, + ttl: 60, + bidder: 'admatic' + }, + { + requestId: 3, + cpm: 0.01, + width: 300, + height: 250, + currency: 'TRY', + mediaType: 'video', + netRevenue: true, + vastImpUrl: 'https://www.admatic.com.tr', + vastXml: 'https://www.admatic.com.tr', + creativeId: '3741', + meta: { + advertiserDomains: ['admatic.com.tr'] + }, + ttl: 60, bidder: 'admatic' } ];