Skip to content

Commit

Permalink
Add GDPR support to GumGum Adapter (prebid#2595)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcoder authored and dluxemburg committed Jul 17, 2018
1 parent 677e336 commit ce7abf3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
7 changes: 6 additions & 1 deletion modules/gumgumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ function isBidRequestValid (bid) {
* @param {validBidRequests[]} - an array of bids
* @return ServerRequest Info describing the request to the server.
*/
function buildRequests (validBidRequests) {
function buildRequests (validBidRequests, bidderRequest) {
const bids = [];
const gdprConsent = Object.assign({ consentString: null, gdprApplies: true }, bidderRequest && bidderRequest.gdprConsent)
utils._each(validBidRequests, bidRequest => {
const timeout = config.getConfig('bidderTimeout');
const {
Expand All @@ -123,6 +124,10 @@ function buildRequests (validBidRequests) {
data.ni = parseInt(params.ICV, 10);
data.pi = 5;
}
data.gdprApplies = gdprConsent.gdprApplies;
if (gdprConsent.gdprApplies) {
data.gdprConsent = gdprConsent.consentString;
}

bids.push({
id: bidId,
Expand Down
16 changes: 14 additions & 2 deletions test/spec/modules/gumgumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,24 @@ describe('gumgumAdapter', () => {
];

it('sends bid request to ENDPOINT via GET', () => {
const requests = spec.buildRequests(bidRequests);
const request = requests[0];
const request = spec.buildRequests(bidRequests)[0];
expect(request.url).to.equal(ENDPOINT);
expect(request.method).to.equal('GET');
expect(request.id).to.equal('30b31c1838de1e');
});
it('should add consent parameters if gdprConsent is present', () => {
const gdprConsent = { consentString: 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', gdprApplies: true };
const fakeBidRequest = { gdprConsent: gdprConsent };
const bidRequest = spec.buildRequests(bidRequests, fakeBidRequest)[0];
expect(bidRequest.data.gdprApplies).to.eq(true);
expect(bidRequest.data.gdprConsent).to.eq('BOJ/P2HOJ/P2HABABMAAAAAZ+A==');
});
it('should handle gdprConsent is present but values are undefined case', () => {
const gdprConsent = { consent_string: undefined, gdprApplies: undefined };
const fakeBidRequest = { gdprConsent: gdprConsent };
const bidRequest = spec.buildRequests(bidRequests, fakeBidRequest)[0];
expect(bidRequest.data).to.not.include.any.keys('gdprConsent')
});
})

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

0 comments on commit ce7abf3

Please sign in to comment.