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

AdUp Technology bid adapter: add support for floor prices #8507

Merged
merged 1 commit into from
Jun 9, 2022
Merged
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
30 changes: 30 additions & 0 deletions modules/aduptechBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,30 @@ export const internal = {
return null;
},

/**
* Extracts the floor price params from given bidRequest
*
* @param {BidRequest} bidRequest
* @returns {undefined|float}
*/
extractFloorPrice: (bidRequest) => {
let floorPrice;
if (bidRequest && bidRequest.params && bidRequest.params.floor) {
// if there is a manual floorPrice set
floorPrice = !isNaN(parseInt(bidRequest.params.floor)) ? bidRequest.params.floor : undefined;
}
if (typeof bidRequest.getFloor === 'function') {
// use prebid floor module
let floorInfo;
try {
floorInfo = bidRequest.getFloor();
} catch (e) {}
floorPrice = typeof floorInfo === 'object' && !isNaN(parseInt(floorInfo.floor)) ? floorInfo.floor : floorPrice;
}

return floorPrice;
},

/**
* Group given array of bidRequests by params.publisher
*
Expand Down Expand Up @@ -248,6 +272,12 @@ export const spec = {
bid.native = nativeConfig;
}

// add floor price
const floorPrice = internal.extractFloorPrice(bidRequest);
if (floorPrice) {
bid.floorPrice = floorPrice;
}

request.data.imp.push(bid);
});

Expand Down
65 changes: 65 additions & 0 deletions test/spec/modules/aduptechBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,71 @@ describe('AduptechBidAdapter', () => {
}
]);
});

it('should build a request with floorPrices', () => {
const bidderRequest = {
auctionId: 'auctionId123',
refererInfo: {
canonicalUrl: 'http://crazy.canonical.url',
referer: 'http://crazy.referer.url'
},
gdprConsent: {
consentString: 'consentString123',
gdprApplies: true
}
};

const getFloorResponse = {
currency: 'USD',
floor: '1.23'
};

const validBidRequests = [
{
bidId: 'bidId1',
adUnitCode: 'adUnitCode1',
transactionId: 'transactionId1',
mediaTypes: {
banner: {
sizes: [[100, 200], [300, 400]]
}
},
params: {
publisher: 'publisher1',
placement: 'placement1'
},
getFloor: () => {
return getFloorResponse
}
}
];

expect(spec.buildRequests(validBidRequests, bidderRequest)).to.deep.equal([
{
url: internal.buildEndpointUrl(validBidRequests[0].params.publisher),
method: ENDPOINT_METHOD,
data: {
auctionId: bidderRequest.auctionId,
pageUrl: bidderRequest.refererInfo.canonicalUrl,
referrer: bidderRequest.refererInfo.referer,
gdpr: {
consentString: bidderRequest.gdprConsent.consentString,
consentRequired: bidderRequest.gdprConsent.gdprApplies
},
imp: [
{
bidId: validBidRequests[0].bidId,
transactionId: validBidRequests[0].transactionId,
adUnitCode: validBidRequests[0].adUnitCode,
params: validBidRequests[0].params,
banner: validBidRequests[0].mediaTypes.banner,
floorPrice: getFloorResponse.floor
}
]
}
}
]);
});
});

describe('interpretResponse', () => {
Expand Down