Skip to content

Commit fe7fdf5

Browse files
bretgIsaac A. Dettman
authored and
Isaac A. Dettman
committed
pbsBidAdapter: register response currency (#4638)
1 parent c0d8dbf commit fe7fdf5

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

modules/prebidServerBidAdapter/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,10 +778,10 @@ const OPEN_RTB_PROTOCOL = {
778778
bidObject.creative_id = bid.crid;
779779
bidObject.creativeId = bid.crid;
780780
if (bid.burl) { bidObject.burl = bid.burl; }
781+
bidObject.currency = (response.cur) ? response.cur : DEFAULT_S2S_CURRENCY;
781782

782-
// TODO: Remove when prebid-server returns ttl, currency and netRevenue
783+
// TODO: Remove when prebid-server returns ttl and netRevenue
783784
bidObject.ttl = (bid.ttl) ? bid.ttl : DEFAULT_S2S_TTL;
784-
bidObject.currency = (bid.currency) ? bid.currency : DEFAULT_S2S_CURRENCY;
785785
bidObject.netRevenue = (bid.netRevenue) ? bid.netRevenue : DEFAULT_S2S_NETREVENUE;
786786

787787
bids.push({ adUnit: bid.impid, bid: bidObject });

test/spec/modules/prebidServerBidAdapter_spec.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ const RESPONSE_OPENRTB = {
273273
'seat': 'appnexus'
274274
},
275275
],
276+
'cur': 'EUR',
276277
'ext': {
277278
'responsetimemillis': {
278279
'appnexus': 8,
@@ -1402,6 +1403,26 @@ describe('S2S Adapter', function () {
14021403
});
14031404
});
14041405

1406+
it('should set the bidResponse currency to whats in the PBS response', function() {
1407+
server.respondWith(JSON.stringify(RESPONSE_OPENRTB));
1408+
adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax);
1409+
server.respond();
1410+
sinon.assert.calledOnce(addBidResponse);
1411+
const pbjsResponse = addBidResponse.firstCall.args[1];
1412+
expect(pbjsResponse).to.have.property('currency', 'EUR');
1413+
});
1414+
1415+
it('should set the default bidResponse currency when not specified in OpenRTB', function() {
1416+
let modifiedResponse = utils.deepClone(RESPONSE_OPENRTB);
1417+
modifiedResponse.cur = '';
1418+
server.respondWith(JSON.stringify(modifiedResponse));
1419+
adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax);
1420+
server.respond();
1421+
sinon.assert.calledOnce(addBidResponse);
1422+
const pbjsResponse = addBidResponse.firstCall.args[1];
1423+
expect(pbjsResponse).to.have.property('currency', 'USD');
1424+
});
1425+
14051426
it('should pass through default adserverTargeting if present in bidObject for banner request', function () {
14061427
const cacheResponse = utils.deepClone(RESPONSE_OPENRTB);
14071428

0 commit comments

Comments
 (0)