Skip to content

Commit

Permalink
Update TrustX Bid Adapter to support gdpr (prebid#2565)
Browse files Browse the repository at this point in the history
* Add trustx adapter and tests for it

* update integration example

* Update trustx adapter

* Post-review fixes of Trustx adapter

* Code improvement for trustx adapter: changed default price type from gross to net

* Update TrustX adapter to support the 1.0 version

* Make requested changes for TrustX adapter

* Updated markdown file for TrustX adapter

* Fix TrustX adapter and spec file

* Update TrustX adapter: r parameter was added to ad request as cache buster

* Add support of gdpr to Trustx Bid Adapter
  • Loading branch information
PWyrembak authored and dluxemburg committed Jul 17, 2018
1 parent a8a8778 commit c932248
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
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

0 comments on commit c932248

Please sign in to comment.