Skip to content

Commit

Permalink
Sonobi - send entire userid payload (prebid#4196)
Browse files Browse the repository at this point in the history
* added userid param to pass the entire userId payload to sonobis bid request endpoint

* removed console log
git p

* fixed lint
  • Loading branch information
JonGoSonobi authored and EMXDigital committed Sep 18, 2019
1 parent b3fd70a commit a7811b8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
3 changes: 3 additions & 0 deletions modules/sonobiBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ export const spec = {
if (validBidRequests[0].schain) {
payload.schain = JSON.stringify(validBidRequests[0].schain)
}
if (deepAccess(validBidRequests[0], 'userId') && Object.keys(validBidRequests[0].userId).length > 0) {
payload.userid = JSON.stringify(validBidRequests[0].userId);
}

// If there is no key_maker data, then don't make the request.
if (isEmpty(data)) {
Expand Down
35 changes: 34 additions & 1 deletion test/spec/modules/sonobiBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,40 @@ describe('SonobiBidAdapter', function () {
it('should return a properly formatted request with schain defined', function () {
const bidRequests = spec.buildRequests(bidRequest, bidderRequests);
expect(JSON.parse(bidRequests.data.schain)).to.deep.equal(bidRequest[0].schain)
})
});

it('should return a properly formatted request with userid as a JSON-encoded set of User ID results', function () {
bidRequest[0].userId = {'pubcid': 'abcd-efg-0101', 'tdid': 'td-abcd-efg-0101'};
bidRequest[1].userId = {'pubcid': 'abcd-efg-0101', 'tdid': 'td-abcd-efg-0101'};
const bidRequests = spec.buildRequests(bidRequest, bidderRequests);
expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json');
expect(bidRequests.method).to.equal('GET');
expect(bidRequests.data.ref).not.to.be.empty;
expect(bidRequests.data.s).not.to.be.empty;
expect(JSON.parse(bidRequests.data.userid)).to.eql({'pubcid': 'abcd-efg-0101', 'tdid': 'td-abcd-efg-0101'});
});

it('should return a properly formatted request with userid omitted if there are no userIds', function () {
bidRequest[0].userId = {};
bidRequest[1].userId = {};
const bidRequests = spec.buildRequests(bidRequest, bidderRequests);
expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json');
expect(bidRequests.method).to.equal('GET');
expect(bidRequests.data.ref).not.to.be.empty;
expect(bidRequests.data.s).not.to.be.empty;
expect(bidRequests.data.userid).to.equal(undefined);
});

it('should return a properly formatted request with userid omitted', function () {
bidRequest[0].userId = undefined;
bidRequest[1].userId = undefined;
const bidRequests = spec.buildRequests(bidRequest, bidderRequests);
expect(bidRequests.url).to.equal('https://apex.go.sonobi.com/trinity.json');
expect(bidRequests.method).to.equal('GET');
expect(bidRequests.data.ref).not.to.be.empty;
expect(bidRequests.data.s).not.to.be.empty;
expect(bidRequests.data.userid).to.equal(undefined);
});
})

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

0 comments on commit a7811b8

Please sign in to comment.