Skip to content

Commit

Permalink
Triplelift Adaptor: Use Floors Module (prebid#5329)
Browse files Browse the repository at this point in the history
* access floor from floors module

* int -> float and null check

* let -> const
  • Loading branch information
colbertk authored and iggyfisk committed Jun 22, 2020
1 parent e918caa commit 8a13aa6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
18 changes: 17 additions & 1 deletion modules/tripleliftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function _buildPostBody(bidRequests) {
return {
id: index,
tagid: bid.params.inventoryCode,
floor: bid.params.floor,
floor: _getFloor(bid),
banner: {
format: _sizes(bid.sizes)
}
Expand All @@ -138,6 +138,22 @@ function _buildPostBody(bidRequests) {
return data;
}

function _getFloor (bid) {
let floor = null;
if (typeof bid.getFloor === 'function') {
const floorInfo = bid.getFloor({
currency: 'USD',
mediaType: 'banner',
size: _sizes(bid.sizes)
});
if (typeof floorInfo === 'object' &&
floorInfo.currency === 'USD' && !isNaN(parseFloat(floorInfo.floor))) {
floor = parseFloat(floorInfo.floor);
}
}
return floor !== null ? floor : bid.params.floor;
}

function getUnifiedIdEids(bidRequests) {
return getEids(bidRequests, 'tdid', 'adserver.org', 'TDID');
}
Expand Down
9 changes: 9 additions & 0 deletions test/spec/modules/tripleliftBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@ describe('triplelift adapter', function () {
const { data: payload } = request;
expect(payload.ext).to.deep.equal(undefined);
});
it('should get floor from floors module if available', function() {
const floorInfo = {
currency: 'USD',
floor: 1.99
};
bidRequests[0].getFloor = () => floorInfo;
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
expect(request.data.imp[0].floor).to.equal(1.99);
});
});

describe('interpretResponse', function () {
Expand Down

0 comments on commit 8a13aa6

Please sign in to comment.