Skip to content

Commit

Permalink
Add optional domain parameter to AdButler adapter (prebid#1078)
Browse files Browse the repository at this point in the history
* Adding AdButler Adapter

* Prevent AdButler TypeError

Only attempt to build a bid response if we have the information of which
bid to respond to.

* Refactor AdButler Testing

Now stubbing adLoader instead of spying. Additional changes to ensure
all tests still passed.

* Prevent AdButler TypeErrors

Prevent AdButler TypeErrors and pass bid request object into the bid
response.

* Add optional domain parameter.

Add optional domain parameter to AdButler adapter.
  • Loading branch information
dharton authored and Nate Cozi committed Apr 18, 2017
1 parent 7f1814c commit 6a6724c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/adapters/adbutler.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,16 @@ var AdButlerAdapter = function AdButlerAdapter() {
}

function buildRequest(bid,adIndex,pageID){
var accountID = utils.getBidIdParameter('accountID', bid.params);
var zoneID = utils.getBidIdParameter('zoneID', bid.params);
var keyword = utils.getBidIdParameter('keyword', bid.params);

var requestURI = location.protocol + '//servedbyadbutler.com/adserve/;type=hbr;';
var accountID = utils.getBidIdParameter('accountID', bid.params),
zoneID = utils.getBidIdParameter('zoneID', bid.params),
keyword = utils.getBidIdParameter('keyword', bid.params),
domain = utils.getBidIdParameter('domain', bid.params);

if(typeof domain === 'undefined' || domain.length === 0){
domain = 'servedbyadbutler.com';
}

var requestURI = location.protocol + '//' + domain + '/adserve/;type=hbr;';
requestURI += 'ID='+encodeURIComponent(accountID)+';';
requestURI += 'setID='+encodeURIComponent(zoneID)+';';
requestURI += 'pid='+encodeURIComponent(pageID)+';';
Expand Down
28 changes: 27 additions & 1 deletion test/spec/adapters/adbutler_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,33 @@ describe('adbutler adapter tests', function () {
var requestURI = stubLoadScript.getCall(0).args[0];

expect(requestURI).to.have.string(';kw=fish;');
})
});

it('should use custom domain string',function(){
var params = {
bidderCode: 'adbutler',
bids: [
{
bidId: '3c9408cdbf2f68',
sizes: [[300, 250]],
bidder: 'adbutler',
params: {
accountID: '107878',
zoneID: '86133',
domain: 'servedbyadbutler.com.dan.test'
},
requestId: '10b327aa396609',
placementCode: '/123456/header-bid-tag-1'
}
]
};

adapter().callBids(params);

var requestURI = stubLoadScript.getCall(0).args[0];

expect(requestURI).to.have.string('.dan.test');
});
});
describe('bid responses',function(){

Expand Down

0 comments on commit 6a6724c

Please sign in to comment.