diff --git a/modules/freewheelSSPBidAdapter.js b/modules/freewheelSSPBidAdapter.js index 632df8fe93c..87c1979ac5d 100644 --- a/modules/freewheelSSPBidAdapter.js +++ b/modules/freewheelSSPBidAdapter.js @@ -208,7 +208,7 @@ export const spec = { * @param {BidRequest[]} bidRequests A non-empty list of bid requests which should be sent to the Server. * @return ServerRequest Info describing the request to the server. */ - buildRequests: function(bidRequests) { + buildRequests: function(bidRequests, bidderRequest) { // var currency = config.getConfig(currency); var currentBidRequest = bidRequests[0]; @@ -223,6 +223,24 @@ export const spec = { componentId: getComponentId(currentBidRequest.params.format) }; + // Add GDPR flag and consent string + if (bidderRequest.gdprConsent) { + requestParams._fw_gdpr_consent = bidderRequest.gdprConsent.consentString; + + if (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') { + requestParams._fw_gdpr = bidderRequest.gdprConsent.gdprApplies; + } + } + + var vastParams = currentBidRequest.params.vastUrlParams; + if (typeof vastParams === 'object') { + for (var key in vastParams) { + if (vastParams.hasOwnProperty(key)) { + requestParams[key] = vastParams[key]; + } + } + } + var location = utils.getTopWindowUrl(); if (isValidUrl(location)) { requestParams.loc = location; diff --git a/test/spec/modules/freewheelSSPBidAdapter_spec.js b/test/spec/modules/freewheelSSPBidAdapter_spec.js index 33bd647efaa..ec4483fafed 100644 --- a/test/spec/modules/freewheelSSPBidAdapter_spec.js +++ b/test/spec/modules/freewheelSSPBidAdapter_spec.js @@ -52,21 +52,27 @@ describe('freewheelSSP BidAdapter Test', () => { 'bidId': '30b31c1838de1e', 'bidderRequestId': '22edbae2733bf6', 'auctionId': '1d1a030790a475', + 'gdprConsent': { + 'consentString': 'BOJ/P2HOJ/P2HABABMAAAAAZ+A==', + 'gdprApplies': true + } } ]; it('should add parameters to the tag', () => { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, bidRequests[0]); const payload = request.data; expect(payload.reqType).to.equal('AdsSetup'); expect(payload.protocolVersion).to.equal('2.0'); expect(payload.zoneId).to.equal('277225'); expect(payload.componentId).to.equal('mustang'); expect(payload.playerSize).to.equal('300x600'); + expect(payload._fw_gdpr).to.equal(true); + expect(payload._fw_gdpr_consent).to.equal('BOJ/P2HOJ/P2HABABMAAAAAZ+A=='); }); it('sends bid request to ENDPOINT via GET', () => { - const request = spec.buildRequests(bidRequests); + const request = spec.buildRequests(bidRequests, bidRequests[0]); expect(request.url).to.contain(ENDPOINT); expect(request.method).to.equal('GET'); }); @@ -139,7 +145,7 @@ describe('freewheelSSP BidAdapter Test', () => { let formattedAd = '
'; it('should get correct bid response', () => { - var request = spec.buildRequests(bidRequests); + var request = spec.buildRequests(formattedBidRequests, formattedBidRequests[0]); let expectedResponse = [ { @@ -160,7 +166,7 @@ describe('freewheelSSP BidAdapter Test', () => { }); it('should get correct bid response with formated ad', () => { - var request = spec.buildRequests(formattedBidRequests); + var request = spec.buildRequests(formattedBidRequests, formattedBidRequests[0]); let expectedResponse = [ { @@ -181,7 +187,7 @@ describe('freewheelSSP BidAdapter Test', () => { }); it('handles nobid responses', () => { - var reqest = spec.buildRequests(formattedBidRequests); + var reqest = spec.buildRequests(formattedBidRequests, formattedBidRequests[0]); let response = ''; let result = spec.interpretResponse(response, reqest);