diff --git a/modules/gumgumBidAdapter.js b/modules/gumgumBidAdapter.js index 0b7a42230634..6a5575d74fee 100644 --- a/modules/gumgumBidAdapter.js +++ b/modules/gumgumBidAdapter.js @@ -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 { @@ -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, diff --git a/test/spec/modules/gumgumBidAdapter_spec.js b/test/spec/modules/gumgumBidAdapter_spec.js index 276972a163f3..8a59d61e2bc4 100644 --- a/test/spec/modules/gumgumBidAdapter_spec.js +++ b/test/spec/modules/gumgumBidAdapter_spec.js @@ -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', () => {