Skip to content

Commit

Permalink
BetweenBidAdatper: added sharedid support (#6531)
Browse files Browse the repository at this point in the history
  • Loading branch information
ignat-one authored Apr 9, 2021
1 parent 2cc905e commit c34d853
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
13 changes: 12 additions & 1 deletion modules/betweenBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {registerBidder} from '../src/adapters/bidderFactory.js';
import { getAdUnitSizes, parseSizesInput } from '../src/utils.js';
import { getAdUnitSizes, parseSizesInput, deepAccess } from '../src/utils.js';
import { getRefererInfo } from '../src/refererDetection.js';

const BIDDER_CODE = 'between';
Expand Down Expand Up @@ -37,6 +37,8 @@ export const spec = {
tz: getTz(),
fl: getFl(),
rr: getRr(),
shid: getSharedId(i)('id'),
shid3: getSharedId(i)('third'),
s: i.params.s,
bidid: i.bidId,
transactionid: i.transactionId,
Expand Down Expand Up @@ -144,6 +146,15 @@ export const spec = {
}
}

function getSharedId(bid) {
const id = deepAccess(bid, 'userId.sharedid.id');
const third = deepAccess(bid, 'userId.sharedid.third');
return function(kind) {
if (kind === 'id') return id || '';
return third || '';
}
}

function getRr() {
try {
var td = top.document;
Expand Down
46 changes: 46 additions & 0 deletions test/spec/modules/betweenBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,50 @@ describe('betweenBidAdapterTests', function () {

expect(req_data.sizes).to.deep.equal(['970x250', '240x400', '728x90'])
});

it('check sharedId with id and third', function() {
const bidRequestData = [{
bidId: 'bid123',
bidder: 'between',
mediaTypes: {
banner: {
sizes: [[728, 90]]
}
},
params: {
s: 1112,
},
userId: {
sharedid: {
id: '01EXQE7JKNDRDDVATB0S2GX1NT',
third: '01EXQE7JKNDRDDVATB0S2GX1NT'
}
}
}];
const shid = JSON.parse(spec.buildRequests(bidRequestData).data)[0].data.shid;
const shid3 = JSON.parse(spec.buildRequests(bidRequestData).data)[0].data.shid3;
expect(shid).to.equal('01EXQE7JKNDRDDVATB0S2GX1NT') && expect(shid3).to.equal('01EXQE7JKNDRDDVATB0S2GX1NT');
});
it('check sharedId with only id', function() {
const bidRequestData = [{
bidId: 'bid123',
bidder: 'between',
mediaTypes: {
banner: {
sizes: [[728, 90]]
}
},
params: {
s: 1112,
},
userId: {
sharedid: {
id: '01EXQE7JKNDRDDVATB0S2GX1NT',
}
}
}];
const shid = JSON.parse(spec.buildRequests(bidRequestData).data)[0].data.shid;
const shid3 = JSON.parse(spec.buildRequests(bidRequestData).data)[0].data.shid3;
expect(shid).to.equal('01EXQE7JKNDRDDVATB0S2GX1NT') && expect(shid3).to.equal('');
});
});

0 comments on commit c34d853

Please sign in to comment.