Skip to content

Commit

Permalink
send appnexus usePaymentRule info to prebid-server ortb request (#2351)
Browse files Browse the repository at this point in the history
* initial commit - send usePaymentRule info to pbs

* move code changes to pbs adapter

* removed commented unit test
  • Loading branch information
jsnellbaker authored and mkendall07 committed Apr 17, 2018
1 parent 9954c6f commit c21f82d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions modules/prebidServerBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,9 @@ const OPEN_RTB_PROTOCOL = {
// TODO: move this bidder specific out to a more ideal location (submodule?); issue# pending
// convert all AppNexus keys to underscore format for pbs
if (bid.bidder === 'appnexus') {
bid.params.use_pmt_rule = (typeof bid.params.usePaymentRule === 'boolean') ? bid.params.usePaymentRule : false;
if (bid.params.usePaymentRule) { delete bid.params.usePaymentRule; }

Object.keys(bid.params).forEach(paramKey => {
let convertedKey = utils.convertCamelToUnderscore(paramKey);
if (convertedKey !== paramKey) {
Expand Down
6 changes: 4 additions & 2 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,19 +551,21 @@ describe('S2S Adapter', () => {
});
});

it('converts appnexus params to underscore syntax', () => {
it('converts appnexus params to expected format for PBS', () => {
const s2sConfig = Object.assign({}, CONFIG, {
endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'
});
config.setConfig({s2sConfig});

const myRequest = utils.deepClone(REQUEST);
myRequest.ad_units[0].bids[0].params.usePaymentRule = true;

adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax);
adapter.callBids(myRequest, BID_REQUESTS, addBidResponse, done, ajax);
const requestBid = JSON.parse(requests[0].requestBody);

expect(requestBid.imp[0].ext.appnexus).to.exist;
expect(requestBid.imp[0].ext.appnexus.placement_id).to.exist.and.to.equal(10433394);
expect(requestBid.imp[0].ext.appnexus.use_pmt_rule).to.exist.and.to.be.true;
expect(requestBid.imp[0].ext.appnexus.member).to.exist;
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/spec/unit/core/adapterManager_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ describe('adapterManager tests', () => {
expect(bidRequests[0].bids.length).to.equal(1);
expect(bidRequests[0].bids[0].adUnitCode).to.equal(adUnits[1].code);
});
})
});
});
});

Expand Down

0 comments on commit c21f82d

Please sign in to comment.