Skip to content

Commit

Permalink
Add GDPR support for Quantum Adapter (prebid#2621)
Browse files Browse the repository at this point in the history
* quantumBidAdapter initial commit

* eslint errors fixed

* updating quantumBidAdapter for reviews, fixed tests to work with native

* set new prebid location for testing and some fixing

* added supportedMediaTypes

* Tests fixed

* Fixed issues with image assets. Tested with the example provided

* Size and tests fixed

* Modify tests

* hello world revert changes

* package-lock reverted

* hello world reverted CRLF/LF Conversion

* hello world reverted LF/CRLF Conversion

* hello world reverted

* hello world reverted

* hello world reverted

* removed hardcoded bid sizes

* GDPR integration

* GDPR support - change quantx_gdpr to (0,1) values accepted

* restored package-lock

* GDPR tests

* GDPR tests fixed

* Send width/height with native assets
  • Loading branch information
sami-elasticad authored and Pupis committed Jun 7, 2018
1 parent 4673056 commit d0eabee
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 4 deletions.
23 changes: 19 additions & 4 deletions modules/quantumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const spec = {
* @param {validBidRequests[]} - an array of bids
* @return ServerRequest Info describing the request to the server.
*/
buildRequests: function (bidRequests) {
buildRequests: function (bidRequests, bidderRequest) {
return bidRequests.map(bid => {
const qtxRequest = {};
let bidId = '';
Expand Down Expand Up @@ -55,6 +55,12 @@ export const spec = {
bidId = bid.bidId;
}
qtxRequest.auid = placementId;

if (bidderRequest && bidderRequest.gdprConsent) {
qtxRequest.quantx_user_consent_string = bidderRequest.gdprConsent.consentString;
qtxRequest.quantx_gdpr = bidderRequest.gdprConsent.gdprApplies === true ? 1 : 0;
};

const url = devEnpoint || ENDPOINT_URL;

return {
Expand All @@ -64,7 +70,8 @@ export const spec = {
mediaType: mediaType,
renderMode: renderMode,
url: url,
'data': qtxRequest
'data': qtxRequest,
bidderRequest
};
});
},
Expand Down Expand Up @@ -243,13 +250,21 @@ export const spec = {
native.title = asset['title']['text'];
break;
case 2:
native.icon = asset['img'];
native.icon = {
url: asset['img'],
width: asset['w'],
height: asset['h']
};
break;
case 3:
native.body = asset['data']['value'];
break;
case 4:
native.image = asset['img'];
native.image = {
url: asset['img'],
width: asset['w'],
height: asset['h']
};
break;
case 10:
native.sponsoredBy = asset['data']['value'];
Expand Down
57 changes: 57 additions & 0 deletions test/spec/modules/quantumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,63 @@ describe('quantumBidAdapter', () => {
})
})

describe('GDPR conformity', () => {
const bidRequests = [{
'bidder': 'quantum',
'mediaType': 'native',
'params': {
placementId: 21546
},
adUnitCode: 'aaa',
transactionId: '2b8389fe-615c-482d-9f1a-376fb8f7d6b0',
sizes: [[0, 0]],
bidId: '1abgs362e0x48a8',
bidderRequestId: '70deaff71c281d',
auctionId: '5c66da22-426a-4bac-b153-77360bef5337'
}];

const bidderRequest = {
gdprConsent: {
consentString: 'awefasdfwefasdfasd',
gdprApplies: true
}
};

it('should transmit correct data', () => {
const requests = spec.buildRequests(bidRequests, bidderRequest);
expect(requests.length).to.equal(1);
expect(requests[0].data.quantx_gdpr).to.equal(1);
expect(requests[0].data.quantx_user_consent_string).to.equal('awefasdfwefasdfasd');
});
});

describe('GDPR absence conformity', () => {
const bidRequests = [{
'bidder': 'quantum',
'mediaType': 'native',
'params': {
placementId: 21546
},
adUnitCode: 'aaa',
transactionId: '2b8389fe-615c-482d-9f1a-376fb8f7d6b0',
sizes: [[0, 0]],
bidId: '1abgs362e0x48a8',
bidderRequestId: '70deaff71c281d',
auctionId: '5c66da22-426a-4bac-b153-77360bef5337'
}];

const bidderRequest = {
gdprConsent: undefined
};

it('should transmit correct data', () => {
const requests = spec.buildRequests(bidRequests, bidderRequest);
expect(requests.length).to.equal(1);
expect(requests[0].data.quantx_gdpr).to.be.undefined;
expect(requests[0].data.quantx_user_consent_string).to.be.undefined;
});
});

describe('interpretResponse', () => {
let bidderRequest = {
bidderCode: 'bidderCode',
Expand Down

0 comments on commit d0eabee

Please sign in to comment.