Skip to content

Commit

Permalink
PBS Bid Adapter: Setting bidderCode and adapterCode for a bid (#8696)
Browse files Browse the repository at this point in the history
* Changed net revenue to True

* Added bidderCode and adapterCode to bidObject

* setting seat as default adapterCode

* removed bidderCode

* Added unit test cases

* cloned the test object

Co-authored-by: Azhar <[email protected]>
  • Loading branch information
pm-azhar-mulla and Azhar authored Jul 21, 2022
1 parent 453ece2 commit d86712f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,13 @@ Object.assign(ORTB2.prototype, {
});
bidObject.requestTimestamp = this.requestTimestamp;
bidObject.cpm = cpm;
if (bid?.ext?.prebid?.meta?.adaptercode) {
bidObject.adapterCode = bid.ext.prebid.meta.adaptercode;
} else if (bidRequest?.bidder) {
bidObject.adapterCode = bidRequest.bidder;
} else {
bidObject.adapterCode = seatbid.seat;
}

// temporarily leaving attaching it to each bidResponse so no breaking change
// BUT: this is a flat map, so it should be only attached to bidderRequest, a the change above does
Expand Down
20 changes: 20 additions & 0 deletions test/spec/modules/prebidServerBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2692,6 +2692,26 @@ describe('S2S Adapter', function () {
sinon.assert.match(actual.imp[0], sinon.match(ortb2Imp));
});

it('setting adapterCode for default bidder', function () {
config.setConfig({ CONFIG });
adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax);
server.requests[0].respond(200, {}, JSON.stringify(RESPONSE_OPENRTB));

const response = addBidResponse.firstCall.args[1];
expect(response).to.have.property('adapterCode', 'appnexus');
});

it('setting adapterCode for alternate bidder', function () {
config.setConfig({ CONFIG });
let RESPONSE_OPENRTB2 = deepClone(RESPONSE_OPENRTB);
RESPONSE_OPENRTB2.seatbid[0].bid[0].ext.prebid.meta.adaptercode = 'appnexus2'
adapter.callBids(REQUEST, BID_REQUESTS, addBidResponse, done, ajax);
server.requests[0].respond(200, {}, JSON.stringify(RESPONSE_OPENRTB2));

const response = addBidResponse.firstCall.args[1];
expect(response).to.have.property('adapterCode', 'appnexus2');
});

describe('on sync requested with no cookie', () => {
let cfg, req, csRes;

Expand Down

0 comments on commit d86712f

Please sign in to comment.