Skip to content

Commit

Permalink
Adyoulike Bid Adapter: fix eids retrieve (#10102)
Browse files Browse the repository at this point in the history
* Adyoulike adapter: fix eids retrieve

* refacto

* rename userId to eids
  • Loading branch information
chrisg93 authored Jul 20, 2023
1 parent 84c631f commit b4c9091
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 27 deletions.
9 changes: 6 additions & 3 deletions modules/adyoulikeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const spec = {
// convert Native ORTB definition to old-style prebid native definition
bidRequests = convertOrtbRequestToProprietaryNative(bidRequests);
let hasVideo = false;
let eids;
const payload = {
Version: VERSION,
Bids: bidRequests.reduce((accumulator, bidReq) => {
Expand All @@ -81,6 +82,9 @@ export const spec = {
if (bidReq.schain) {
accumulator[bidReq.bidId].SChain = bidReq.schain;
}
if (!eids && bidReq.userIdAsEids && bidReq.userIdAsEids.length) {
eids = bidReq.userIdAsEids;
}
if (mediatype === NATIVE) {
let nativeReq = bidReq.mediaTypes.native;
if (nativeReq.type === 'image') {
Expand Down Expand Up @@ -120,9 +124,8 @@ export const spec = {
if (bidderRequest.ortb2) {
payload.ortb2 = bidderRequest.ortb2;
}

if (deepAccess(bidderRequest, 'userIdAsEids')) {
payload.userId = bidderRequest.userIdAsEids;
if (eids) {
payload.eids = eids;
}

payload.pbjs_version = '$prebid.version$';
Expand Down
37 changes: 13 additions & 24 deletions test/spec/modules/adyoulikeBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -707,32 +707,21 @@ describe('Adyoulike Adapter', function () {
expect(payload.gdprConsent.consentRequired).to.be.null;
});

it('should add userid eids information to the request', function () {
let bidderRequest = {
'auctionId': '1d1a030790a475',
'bidderRequestId': '22edbae2733bf6',
'timeout': 3000,
'userIdAsEids':
[
{
'source': 'pubcid.org',
'uids': [
{
'atype': 1,
'id': '01EAJWWNEPN3CYMM5N8M5VXY22'
}
]
}
]
};

bidderRequest.bids = bidRequestWithSinglePlacement;

const request = spec.buildRequests(bidRequestWithSinglePlacement, bidderRequest);
it('should add eids eids information to the request', function () {
let bidRequest = bidRequestWithSinglePlacement;
bidRequest[0].userIdAsEids = [{
'source': 'pubcid.org',
'uids': [{
'atype': 1,
'id': '01EAJWWNEPN3CYMM5N8M5VXY22'
}]
}]

const request = spec.buildRequests(bidRequest, bidderRequest);
const payload = JSON.parse(request.data);

expect(payload.userId).to.exist;
expect(payload.userId).to.deep.equal(bidderRequest.userIdAsEids);
expect(payload.eids).to.exist;
expect(payload.eids).to.deep.equal(bidRequest[0].userIdAsEids);
});

it('sends bid request to endpoint with single placement', function () {
Expand Down

0 comments on commit b4c9091

Please sign in to comment.