Skip to content
Open
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
21 changes: 19 additions & 2 deletions modules/impactifyBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { deepAccess, deepSetValue, generateUUID } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
import {ajax} from '../src/ajax.js';
import { ajax } from '../src/ajax.js';
import { createEidsArray } from './userId/eids.js';

const BIDDER_CODE = 'impactify';
Expand All @@ -27,6 +27,18 @@ const getDeviceType = () => {
return 2;
};

const getFloor = (bid) => {
const floorInfo = bid.getFloor({
currency: DEFAULT_CURRENCY,
mediaType: '*',
size: '*'
});
if (typeof floorInfo === 'object' && floorInfo.currency === DEFAULT_CURRENCY && !isNaN(parseFloat(floorInfo.floor))) {
return parseFloat(floorInfo.floor);
}
return null;
}

const createOpenRtbRequest = (validBidRequests, bidderRequest) => {
// Create request and set imp bids inside
let request = {
Expand Down Expand Up @@ -81,7 +93,6 @@ const createOpenRtbRequest = (validBidRequests, bidderRequest) => {

if (bidderRequest.uspConsent) {
deepSetValue(request, 'regs.ext.us_privacy', bidderRequest.uspConsent);
this.syncStore.uspConsent = bidderRequest.uspConsent;
}

if (GETCONFIG('coppa') == true) deepSetValue(request, 'regs.coppa', 1);
Expand Down Expand Up @@ -114,6 +125,12 @@ const createOpenRtbRequest = (validBidRequests, bidderRequest) => {
if (bid.params.container) {
imp.ext.impactify.container = bid.params.container;
}
if (typeof bid.getFloor === 'function') {
const floor = getFloor(bid);
if (floor) {
imp.bidfloor = floor;
}
}
request.imp.push(imp);
});

Expand Down
13 changes: 13 additions & 0 deletions test/spec/modules/impactifyBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,19 @@ describe('ImpactifyAdapter', function () {
}
};

it('should pass bidfloor', function () {
videoBidRequests[0].getFloor = function() {
return {
currency: 'USD',
floor: 1.23,
}
}

const res = spec.buildRequests(videoBidRequests, videoBidderRequest)
const resData = JSON.parse(res.data)
expect(resData.imp[0].bidfloor).to.equal(1.23)
});

it('sends video bid request to ENDPOINT via POST', function () {
const request = spec.buildRequests(videoBidRequests, videoBidderRequest);
expect(request.url).to.equal(ORIGIN + AUCTIONURI);
Expand Down