Skip to content

Commit

Permalink
AdButler Bid Adapter: Add ability to include extra query params
Browse files Browse the repository at this point in the history
  • Loading branch information
dharton committed Jul 27, 2020
1 parent abb33d6 commit 4240baa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions modules/adbutlerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ export const spec = {
let requestURI;
let serverRequests = [];
let zoneCounters = {};
let extraParams = {};

for (i = 0; i < validBidRequests.length; i++) {
bidRequest = validBidRequests[i];
zoneID = utils.getBidIdParameter('zoneID', bidRequest.params);
accountID = utils.getBidIdParameter('accountID', bidRequest.params);
keyword = utils.getBidIdParameter('keyword', bidRequest.params);
domain = utils.getBidIdParameter('domain', bidRequest.params);
extraParams = utils.getBidIdParameter('extra', bidRequest.params);

if (!(zoneID in zoneCounters)) {
zoneCounters[zoneID] = 0;
Expand All @@ -52,6 +54,13 @@ export const spec = {
requestURI += 'kw=' + encodeURIComponent(keyword) + ';';
}

for (let key in extraParams) {
if (extraParams.hasOwnProperty(key)) {
let val = encodeURIComponent(extraParams[key]);
requestURI += `${key}=${val};`;
}
}

zoneCounters[zoneID]++;
serverRequests.push({
method: 'GET',
Expand Down
12 changes: 11 additions & 1 deletion test/spec/modules/adbutlerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ describe('AdButler adapter', function () {
zoneID: '210093',
keyword: 'red',
minCPM: '1.00',
maxCPM: '5.00'
maxCPM: '5.00',
extra: {
foo: 'bar',
}
},
placementCode: '/19968336/header-bid-tag-1',
mediaTypes: {
Expand Down Expand Up @@ -93,6 +96,13 @@ describe('AdButler adapter', function () {
expect(requestURL).to.have.string(';kw=red;');
});

it('should set the extra parameter', () => {
let requests = spec.buildRequests(bidRequests);
let requestURL = requests[0].url;

expect(requestURL).to.have.string(';foo=bar;');
});

it('should increment the count for the same zone', function () {
let bidRequests = [
{
Expand Down

0 comments on commit 4240baa

Please sign in to comment.