diff --git a/modules/pulsepointBidAdapter.js b/modules/pulsepointBidAdapter.js index fc637cc9fff..94733ad7805 100644 --- a/modules/pulsepointBidAdapter.js +++ b/modules/pulsepointBidAdapter.js @@ -34,7 +34,7 @@ export const spec = { !!(bid && bid.params && bid.params.cp && bid.params.ct) ), - buildRequests: bidRequests => { + buildRequests: (bidRequests, bidderRequest) => { const request = { id: bidRequests[0].bidderRequestId, imp: bidRequests.map(slot => impression(slot)), @@ -42,6 +42,7 @@ export const spec = { app: app(bidRequests), device: device(), }; + applyGdpr(bidderRequest, request); return { method: 'POST', url: '//bid.contextweb.com/header/ortb', @@ -304,6 +305,16 @@ function adSize(slot) { return [1, 1]; } +/** + * Applies GDPR parameters to request. + */ +function applyGdpr(bidderRequest, ortbRequest) { + if (bidderRequest && bidderRequest.gdprConsent) { + ortbRequest.regs = { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies ? 1 : 0 } }; + ortbRequest.user = { ext: { consent: bidderRequest.gdprConsent.consentString } }; + } +} + /** * Parses the native response from the Bid given. */ diff --git a/test/spec/modules/pulsepointBidAdapter_spec.js b/test/spec/modules/pulsepointBidAdapter_spec.js index b4793256ee0..709dbeb76a2 100644 --- a/test/spec/modules/pulsepointBidAdapter_spec.js +++ b/test/spec/modules/pulsepointBidAdapter_spec.js @@ -273,4 +273,25 @@ describe('PulsePoint Adapter Tests', () => { expect(ortbRequest.app.storeurl).to.equal('http://pulsepoint.com/apps'); expect(ortbRequest.app.domain).to.equal('pulsepoint.com'); }); + + it('Verify GDPR', () => { + const bidderRequest = { + gdprConsent: { + gdprApplies: true, + consentString: 'serialized_gpdr_data' + } + }; + const request = spec.buildRequests(slotConfigs, bidderRequest); + expect(request.url).to.equal('//bid.contextweb.com/header/ortb'); + expect(request.method).to.equal('POST'); + const ortbRequest = JSON.parse(request.data); + // user object + expect(ortbRequest.user).to.not.equal(null); + expect(ortbRequest.user.ext).to.not.equal(null); + expect(ortbRequest.user.ext.consent).to.equal('serialized_gpdr_data'); + // regs object + expect(ortbRequest.regs).to.not.equal(null); + expect(ortbRequest.regs.ext).to.not.equal(null); + expect(ortbRequest.regs.ext.gdpr).to.equal(1); + }); });