Skip to content

Commit

Permalink
Adding support of eids for smilewanted (prebid#9440)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxSmileWanted authored and jorgeluisrocha committed May 18, 2023
1 parent cc3e9b4 commit db30d06
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 3 deletions.
5 changes: 5 additions & 0 deletions modules/smilewantedBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ export const spec = {
payload.gdpr_consent = bidderRequest.gdprConsent.consentString;
payload.gdpr = bidderRequest.gdprConsent.gdprApplies; // we're handling the undefined case server side
}

if (bid && bid.userIdAsEids) {
payload.eids = bid.userIdAsEids;
}

var payloadString = JSON.stringify(payload);
return {
method: 'POST',
Expand Down
57 changes: 54 additions & 3 deletions test/spec/modules/smilewantedBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { expect } from 'chai';
import { spec } from 'modules/smilewantedBidAdapter.js';
import { newBidder } from 'src/adapters/bidderFactory.js';
import { config } from 'src/config.js';
import * as utils from 'src/utils.js';
import { requestBidsHook } from 'modules/consentManagement.js';

const DISPLAY_REQUEST = [{
adUnitCode: 'sw_300x250',
Expand All @@ -20,6 +17,37 @@ const DISPLAY_REQUEST = [{
transactionId: 'trans_abcd1234'
}];

const DISPLAY_REQUEST_WITH_EIDS = [{
adUnitCode: 'sw_300x250',
bidId: '12345',
sizes: [
[300, 250],
[300, 200]
],
bidder: 'smilewanted',
params: {
zoneId: 1
},
requestId: 'request_abcd1234',
transactionId: 'trans_abcd1234',
userIdAsEids: [{
source: 'pubcid.org',
uids: [{
id: 'some-random-id-value',
atype: 1
}]
}, {
source: 'adserver.org',
uids: [{
id: 'some-random-id-value',
atype: 1,
ext: {
rtiPartner: 'TDID'
}
}]
}]
}];

const DISPLAY_REQUEST_WITH_POSITION_TYPE = [{
adUnitCode: 'sw_300x250',
bidId: '12345',
Expand Down Expand Up @@ -170,6 +198,29 @@ describe('smilewantedBidAdapterTests', function () {
expect(requestContent).to.have.property('pageDomain').and.to.equal('https://localhost/Prebid.js/integrationExamples/gpt/hello_world.html');
});

it('Verify external ids in request and ids found', function () {
config.setConfig({
'currency': {
'adServerCurrency': 'EUR'
}
});
const request = spec.buildRequests(DISPLAY_REQUEST_WITH_EIDS, {});
const requestContent = JSON.parse(request[0].data);

expect(requestContent).to.have.property('eids');
expect(requestContent.eids).to.not.equal(null).and.to.not.be.undefined;
expect(requestContent.eids.length).to.greaterThan(0);
for (let index in requestContent.eids) {
let eid = requestContent.eids[index];
expect(eid.source).to.not.equal(null).and.to.not.be.undefined;
expect(eid.uids).to.not.equal(null).and.to.not.be.undefined;
for (let uidsIndex in eid.uids) {
let uid = eid.uids[uidsIndex];
expect(uid.id).to.not.equal(null).and.to.not.be.undefined;
}
}
});

describe('gdpr tests', function () {
afterEach(function () {
config.resetConfig();
Expand Down

0 comments on commit db30d06

Please sign in to comment.