Skip to content

Commit

Permalink
RTBHouse Bid Adapter: add support to channel param (prebid#7879)
Browse files Browse the repository at this point in the history
  • Loading branch information
rtbh-lotani authored and Chris Pabst committed Jan 10, 2022
1 parent 71eaa08 commit 4af8ed1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
18 changes: 14 additions & 4 deletions modules/rtbhouseBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,26 @@ function mapBanner(slot) {
* @returns {object} Site by OpenRTB 2.5 §3.2.13
*/
function mapSite(slot, bidderRequest) {
const pubId = slot && slot.length > 0
? slot[0].params.publisherId
: 'unknown';
return {
let pubId = 'unknown';
let channel = null;
if (slot && slot.length > 0) {
pubId = slot[0].params.publisherId;
channel = slot[0].params.channel &&
slot[0].params.channel
.toString()
.slice(0, 50);
}
let siteData = {
publisher: {
id: pubId.toString(),
},
page: bidderRequest.refererInfo.referer,
name: getOrigin()
};
if (channel) {
siteData.channel = channel;
}
return siteData;
}

/**
Expand Down
20 changes: 20 additions & 0 deletions test/spec/modules/rtbhouseBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ describe('RTBHouseAdapter', () => {
'params': {
'publisherId': 'PREBID_TEST',
'region': 'prebid-eu',
'channel': 'Partner_Site - news',
'test': 1
},
'adUnitCode': 'adunit-code',
Expand Down Expand Up @@ -101,6 +102,25 @@ describe('RTBHouseAdapter', () => {
expect(JSON.parse(builtTestRequest).test).to.equal(1);
});

it('should build channel param into request.site', () => {
let builtTestRequest = spec.buildRequests(bidRequests, bidderRequest).data;
expect(JSON.parse(builtTestRequest).site.channel).to.equal('Partner_Site - news');
})

it('should not build channel param into request.site if no value is passed', () => {
let bidRequest = Object.assign([], bidRequests);
bidRequest[0].params.channel = undefined;
let builtTestRequest = spec.buildRequests(bidRequest, bidderRequest).data;
expect(JSON.parse(builtTestRequest).site.channel).to.be.undefined
})

it('should cap the request.site.channel length to 50', () => {
let bidRequest = Object.assign([], bidRequests);
bidRequest[0].params.channel = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent scelerisque ipsum eu purus lobortis iaculis.';
let builtTestRequest = spec.buildRequests(bidRequest, bidderRequest).data;
expect(JSON.parse(builtTestRequest).site.channel.length).to.equal(50)
})

it('should build valid OpenRTB banner object', () => {
const request = JSON.parse(spec.buildRequests(bidRequests, bidderRequest).data);
const imp = request.imp[0];
Expand Down

0 comments on commit 4af8ed1

Please sign in to comment.