Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AOL Bid Adapter: add support for the floors module #6657

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions modules/aolBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,23 @@ function getSupportedEids(bid) {
});
}

function getBidFloor(bid) {
if (!utils.isFn(bid.getFloor)) {
return (bid.params.bidFloor) ? bid.params.bidFloor : null;
}

let floor = bid.getFloor({
currency: 'USD',
mediaType: '*',
size: '*'
});

if (utils.isPlainObject(floor) && !isNaN(floor.floor) && floor.currency === 'USD') {
return floor.floor;
}
return null;
}

export const spec = {
code: AOL_BIDDERS_CODES.AOL,
gvlid: 25,
Expand Down Expand Up @@ -214,6 +231,7 @@ export const spec = {
const params = bid.params;
const serverParam = params.server;
let regionParam = params.region || 'us';
let bidFloor = getBidFloor(bid);
let server;

if (!MP_SERVER_MAP.hasOwnProperty(regionParam)) {
Expand All @@ -238,7 +256,7 @@ export const spec = {
sizeid: params.sizeId || 0,
alias: params.alias || utils.getUniqueIdentifierStr(),
misc: new Date().getTime(), // cache busting
dynamicParams: this.formatMarketplaceDynamicParams(params, consentData)
dynamicParams: this.formatMarketplaceDynamicParams(params, consentData, bidFloor)
}));
},
buildOneMobileGetUrl(bid, consentData) {
Expand Down Expand Up @@ -268,11 +286,11 @@ export const spec = {
}
return (url.indexOf('//') === 0) ? `${DEFAULT_PROTO}:${url}` : `${DEFAULT_PROTO}://${url}`;
},
formatMarketplaceDynamicParams(params = {}, consentData = {}) {
formatMarketplaceDynamicParams(params = {}, consentData = {}, bidFloor = {}) {
let queryParams = {};

if (params.bidFloor) {
queryParams.bidfloor = params.bidFloor;
if (bidFloor) {
queryParams.bidfloor = bidFloor;
}

Object.assign(queryParams, this.formatKeyValues(params.keyValues));
Expand Down
14 changes: 14 additions & 0 deletions test/spec/modules/aolBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,20 @@ describe('AolAdapter', function () {
expect(request.url).to.contain('bidfloor=0.8');
});

it('should return url with bidFloor option from floor module if it is present', function () {
let getFloorResponse = { currency: 'USD', floor: 3 };
let bidRequest = createCustomBidRequest({
params: {
placement: 1234567,
network: '9599.1',
bidFloor: 0.80
}
});
bidRequest.getFloor = () => getFloorResponse;
let [request] = spec.buildRequests(bidRequest.bids);
expect(request.url).to.contain('bidfloor=3');
});

it('should return url with key values if keyValues param is present', function () {
let bidRequest = createCustomBidRequest({
params: {
Expand Down