-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08e3c52
commit 0bc782c
Showing
5 changed files
with
60 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { VIDEO } from '../../src/mediaTypes.js'; | ||
import { deepAccess, isFn } from '../../src/utils.js'; | ||
|
||
const DEFAULT_FLOOR = 0.0; | ||
|
||
/** | ||
* Get floors from Prebid Price Floors module | ||
* | ||
* @param {object} bid Bid request object | ||
* @param {string} currency Ad server currency | ||
* @param {string} mediaType Bid media type | ||
* @return {number} Floor price | ||
*/ | ||
export function getBidFloor (bid, currency, mediaType) { | ||
const floors = []; | ||
|
||
if (isFn(bid.getFloor)) { | ||
(deepAccess(bid, `mediaTypes.${mediaType}.${mediaType === VIDEO ? 'playerSize' : 'sizes'}`) || []).forEach(size => { | ||
const floor = bid.getFloor({ | ||
currency: currency || 'USD', | ||
mediaType, | ||
size | ||
}).floor; | ||
|
||
floors.push(!isNaN(floor) ? floor : DEFAULT_FLOOR); | ||
}); | ||
} | ||
|
||
return floors.length ? Math.min(...floors) : DEFAULT_FLOOR; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters