Skip to content

Commit

Permalink
Kargo Bid Adapter: adding media type to bid response, supporting vast…
Browse files Browse the repository at this point in the history
…Xml response (#8426)

* kargo adapter - adding mediaType to bid response, conditionally set vastXml field

* kargo adapter - updating tests
  • Loading branch information
andyrusiecki authored May 18, 2022
1 parent 34622e3 commit 621a88d
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 11 deletions.
31 changes: 23 additions & 8 deletions modules/kargoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
48 changes: 45 additions & 3 deletions test/spec/modules/kargoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,17 @@ describe('kargo adapter tests', function () {
adm: '<div id="4"></div>',
width: 300,
height: 250,
mediaType: 'banner',
metadata: {},
currency: 'EUR'
},
5: {
id: 'bar',
cpm: 2.5,
adm: '<VAST></VAST>',
width: 300,
height: 250,
mediaType: 'video',
metadata: {},
currency: 'EUR'
}
Expand All @@ -476,6 +487,11 @@ describe('kargo adapter tests', function () {
params: {
placementId: 'bar'
}
}, {
bidId: 5,
params: {
placementId: 'bar'
}
}]
});
var expectation = [{
Expand All @@ -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,
Expand All @@ -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']
}
Expand All @@ -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,
Expand All @@ -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: '<VAST></VAST>',
ttl: 300,
creativeId: 'bar',
dealId: undefined,
netRevenue: true,
currency: 'EUR',
mediaType: 'video',
meta: {
mediaType: 'video'
}
}];
expect(resp).to.deep.equal(expectation);
});
Expand Down

0 comments on commit 621a88d

Please sign in to comment.