Skip to content

Commit

Permalink
etarget Bid Adapter: update support for using priceFloor module (#7305)
Browse files Browse the repository at this point in the history
* new feature getMetaData

* metaData unit test

* advertiserDomains

* advertiserDomains

* added ortb2

* getMetaData feature moved into bidderRequest object

* getMetaData featured moved into bidderRequest object

* getMetaData feature moved into bidderRequest object

* implemented priceFloor

* priceFloor test values

* added priceFloor

* deepClone import

* priceFloor test

* priceFloor test

* floorPrice test

* priceFloor test

* priceFloor test

* priceFloor test

* priceFloor test

* priceFloor test

* priceFloor update
  • Loading branch information
etargetse authored Aug 17, 2021
1 parent bce3396 commit a4207df
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
20 changes: 19 additions & 1 deletion modules/etargetBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const spec = {
var request = [];
var bids = JSON.parse(JSON.stringify(validBidRequests));
var lastCountry = 'sk';
var floors = [];
for (i = 0, l = bids.length; i < l; i++) {
bid = bids[i];
if (countryMap[bid.params.country]) {
Expand All @@ -37,6 +38,7 @@ export const spec = {
reqParams = bid.params;
reqParams.transactionId = bid.transactionId;
request.push(formRequestUrl(reqParams));
floors[i] = getBidFloor(bid);
}

request.unshift('https://' + lastCountry + '.search.etargetnet.com/hb/?hbget=1');
Expand All @@ -52,6 +54,9 @@ export const spec = {
request.push('gdpr_consent=' + gdprObject.gdpr_consent);
}
bidderRequest.metaData = getMetaData();
if (floors.length > 0) {
bidderRequest.floors = floors;
}
}

return {
Expand Down Expand Up @@ -139,7 +144,6 @@ export const spec = {
bidObject.gdpr = bidRequest.gdpr.gdpr;
bidObject.gdpr_consent = bidRequest.gdpr.gdpr_consent;
}

if (bid.adomain) {
utils.deepSetValue(bidObject, 'meta.advertiserDomains', Array.isArray(bid.adomain) ? bid.adomain : [bid.adomain]);
}
Expand All @@ -160,4 +164,18 @@ export const spec = {
}
}
};
function getBidFloor(bid) {
if (!utils.isFn(bid.getFloor)) {
return null;
}
let floor = bid.getFloor({
currency: 'EUR',
mediaType: '*',
size: '*'
});
if (utils.isPlainObject(floor) && !isNaN(floor.floor)) {
return floor.floor;
}
return null;
}
registerBidder(spec);
11 changes: 11 additions & 0 deletions test/spec/modules/etargetBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {assert, expect} from 'chai';
import {spec} from 'modules/etargetBidAdapter.js';
import { BANNER, VIDEO } from 'src/mediaTypes.js';
import { deepClone } from 'src/utils.js';

describe('etarget adapter', function () {
let serverResponse, bidRequest, bidResponses;
Expand Down Expand Up @@ -41,6 +42,16 @@ describe('etarget adapter', function () {
assert.equal(request.method, 'POST');
});

it('should attach floor param when either bid param or getFloor function exists', function () {
// let getFloorResponse = { currency: 'EUR', floor: 5 };
let request = null;
let bidRequest = deepClone(bids[0]);

// floor param has to be NULL
request = spec.buildRequests([bidRequest]);
assert.equal(typeof request.floors, 'undefined');
});

it('should correctly form bid items', function () {
let bidList = bids;
let request = spec.buildRequests(bidList);
Expand Down

0 comments on commit a4207df

Please sign in to comment.