Skip to content

Commit

Permalink
use floor module
Browse files Browse the repository at this point in the history
  • Loading branch information
Aiholkin committed Jan 20, 2021
1 parent 32c71f2 commit f0c5c24
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
28 changes: 16 additions & 12 deletions modules/colossussspBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion test/spec/modules/colossussspBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit f0c5c24

Please sign in to comment.