Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TrustX Bid Adapter to support gdpr #2565

Merged
merged 21 commits into from
May 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
031fa56
Add trustx adapter and tests for it
PWyrembak Aug 15, 2017
319cadd
update integration example
PWyrembak Aug 15, 2017
0e877f9
Merge remote-tracking branch 'upstream/master'
PWyrembak Aug 16, 2017
0425234
Merge remote-tracking branch 'upstream/master'
PWyrembak Sep 8, 2017
69ab1f4
Update trustx adapter
PWyrembak Sep 9, 2017
817f2fa
Merge remote-tracking branch 'upstream/master'
PWyrembak Sep 19, 2017
ef50012
Post-review fixes of Trustx adapter
PWyrembak Sep 19, 2017
bd5b75c
Merge remote-tracking branch 'upstream/master'
PWyrembak Oct 3, 2017
bff944b
Merge remote-tracking branch 'upstream/master'
PWyrembak Oct 10, 2017
843440d
Code improvement for trustx adapter: changed default price type from …
PWyrembak Oct 10, 2017
cd01e9b
Merge remote-tracking branch 'upstream/master'
PWyrembak Oct 17, 2017
aa249b5
Update TrustX adapter to support the 1.0 version
PWyrembak Oct 17, 2017
119728b
Merge remote-tracking branch 'upstream/master'
PWyrembak Oct 20, 2017
5f60ac3
Make requested changes for TrustX adapter
PWyrembak Oct 20, 2017
2628673
Updated markdown file for TrustX adapter
PWyrembak Oct 24, 2017
b3badf9
Merge remote-tracking branch 'upstream/master'
PWyrembak Oct 26, 2017
292b4dd
Fix TrustX adapter and spec file
PWyrembak Oct 26, 2017
b3e1465
Merge remote-tracking branch 'upstream/master'
PWyrembak Dec 19, 2017
09b581a
Update TrustX adapter: r parameter was added to ad request as cache b…
PWyrembak Dec 19, 2017
7b16a1c
Merge remote-tracking branch 'upstream/master'
PWyrembak May 17, 2018
73b7249
Add support of gdpr to Trustx Bid Adapter
PWyrembak May 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion modules/trustxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ export const spec = {
* Make a server request from the list of BidRequests.
*
* @param {BidRequest[]} validBidRequests - an array of bids
* @param {bidderRequest} - bidder request object
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function(validBidRequests) {
buildRequests: function(validBidRequests, bidderRequest) {
const auids = [];
const bidsMap = {};
const bids = validBidRequests || [];
Expand All @@ -59,6 +60,15 @@ export const spec = {
r: reqId
};

if (bidderRequest && bidderRequest.gdprConsent) {
if (bidderRequest.gdprConsent.consentString) {
payload.gdpr_consent = bidderRequest.gdprConsent.consentString;
}
payload.gdpr_applies =
(typeof bidderRequest.gdprConsent.gdprApplies === 'boolean')
? Number(bidderRequest.gdprConsent.gdprApplies) : 1;
}

return {
method: 'GET',
url: ENDPOINT_URL,
Expand Down
24 changes: 24 additions & 0 deletions test/spec/modules/trustxBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,30 @@ describe('TrustXAdapter', function () {
expect(payload).to.have.property('r', '22edbae2733bf6');
delete bidRequests[1].params.priceType;
});

it('if gdprConsent is present payload must have gdpr params', () => {
const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: true}});
const payload = request.data;
expect(payload).to.be.an('object');
expect(payload).to.have.property('gdpr_consent', 'AAA');
expect(payload).to.have.property('gdpr_applies', 1);
});

it('if gdprApplies is false gdpr_applies must be 0', () => {
const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA', gdprApplies: false}});
const payload = request.data;
expect(payload).to.be.an('object');
expect(payload).to.have.property('gdpr_consent', 'AAA');
expect(payload).to.have.property('gdpr_applies', 0);
});

it('if gdprApplies is undefined gdpr_applies must be 1', () => {
const request = spec.buildRequests(bidRequests, {gdprConsent: {consentString: 'AAA'}});
const payload = request.data;
expect(payload).to.be.an('object');
expect(payload).to.have.property('gdpr_consent', 'AAA');
expect(payload).to.have.property('gdpr_applies', 1);
});
});

describe('interpretResponse', () => {
Expand Down