diff --git a/modules/adheseBidAdapter.js b/modules/adheseBidAdapter.js index 6ca8c8a6aa6..445c9956410 100644 --- a/modules/adheseBidAdapter.js +++ b/modules/adheseBidAdapter.js @@ -11,7 +11,7 @@ export const spec = { supportedMediaTypes: [BANNER, VIDEO], isBidRequestValid: function(bid) { - return !!(bid.params.account && bid.params.location && bid.params.format); + return !!(bid.params.account && bid.params.location && (bid.params.format || bid.mediaTypes.banner.sizes)); }, buildRequests: function(validBidRequests, bidderRequest) { @@ -83,7 +83,10 @@ function adResponse(bid, ad) { width: Number(ad.width), height: Number(ad.height), creativeId: adDetails.creativeId, - dealId: adDetails.dealId + dealId: adDetails.dealId, + adhese: { + originData: adDetails.originData + } }); if (bidResponse.mediaType === VIDEO) { @@ -112,7 +115,19 @@ function mergeTargets(targets, target) { } function bidToSlotName(bid) { - return bid.params.location + '-' + bid.params.format; + if (bid.params.format) { + return bid.params.location + '-' + bid.params.format; + } + + var sizes = bid.mediaTypes.banner.sizes; + sizes.sort(); + var format = sizes.map(size => size[0] + 'x' + size[1]).join('_'); + + if (format.length > 0) { + return bid.params.location + '-' + format; + } else { + return bid.params.location; + } } function getAccount(validBidRequests) { @@ -150,22 +165,27 @@ function getPrice(ad) { function getAdDetails(ad) { let creativeId = ''; let dealId = ''; + let originData = {}; if (isAdheseAd(ad)) { creativeId = ad.id; dealId = ad.orderId; + originData = { priority: ad.priority, orderProperty: ad.orderProperty, adFormat: ad.adFormat, adType: ad.adType, libId: ad.libId, adspaceId: ad.adspaceId, viewableImpressionCounter: ad.viewableImpressionCounter }; } else { creativeId = ad.origin + (ad.originInstance ? '-' + ad.originInstance : ''); - if (ad.originData && ad.originData.seatbid && ad.originData.seatbid.length) { - const seatbid = ad.originData.seatbid[0]; - if (seatbid.bid && seatbid.bid.length) { - const bid = seatbid.bid[0]; - creativeId = String(bid.crid || ''); - dealId = String(bid.dealid || ''); + if (ad.originData) { + originData = ad.originData; + if (ad.originData.seatbid && ad.originData.seatbid.length) { + const seatbid = ad.originData.seatbid[0]; + if (seatbid.bid && seatbid.bid.length) { + const bid = seatbid.bid[0]; + creativeId = String(bid.crid || ''); + dealId = String(bid.dealid || ''); + } } } } - return { creativeId: creativeId, dealId: dealId }; + return { creativeId: creativeId, dealId: dealId, originData: originData }; } function base64urlEncode(s) { diff --git a/test/spec/modules/adheseBidAdapter_spec.js b/test/spec/modules/adheseBidAdapter_spec.js index 348fb772319..32658e2bb27 100644 --- a/test/spec/modules/adheseBidAdapter_spec.js +++ b/test/spec/modules/adheseBidAdapter_spec.js @@ -153,6 +153,16 @@ describe('AdheseAdapter', function () { mediaType: 'banner', netRevenue: NET_REVENUE, ttl: TTL, + adhese: { + originData: { + seatbid: [ + { + bid: [ { crid: '60613369', dealid: null } ], + seat: '958' + } + ] + } + } }]; expect(spec.interpretResponse(sspBannerResponse, bidRequest)).to.deep.equal(expectedResponse); }); @@ -185,6 +195,7 @@ describe('AdheseAdapter', function () { mediaType: 'video', netRevenue: NET_REVENUE, ttl: TTL, + adhese: { originData: {} } }]; expect(spec.interpretResponse(sspVideoResponse, bidRequest)).to.deep.equal(expectedResponse); }); @@ -235,6 +246,17 @@ describe('AdheseAdapter', function () { let expectedResponse = [{ requestId: BID_ID, ad: '', + adhese: { + originData: { + adFormat: 'largeleaderboard', + adType: 'largeleaderboard', + adspaceId: '162363', + libId: '90511', + orderProperty: undefined, + priority: undefined, + viewableImpressionCounter: undefined + } + }, cpm: 5.96, currency: 'USD', creativeId: '742898', @@ -279,6 +301,17 @@ describe('AdheseAdapter', function () { let expectedResponse = [{ requestId: BID_ID, vastXml: '', + adhese: { + originData: { + adFormat: '', + adType: 'preroll', + adspaceId: '164196', + libId: '89860', + orderProperty: undefined, + priority: undefined, + viewableImpressionCounter: undefined + } + }, cpm: 0, currency: 'USD', creativeId: '742470',