Skip to content

Commit

Permalink
BridgewellBidAdapter: modify to include user ids in the bid request o…
Browse files Browse the repository at this point in the history
…bject (prebid#6845)
  • Loading branch information
rigelbibi authored and agrandes-tappx committed Sep 29, 2021
1 parent bac522e commit df8aa49
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
17 changes: 12 additions & 5 deletions modules/bridgewellBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { BANNER, NATIVE } from '../src/mediaTypes.js';
import find from 'core-js-pure/features/array/find.js';

const BIDDER_CODE = 'bridgewell';
const REQUEST_ENDPOINT = 'https://prebid.scupio.com/recweb/prebid.aspx?cb=' + Math.random();
const BIDDER_VERSION = '0.0.3';
const REQUEST_ENDPOINT = 'https://prebid.scupio.com/recweb/prebid.aspx?cb=';
const BIDDER_VERSION = '1.1.0';

export const spec = {
code: BIDDER_CODE,
Expand Down Expand Up @@ -37,7 +37,12 @@ export const spec = {
*/
buildRequests: function (validBidRequests, bidderRequest) {
const adUnits = [];
var bidderUrl = REQUEST_ENDPOINT + Math.random();
var userIds;

utils._each(validBidRequests, function (bid) {
userIds = bid.userId;

if (bid.params.cid) {
adUnits.push({
cid: bid.params.cid,
Expand All @@ -47,7 +52,8 @@ export const spec = {
banner: {
sizes: bid.sizes
}
}
},
userIds: userIds || {}
});
} else {
adUnits.push({
Expand All @@ -58,7 +64,8 @@ export const spec = {
banner: {
sizes: bid.sizes
}
}
},
userIds: userIds || {}
});
}
});
Expand All @@ -70,7 +77,7 @@ export const spec = {

return {
method: 'POST',
url: REQUEST_ENDPOINT,
url: bidderUrl,
data: {
version: {
prebid: '$prebid.version$',
Expand Down
33 changes: 25 additions & 8 deletions test/spec/modules/bridgewellBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import { expect } from 'chai';
import { spec } from 'modules/bridgewellBidAdapter.js';
import { newBidder } from 'src/adapters/bidderFactory.js';

const userId = {
'criteoId': 'vYlICF9oREZlTHBGRVdrJTJCUUJnc3U2ckNVaXhrV1JWVUZVSUxzZmJlcnJZR0ZxbVhFRnU5bDAlMkJaUWwxWTlNcmdEeHFrJTJGajBWVlV4T3lFQ0FyRVcxNyUyQlIxa0lLSlFhcWJpTm9PSkdPVkx0JTJCbzlQRTQlM0Q',
'pubcid': '074864cb-3705-430e-9ff7-48ccf3c21b94',
'sharedid': {'id': '01F61MX53D786DSB2WYD38ZVM7', 'third': '01F61MX53D786DSB2WYD38ZVM7'},
'uid2': {'id': 'eb33b0cb-8d35-1234-b9c0-1a31d4064777'},
'flocId': {'id': '12345', 'version': 'chrome.1.1'},
}

describe('bridgewellBidAdapter', function () {
const adapter = newBidder(spec);

Expand Down Expand Up @@ -87,6 +95,7 @@ describe('bridgewellBidAdapter', function () {
'bidId': '3150ccb55da321',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475',
'userId': userId,
},
{
'bidder': 'bridgewell',
Expand Down Expand Up @@ -126,6 +135,7 @@ describe('bridgewellBidAdapter', function () {
'bidId': '3150ccb55da321',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475',
'userId': userId,
}
];

Expand All @@ -142,10 +152,13 @@ describe('bridgewellBidAdapter', function () {
expect(payload.adUnits).to.be.an('array');
expect(payload.url).to.exist.and.to.equal('https://www.bridgewell.com/');
for (let i = 0, max_i = payload.adUnits.length; i < max_i; i++) {
expect(payload.adUnits[i]).to.have.property('ChannelID').that.is.a('string');
expect(payload.adUnits[i]).to.not.have.property('cid');
expect(payload.adUnits[i]).to.have.property('adUnitCode').and.to.equal('adunit-code-2');
expect(payload.adUnits[i]).to.have.property('requestId').and.to.equal('3150ccb55da321');
let u = payload.adUnits[i];
expect(u).to.have.property('ChannelID').that.is.a('string');
expect(u).to.not.have.property('cid');
expect(u).to.have.property('adUnitCode').and.to.equal('adunit-code-2');
expect(u).to.have.property('requestId').and.to.equal('3150ccb55da321');
expect(u).to.have.property('userIds');
expect(u.userIds).to.deep.equal(userId);
}
});

Expand All @@ -170,6 +183,7 @@ describe('bridgewellBidAdapter', function () {
'bidId': '3150ccb55da321',
'bidderRequestId': '22edbae2733bf6',
'auctionId': '1d1a030790a475',
'userId': userId
},
];

Expand All @@ -180,10 +194,13 @@ describe('bridgewellBidAdapter', function () {
expect(payload.adUnits).to.be.an('array');
expect(payload.url).to.exist.and.to.equal('https://www.bridgewell.com/');
for (let i = 0, max_i = payload.adUnits.length; i < max_i; i++) {
expect(payload.adUnits[i]).to.have.property('cid').that.is.a('number');
expect(payload.adUnits[i]).to.not.have.property('ChannelID');
expect(payload.adUnits[i]).to.have.property('adUnitCode').and.to.equal('adunit-code-2');
expect(payload.adUnits[i]).to.have.property('requestId').and.to.equal('3150ccb55da321');
let u = payload.adUnits[i];
expect(u).to.have.property('cid').that.is.a('number');
expect(u).to.not.have.property('ChannelID');
expect(u).to.have.property('adUnitCode').and.to.equal('adunit-code-2');
expect(u).to.have.property('requestId').and.to.equal('3150ccb55da321');
expect(u).to.have.property('userIds');
expect(u.userIds).to.deep.equal(userId);
}
});

Expand Down

0 comments on commit df8aa49

Please sign in to comment.