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

BrightMountainMedia Bid Adapter: add floors module support #6833

Merged
merged 13 commits into from
Jun 1, 2021
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
36 changes: 35 additions & 1 deletion modules/brightMountainMediaBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const spec = {
let placement = {
placementId: bid.params.placement_id,
bidId: bid.bidId,
floor: {},
};

if (bid.mediaTypes.hasOwnProperty(BANNER)) {
Expand Down Expand Up @@ -87,6 +88,23 @@ export const spec = {
placement['playbackmethod'] = bid.mediaTypes.video.playbackmethod;
}
}

if (typeof bid.getFloor === 'function') {
let floorInfo = {};

for (let size of placement['sizes']) {
floorInfo = bid.getFloor({
currency: 'USD',
mediaType: placement['traffic'],
size: size,
});

if (typeof floorInfo === 'object' && floorInfo.currency === 'USD') {
placement.floor[`${size[0]}x${size[1]}`] = parseFloat(floorInfo.floor);
}
}
}

if (bid.schain) {
placement.schain = bid.schain;
}
Expand All @@ -105,10 +123,26 @@ export const spec = {
if (response && Array.isArray(response) && response.length > 0) {
for (let i = 0; i < response.length; i++) {
if (response[i].cpm > 0) {
const tempResponse = {
requestId: response[i].requestId,
width: response[i].width,
height: response[i].height,
cpm: response[i].cpm,
mediaType: response[i].mediaType,
creativeId: response[i].creativeId,
currency: response[i].currency,
netRevenue: response[i].netRevenue,
ttl: response[i].ttl,
ad: response[i].ad,
meta: {
advertiserDomains: response[i].adomain && response[i].adomain.length ? response[i].adomain : [],
}
};

if (response[i].mediaType && response[i].mediaType === 'video') {
response[i].vastXml = response[i].ad;
}
bidResponse.push(response[i]);
bidResponse.push(tempResponse);
}
}
}
Expand Down
49 changes: 47 additions & 2 deletions test/spec/modules/brightMountainMediaBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,48 @@ describe('brightMountainMediaBidAdapter_spec', function () {
let serverRequest = spec.buildRequests([bidBanner], bidderRequest);
testServerRequestBody(serverRequest);

it('sends bidfloor param if present', function () {
bidBanner.getFloor = function () {
return {
currency: 'USD',
floor: 0.5,
}
};
const request = spec.buildRequests([bidBanner], bidderRequest);
expect(request.data.placements[0].floor['300x250']).to.equal(0.5);
});

it('sends gdpr info if exists', function () {
const gdprConsent = {
consentString: 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==',
gdprApplies: true
};

bidderRequest['gdprConsent'] = gdprConsent;
const request = spec.buildRequests([bidBanner], bidderRequest);

expect(request.data.gdpr_require).to.exist.and.to.be.a('number');
expect(request.data.gdpr_consent).to.exist.and.to.be.a('string');
});

it('sends schain info if exists', function () {
const schain = {
ver: '1.0',
complete: 1,
nodes: [
{
asi: 'directseller.com',
sid: '00001',
rid: 'BidRequest1',
hp: 1
}
]
};
bidBanner.schain = schain;
const request = spec.buildRequests([bidBanner], bidderRequest);
expect(request.data.placements[0].schain).to.be.an('object');
});

bidderRequest['bids'] = [bidVideo];
serverRequest = spec.buildRequests([bidVideo], bidderRequest);
testServerRequestBody(serverRequest);
Expand All @@ -129,6 +171,7 @@ describe('brightMountainMediaBidAdapter_spec', function () {
expect(dataItem.netRevenue).to.be.a('boolean');
expect(dataItem.currency).to.be.a('string');
expect(dataItem.mediaType).to.be.a('string');
expect(dataItem.meta.advertiserDomains[0]).to.be.a('string');
}
});
}
Expand All @@ -145,7 +188,8 @@ describe('brightMountainMediaBidAdapter_spec', function () {
ttl: 1000,
creativeId: '123asd',
netRevenue: true,
currency: 'USD'
currency: 'USD',
adomain: ['adomain.com'],
}]
};

Expand All @@ -160,7 +204,8 @@ describe('brightMountainMediaBidAdapter_spec', function () {
ttl: 1000,
creativeId: '123asd',
netRevenue: true,
currency: 'USD'
currency: 'USD',
adomain: ['adomain.com'],
}]
};
let serverResponses = spec.interpretResponse(resObjectBanner);
Expand Down