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

Ivp 3380 #2

Merged
merged 5 commits into from
Jul 6, 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
26 changes: 24 additions & 2 deletions modules/riseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import {config} from '../src/config.js';

const SUPPORTED_AD_TYPES = [VIDEO];
const BIDDER_CODE = 'rise';
const BIDDER_VERSION = '4.0.0';
const BIDDER_VERSION = '4.0.1';
const TTL = 360;
const CURRENCY = 'USD';
const SELLER_ENDPOINT = 'https://hb.yellowblue.io/';
const MODES = {
PRODUCTION: 'hb',
Expand Down Expand Up @@ -53,6 +54,10 @@ export const spec = {
mediaType: VIDEO
};

if (body.adomain && body.adomain.length) {
bidResponse.meta = {};
bidResponse.meta.advertiserDomains = body.adomain
}
bidResponses.push(bidResponse);

return bidResponses;
Expand Down Expand Up @@ -82,6 +87,23 @@ export const spec = {

registerBidder(spec);

/**
* Get floor price
* @param bid {bid}
* @returns {Number}
*/
function getFloor(bid) {
if (!utils.isFn(bid.getFloor)) {
return 0;
}
let floorResult = bid.getFloor({
currency: CURRENCY,
mediaType: VIDEO,
size: '*'
});
return floorResult.currency === CURRENCY ? floorResult.floor : 0;
}

/**
* Build the video request
* @param bid {bid}
Expand Down Expand Up @@ -206,7 +228,7 @@ function generateParameters(bid, bidderRequest) {
width: width,
height: height,
publisher_id: params.org,
floor_price: params.floorPrice,
floor_price: Math.max(getFloor(bid), params.floorPrice),
ua: navigator.userAgent,
bid_id: utils.getBidIdParameter('bidId', bid),
bidder_request_id: utils.getBidIdParameter('bidderRequestId', bid),
Expand Down
37 changes: 35 additions & 2 deletions test/spec/modules/riseBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { spec } from 'modules/riseBidAdapter.js';
import { newBidder } from 'src/adapters/bidderFactory.js';
import { config } from 'src/config.js';
import { VIDEO } from '../../../src/mediaTypes.js';
import { deepClone } from 'src/utils.js';

const ENDPOINT = 'https://hb.yellowblue.io/hb';
const TEST_ENDPOINT = 'https://hb.yellowblue.io/hb-test';
Expand Down Expand Up @@ -250,6 +251,34 @@ describe('riseAdapter', function () {
expect(request.data).to.have.property('schain', '1.0,1!indirectseller.com,00001,,,,');
}
});

it('should set floor_price to getFloor.floor value if it is greater than params.floorPrice', function() {
const bid = deepClone(bidRequests[0]);
bid.getFloor = () => {
return {
currency: 'USD',
floor: 3.32
}
}
bid.params.floorPrice = 0.64;
const request = spec.buildRequests([bid], bidderRequest)[0];
expect(request.data).to.be.an('object');
expect(request.data).to.have.property('floor_price', 3.32);
});

it('should set floor_price to params.floorPrice value if it is greater than getFloor.floor', function() {
const bid = deepClone(bidRequests[0]);
bid.getFloor = () => {
return {
currency: 'USD',
floor: 0.8
}
}
bid.params.floorPrice = 1.5;
const request = spec.buildRequests([bid], bidderRequest)[0];
expect(request.data).to.be.an('object');
expect(request.data).to.have.property('floor_price', 1.5);
});
});

describe('interpretResponse', function () {
Expand All @@ -260,7 +289,8 @@ describe('riseAdapter', function () {
height: 480,
requestId: '21e12606d47ba7',
netRevenue: true,
currency: 'USD'
currency: 'USD',
adomain: ['abc.com']
};

it('should get correct bid response', function () {
Expand All @@ -275,7 +305,10 @@ describe('riseAdapter', function () {
netRevenue: true,
ttl: TTL,
vastXml: '<VAST version="3.0"></VAST>',
mediaType: VIDEO
mediaType: VIDEO,
meta: {
advertiserDomains: ['abc.com']
}
}
];
const result = spec.interpretResponse({ body: response });
Expand Down