From 1a04f1f3097c179d33d81784af652e7cf8e75212 Mon Sep 17 00:00:00 2001 From: Rachel Joyce Date: Wed, 26 Jul 2017 15:48:19 -0600 Subject: [PATCH 01/19] Update Sovrn adapter. Add test coverage. Enable deal IDs. --- modules/sovrnBidAdapter.js | 112 +++++++------ test/spec/modules/sovrnBidAdapter_spec.js | 184 +++++++++++----------- 2 files changed, 143 insertions(+), 153 deletions(-) diff --git a/modules/sovrnBidAdapter.js b/modules/sovrnBidAdapter.js index 209cdab11d9..e5c1623bb3a 100644 --- a/modules/sovrnBidAdapter.js +++ b/modules/sovrnBidAdapter.js @@ -91,67 +91,63 @@ var SovrnAdapter = function SovrnAdapter() { // expose the callback to the global object: $$PREBID_GLOBAL$$.sovrnResponse = function (sovrnResponseObj) { - // valid object? - if (sovrnResponseObj && sovrnResponseObj.id) { - // valid object w/ bid responses? - if (sovrnResponseObj.seatbid && sovrnResponseObj.seatbid.length !== 0 && sovrnResponseObj.seatbid[0].bid && sovrnResponseObj.seatbid[0].bid.length !== 0) { - var impidsWithBidBack = []; - sovrnResponseObj.seatbid[0].bid.forEach(function (sovrnBid) { - var responseCPM; - var placementCode = ''; - var id = sovrnBid.impid; - var bid = {}; - - // try to fetch the bid request we sent Sovrn - var bidObj = $$PREBID_GLOBAL$$._bidsRequested.find(bidSet => bidSet.bidderCode === 'sovrn').bids - .find(bid => bid.bidId === id); - - if (bidObj) { - placementCode = bidObj.placementCode; - bidObj.status = CONSTANTS.STATUS.GOOD; - - // place ad response on bidmanager._adResponsesByBidderId - responseCPM = parseFloat(sovrnBid.price); - - if (responseCPM !== 0) { - sovrnBid.placementCode = placementCode; - sovrnBid.size = bidObj.sizes; - var responseAd = sovrnBid.adm; - - // build impression url from response - var responseNurl = ''; - - // store bid response - // bid status is good (indicating 1) - bid = bidfactory.createBid(1, bidObj); - bid.creative_id = sovrnBid.id; - bid.bidderCode = 'sovrn'; - bid.cpm = responseCPM; - - // set ad content + impression url - // sovrn returns