Skip to content

Commit

Permalink
added cur to ortb
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac Dettman committed Jun 27, 2019
1 parent 5cdd5a3 commit 7b70c14
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
8 changes: 8 additions & 0 deletions modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,14 @@ const OPEN_RTB_PROTOCOL = {
request.ext.prebid = Object.assign(request.ext.prebid, _s2sConfig.extPrebid);
}

/**
* @type {(string[]|undefined)} - OpenRTB property 'cur', currencies available for bids
*/
const adServerCur = config.getConfig('currency.adServerCurrency');
if (Array.isArray(adServerCur) && adServerCur.length) {
request.cur = adServerCur.slice();
}

_appendSiteAppDevice(request);

const digiTrust = _getDigiTrustQueryParams(bidRequests && bidRequests[0]);
Expand Down
31 changes: 30 additions & 1 deletion test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,36 @@ describe('S2S Adapter', function () {
expect(requestBid.user.ext.eids.filter(eid => eid.source === 'adserver.org')[0].uids[0].id).is.equal('abc123');
expect(requestBid.user.ext.eids.filter(eid => eid.source === 'pubcommon')).is.not.empty; ;
expect(requestBid.user.ext.eids.filter(eid => eid.source === 'pubcommon')[0].uids[0].id).is.equal('1234');
})
});

it('setting currency.adServerCurrency results in the openRTB JSON containing cur: ["AAA"]', function () {
let ortb2Config = utils.deepClone(CONFIG);
ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction';
config.setConfig({
currency: {adServerCurrency: ['USD', 'GB', 'UK', 'AU']},
s2sConfig: ortb2Config
});

const userIdBidRequest = utils.deepClone(BID_REQUESTS);
adapter.callBids(REQUEST, userIdBidRequest, addBidResponse, done, ajax);

const parsedRequestBody = JSON.parse(requests[0].requestBody);
expect(parsedRequestBody.cur).to.deep.equal(['USD', 'GB', 'UK', 'AU']);
});

it('when currency.adServerCurrency is unset, the OpenRTB JSON should not contain cur', function () {
let ortb2Config = utils.deepClone(CONFIG);
ortb2Config.endpoint = 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction';
config.setConfig({
s2sConfig: ortb2Config
});

const userIdBidRequest = utils.deepClone(BID_REQUESTS);
adapter.callBids(REQUEST, userIdBidRequest, addBidResponse, done, ajax);

const parsedRequestBody = JSON.parse(requests[0].requestBody);
expect(typeof parsedRequestBody.cur).to.equal('undefined');
});

it('always add ext.prebid.targeting.includebidderkeys: false for ORTB', function () {
const s2sConfig = Object.assign({}, CONFIG, {
Expand Down

0 comments on commit 7b70c14

Please sign in to comment.