From 621a88dfad295e2905f0cdae21536b92d60256ff Mon Sep 17 00:00:00 2001 From: Andy Rusiecki Date: Wed, 18 May 2022 08:03:49 -0400 Subject: [PATCH] Kargo Bid Adapter: adding media type to bid response, supporting vastXml response (#8426) * kargo adapter - adding mediaType to bid response, conditionally set vastXml field * kargo adapter - updating tests --- modules/kargoBidAdapter.js | 31 +++++++++++---- test/spec/modules/kargoBidAdapter_spec.js | 48 +++++++++++++++++++++-- 2 files changed, 68 insertions(+), 11 deletions(-) diff --git a/modules/kargoBidAdapter.js b/modules/kargoBidAdapter.js index 098e38b2c43..1842231721b 100644 --- a/modules/kargoBidAdapter.js +++ b/modules/kargoBidAdapter.js @@ -70,27 +70,42 @@ export const spec = { const bidResponses = []; for (let bidId in bids) { let adUnit = bids[bidId]; - let meta; + let meta = { + mediaType: BANNER + }; + if (adUnit.metadata && adUnit.metadata.landingPageDomain) { - meta = { - clickUrl: adUnit.metadata.landingPageDomain[0], - advertiserDomains: adUnit.metadata.landingPageDomain - }; + meta.clickUrl = adUnit.metadata.landingPageDomain[0]; + meta.advertiserDomains = adUnit.metadata.landingPageDomain; + } + + if (adUnit.mediaType && SUPPORTED_MEDIA_TYPES.includes(adUnit.mediaType)) { + meta.mediaType = adUnit.mediaType; } - bidResponses.push({ + + const bidResponse = { requestId: bidId, cpm: Number(adUnit.cpm), width: adUnit.width, height: adUnit.height, - ad: adUnit.adm, ttl: 300, creativeId: adUnit.id, dealId: adUnit.targetingCustom, netRevenue: true, currency: adUnit.currency || bidRequest.currency, + mediaType: meta.mediaType, meta: meta - }); + }; + + if (meta.mediaType == VIDEO) { + bidResponse.vastXml = adUnit.adm; + } else { + bidResponse.ad = adUnit.adm; + } + + bidResponses.push(bidResponse); } + return bidResponses; }, getUserSyncs: function(syncOptions, responses, gdprConsent, usPrivacy) { diff --git a/test/spec/modules/kargoBidAdapter_spec.js b/test/spec/modules/kargoBidAdapter_spec.js index 6f5a0008783..1515ed0820e 100644 --- a/test/spec/modules/kargoBidAdapter_spec.js +++ b/test/spec/modules/kargoBidAdapter_spec.js @@ -451,6 +451,17 @@ describe('kargo adapter tests', function () { adm: '
', width: 300, height: 250, + mediaType: 'banner', + metadata: {}, + currency: 'EUR' + }, + 5: { + id: 'bar', + cpm: 2.5, + adm: '', + width: 300, + height: 250, + mediaType: 'video', metadata: {}, currency: 'EUR' } @@ -476,6 +487,11 @@ describe('kargo adapter tests', function () { params: { placementId: 'bar' } + }, { + bidId: 5, + params: { + placementId: 'bar' + } }] }); var expectation = [{ @@ -489,7 +505,10 @@ describe('kargo adapter tests', function () { dealId: undefined, netRevenue: true, currency: 'USD', - meta: undefined + mediaType: 'banner', + meta: { + mediaType: 'banner' + } }, { requestId: '2', cpm: 2.5, @@ -501,7 +520,9 @@ describe('kargo adapter tests', function () { dealId: 'dmpmptest1234', netRevenue: true, currency: 'USD', + mediaType: 'banner', meta: { + mediaType: 'banner', clickUrl: 'https://foobar.com', advertiserDomains: ['https://foobar.com'] } @@ -516,7 +537,10 @@ describe('kargo adapter tests', function () { dealId: undefined, netRevenue: true, currency: 'USD', - meta: undefined + mediaType: 'banner', + meta: { + mediaType: 'banner' + } }, { requestId: '4', cpm: 2.5, @@ -528,7 +552,25 @@ describe('kargo adapter tests', function () { dealId: undefined, netRevenue: true, currency: 'EUR', - meta: undefined + mediaType: 'banner', + meta: { + mediaType: 'banner' + } + }, { + requestId: '5', + cpm: 2.5, + width: 300, + height: 250, + vastXml: '', + ttl: 300, + creativeId: 'bar', + dealId: undefined, + netRevenue: true, + currency: 'EUR', + mediaType: 'video', + meta: { + mediaType: 'video' + } }]; expect(resp).to.deep.equal(expectation); });