Skip to content

Commit

Permalink
Doceree bid adaptor: New GDPR related parameters (prebid#7815)
Browse files Browse the repository at this point in the history
* Update docereeBidAdapter.md

* Update docereeBidAdapter.js

* Update docereeBidAdapter.js

* Update docereeBidAdapter.md

* Function to check gdpr consent present

* Unit test case to check if gdpr consent present

* Update docereeBidAdapter_spec.js

* Fixed build errors
  • Loading branch information
shubhendu-singh-doceree authored and avj83 committed Jan 24, 2022
1 parent 4e808c6 commit 9aef83d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
11 changes: 10 additions & 1 deletion modules/docereeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@ export const spec = {
const { placementId } = bid.params;
return !!placementId
},
isGdprConsentPresent: (bid) => {
const { gdpr, gdprConsent } = bid.params;
if (gdpr == '1') {
return !!gdprConsent
}
return true
},
buildRequests: (validBidRequests) => {
const serverRequests = [];
const { data } = config.getConfig('doceree.user')
const { page, domain, token } = config.getConfig('doceree.context')
const encodedUserInfo = window.btoa(encodeURIComponent(JSON.stringify(data)))

validBidRequests.forEach(function(validBidRequest) {
const { publisherUrl, placementId } = validBidRequest.params;
const { publisherUrl, placementId, gdpr, gdprConsent } = validBidRequest.params;
const url = publisherUrl || page
let queryString = '';
queryString = tryAppendQueryString(queryString, 'id', placementId);
Expand All @@ -32,6 +39,8 @@ export const spec = {
queryString = tryAppendQueryString(queryString, 'prebidjs', true);
queryString = tryAppendQueryString(queryString, 'token', token);
queryString = tryAppendQueryString(queryString, 'requestId', validBidRequest.bidId);
queryString = tryAppendQueryString(queryString, 'gdpr', gdpr);
queryString = tryAppendQueryString(queryString, 'gdpr_consent', gdprConsent);

serverRequests.push({
method: 'GET',
Expand Down
2 changes: 2 additions & 0 deletions modules/docereeBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ var adUnits = [
params: {
placementId: 'DOC_7jm9j5eqkl0xvc5w', //required
publisherUrl: document.URL || window.location.href, //optional
gdpr: '1', //optional
gdprConsent:'CPQfU1jPQfU1jG0AAAENAwCAAAAAAAAAAAAAAAAAAAAA.IGLtV_T9fb2vj-_Z99_tkeYwf95y3p-wzhheMs-8NyZeH_B4Wv2MyvBX4JiQKGRgksjLBAQdtHGlcTQgBwIlViTLMYk2MjzNKJrJEilsbO2dYGD9Pn8HT3ZCY70-vv__7v3ff_3g', //optional
}
}
]
Expand Down
10 changes: 9 additions & 1 deletion test/spec/modules/docereeBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ describe('BidlabBidAdapter', function () {
bidder: 'doceree',
params: {
placementId: 'DOC_7jm9j5eqkl0xvc5w',
gdpr: '1',
gdprConsent: 'CPQfU1jPQfU1jG0AAAENAwCAAAAAAAAAAAAAAAAAAAAA.IGLtV_T9fb2vj-_Z99_tkeYwf95y3p-wzhheMs-8NyZeH_B4Wv2MyvBX4JiQKGRgksjLBAQdtHGlcTQgBwIlViTLMYk2MjzNKJrJEilsbO2dYGD9Pn8HT3ZCY70-vv__7v3ff_3g'
}
};

Expand All @@ -44,6 +46,12 @@ describe('BidlabBidAdapter', function () {
});
});

describe('isGdprConsentPresent', function () {
it('Should return true if gdpr consent is present', function () {
expect(spec.isGdprConsentPresent(bid)).to.be.true;
});
});

describe('buildRequests', function () {
let serverRequest = spec.buildRequests([bid]);
serverRequest = serverRequest[0]
Expand All @@ -56,7 +64,7 @@ describe('BidlabBidAdapter', function () {
expect(serverRequest.method).to.equal('GET');
});
it('Returns valid URL', function () {
expect(serverRequest.url).to.equal('https://bidder.doceree.com/v1/adrequest?id=DOC_7jm9j5eqkl0xvc5w&pubRequestedURL=undefined&loggedInUser=JTdCJTIyZ2VuZGVyJTIyJTNBJTIyJTIyJTJDJTIyZW1haWwlMjIlM0ElMjIlMjIlMkMlMjJoYXNoZWRFbWFpbCUyMiUzQSUyMiUyMiUyQyUyMmZpcnN0TmFtZSUyMiUzQSUyMiUyMiUyQyUyMmxhc3ROYW1lJTIyJTNBJTIyJTIyJTJDJTIybnBpJTIyJTNBJTIyJTIyJTJDJTIyaGFzaGVkTlBJJTIyJTNBJTIyJTIyJTJDJTIyY2l0eSUyMiUzQSUyMiUyMiUyQyUyMnppcENvZGUlMjIlM0ElMjIlMjIlMkMlMjJzcGVjaWFsaXphdGlvbiUyMiUzQSUyMiUyMiU3RA%3D%3D&prebidjs=true&requestId=testing&');
expect(serverRequest.url).to.equal('https://bidder.doceree.com/v1/adrequest?id=DOC_7jm9j5eqkl0xvc5w&pubRequestedURL=undefined&loggedInUser=JTdCJTIyZ2VuZGVyJTIyJTNBJTIyJTIyJTJDJTIyZW1haWwlMjIlM0ElMjIlMjIlMkMlMjJoYXNoZWRFbWFpbCUyMiUzQSUyMiUyMiUyQyUyMmZpcnN0TmFtZSUyMiUzQSUyMiUyMiUyQyUyMmxhc3ROYW1lJTIyJTNBJTIyJTIyJTJDJTIybnBpJTIyJTNBJTIyJTIyJTJDJTIyaGFzaGVkTlBJJTIyJTNBJTIyJTIyJTJDJTIyY2l0eSUyMiUzQSUyMiUyMiUyQyUyMnppcENvZGUlMjIlM0ElMjIlMjIlMkMlMjJzcGVjaWFsaXphdGlvbiUyMiUzQSUyMiUyMiU3RA%3D%3D&prebidjs=true&requestId=testing&gdpr=1&gdpr_consent=CPQfU1jPQfU1jG0AAAENAwCAAAAAAAAAAAAAAAAAAAAA.IGLtV_T9fb2vj-_Z99_tkeYwf95y3p-wzhheMs-8NyZeH_B4Wv2MyvBX4JiQKGRgksjLBAQdtHGlcTQgBwIlViTLMYk2MjzNKJrJEilsbO2dYGD9Pn8HT3ZCY70-vv__7v3ff_3g&');
});
});
describe('interpretResponse', function () {
Expand Down

0 comments on commit 9aef83d

Please sign in to comment.