From c21f82d2ec42305a921d140e3d0a117fba0327d8 Mon Sep 17 00:00:00 2001 From: jsnellbaker <31102355+jsnellbaker@users.noreply.github.com> Date: Tue, 17 Apr 2018 13:42:56 -0400 Subject: [PATCH] send appnexus usePaymentRule info to prebid-server ortb request (#2351) * initial commit - send usePaymentRule info to pbs * move code changes to pbs adapter * removed commented unit test --- modules/prebidServerBidAdapter.js | 3 +++ test/spec/modules/prebidServerBidAdapter_spec.js | 6 ++++-- test/spec/unit/core/adapterManager_spec.js | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/prebidServerBidAdapter.js b/modules/prebidServerBidAdapter.js index 8e1a5a07560..a7ad11babe7 100644 --- a/modules/prebidServerBidAdapter.js +++ b/modules/prebidServerBidAdapter.js @@ -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) { diff --git a/test/spec/modules/prebidServerBidAdapter_spec.js b/test/spec/modules/prebidServerBidAdapter_spec.js index a1392989ad7..eef8a266b68 100644 --- a/test/spec/modules/prebidServerBidAdapter_spec.js +++ b/test/spec/modules/prebidServerBidAdapter_spec.js @@ -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; }); }); diff --git a/test/spec/unit/core/adapterManager_spec.js b/test/spec/unit/core/adapterManager_spec.js index d11dfc02c4c..39e468d4959 100644 --- a/test/spec/unit/core/adapterManager_spec.js +++ b/test/spec/unit/core/adapterManager_spec.js @@ -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); }); - }) + }); }); });