Skip to content

Commit

Permalink
Merge pull request #26 from sovrn/EX-2549_deal_id_custom_param
Browse files Browse the repository at this point in the history
EX-2549 Dealids custom param
  • Loading branch information
egsgordeev authored Dec 8, 2020
2 parents 93f393a + 2b452a0 commit 8dc7356
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
14 changes: 12 additions & 2 deletions modules/sovrnBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const spec = {
bidSizes = ((utils.isArray(bidSizes) && utils.isArray(bidSizes[0])) ? bidSizes : [bidSizes])
bidSizes = bidSizes.filter(size => utils.isArray(size))
const processedSizes = bidSizes.map(size => ({w: parseInt(size[0], 10), h: parseInt(size[1], 10)}))
sovrnImps.push({
const imp = {
adunitcode: bid.adUnitCode,
id: bid.bidId,
banner: {
Expand All @@ -63,7 +63,17 @@ export const spec = {
},
tagid: String(utils.getBidIdParameter('tagid', bid.params)),
bidfloor: utils.getBidIdParameter('bidfloor', bid.params)
});
}

const segmentsString = utils.getBidIdParameter('segments', bid.params)

if (segmentsString) {
imp.ext = {
deals: segmentsString.split(',')
}
}

sovrnImps.push(imp);
});

const page = bidderRequest.refererInfo.referer
Expand Down
26 changes: 26 additions & 0 deletions test/spec/modules/sovrnBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,32 @@ describe('sovrnBidAdapter', function() {
expect(data.user.ext.tpid[0].uid).to.equal('A_CRITEO_ID')
expect(data.user.ext.prebid_criteoid).to.equal('A_CRITEO_ID')
});

it('should ignore empty segments', function() {
const payload = JSON.parse(request.data)
expect(payload.imp[0].ext).to.be.undefined
})

it('should pass segments param as dealids array', function() {
const segmentsRequests = [{
'bidder': 'sovrn',
'params': {
'segments': 'test1,test2'
},
'adUnitCode': 'adunit-code',
'sizes': [
[300, 250],
[300, 600]
],
'bidId': '30b31c1838de1e',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475'
}];
const request = spec.buildRequests(segmentsRequests, bidderRequest)
const payload = JSON.parse(request.data)
expect(payload.imp[0].ext.deals[0]).to.equal('test1')
expect(payload.imp[0].ext.deals[1]).to.equal('test2')
})
});

describe('interpretResponse', function () {
Expand Down

0 comments on commit 8dc7356

Please sign in to comment.