From f0c5c248627567e669d8eed4f2bb9a26a857e2ad Mon Sep 17 00:00:00 2001 From: Aiholkin Date: Wed, 20 Jan 2021 21:20:40 +0200 Subject: [PATCH] use floor module --- modules/colossussspBidAdapter.js | 28 +++++++++++-------- package-lock.json | 2 +- .../modules/colossussspBidAdapter_spec.js | 3 +- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/modules/colossussspBidAdapter.js b/modules/colossussspBidAdapter.js index 7c42210756c..1afb343566d 100644 --- a/modules/colossussspBidAdapter.js +++ b/modules/colossussspBidAdapter.js @@ -56,15 +56,8 @@ export const spec = { * @return ServerRequest Info describing the request to the server. */ buildRequests: (validBidRequests, bidderRequest) => { - let winTop = window; - let location; - try { - location = new URL(bidderRequest.refererInfo.referer) - winTop = window.top; - } catch (e) { - location = winTop.location; - utils.logMessage(e); - }; + const winTop = utils.getWindowTop(); + const location = winTop.location; let placements = []; let request = { 'deviceWidth': winTop.screen.width, @@ -94,10 +87,21 @@ export const spec = { bidId: bid.bidId, sizes: bid.mediaTypes[traff].sizes, traffic: traff, - eids: [] + eids: [], + floor: {} }; - if (!isNaN(bid.params.bidfloor)) { - placement.bidfloor = Number(bid.params.bidfloor); + if (typeof bid.getFloor === 'function') { + let tmpFloor = {}; + for (let size of placement.sizes) { + tmpFloor = bid.getFloor({ + currency: 'USD', + mediaType: traff, + size: size + }); + if (tmpFloor) { + placement.floor[`${size[0]}x${size[1]}`] = tmpFloor.floor; + } + } } if (bid.schain) { placement.schain = bid.schain; diff --git a/package-lock.json b/package-lock.json index 330298cbaac..f98f4c19764 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "prebid.js", - "version": "4.15.0-pre", + "version": "4.23.0-pre", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/test/spec/modules/colossussspBidAdapter_spec.js b/test/spec/modules/colossussspBidAdapter_spec.js index b241d0602b2..f6e24d07c63 100644 --- a/test/spec/modules/colossussspBidAdapter_spec.js +++ b/test/spec/modules/colossussspBidAdapter_spec.js @@ -88,12 +88,13 @@ describe('ColossussspAdapter', function () { let placements = data['placements']; for (let i = 0; i < placements.length; i++) { let placement = placements[i]; - expect(placement).to.have.all.keys('placementId', 'eids', 'bidId', 'traffic', 'sizes', 'schain'); + expect(placement).to.have.all.keys('placementId', 'eids', 'bidId', 'traffic', 'sizes', 'schain', 'floor'); expect(placement.schain).to.be.an('object') expect(placement.placementId).to.be.a('number'); expect(placement.bidId).to.be.a('string'); expect(placement.traffic).to.be.a('string'); expect(placement.sizes).to.be.an('array'); + expect(placement.floor).to.be.an('object'); } }); it('Returns empty data if no valid requests are passed', function () {