diff --git a/modules/platformioBidAdapter.js b/modules/platformioBidAdapter.js index b33aeab8f88..79fcd2120b5 100644 --- a/modules/platformioBidAdapter.js +++ b/modules/platformioBidAdapter.js @@ -23,7 +23,7 @@ export const spec = { isBidRequestValid: bid => ( !!(bid && bid.params && bid.params.pubId && bid.params.placementId) ), - buildRequests: bidRequests => { + buildRequests: (bidRequests, bidderRequest) => { const request = { id: bidRequests[0].bidderRequestId, at: 2, @@ -32,6 +32,7 @@ export const spec = { app: app(bidRequests), device: device(bidRequests), }; + applyGdpr(bidderRequest, request); return { method: 'POST', url: '//piohbdisp.hb.adx1.com/', @@ -276,6 +277,13 @@ function parse(rawResponse) { return null; } +function applyGdpr(bidderRequest, ortbRequest) { + if (bidderRequest && bidderRequest.gdprConsent) { + ortbRequest.regs = { ext: { gdpr: bidderRequest.gdprConsent.gdprApplies ? 1 : 0 } }; + ortbRequest.user = { ext: { consent: bidderRequest.gdprConsent.consentString } }; + } +} + function nativeResponse(imp, bid) { if (imp['native']) { const nativeAd = parse(bid.adm); diff --git a/test/spec/modules/platformioBidAdapter_spec.js b/test/spec/modules/platformioBidAdapter_spec.js index fc8ba5bf45e..39ada3cc01c 100644 --- a/test/spec/modules/platformioBidAdapter_spec.js +++ b/test/spec/modules/platformioBidAdapter_spec.js @@ -313,4 +313,23 @@ describe('Platform.io Adapter Tests', () => { expect(ortbRequest.app.storeurl).to.equal('http://platform.io/apps'); expect(ortbRequest.app.domain).to.equal('platform.io'); }); + + it('Verify GDPR', () => { + const bidderRequest = { + gdprConsent: { + gdprApplies: true, + consentString: 'serialized_gpdr_data' + } + }; + const request = spec.buildRequests(slotConfigs, bidderRequest); + expect(request.url).to.equal('//piohbdisp.hb.adx1.com/'); + expect(request.method).to.equal('POST'); + const ortbRequest = JSON.parse(request.data); + 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'); + expect(ortbRequest.regs).to.not.equal(null); + expect(ortbRequest.regs.ext).to.not.equal(null); + expect(ortbRequest.regs.ext.gdpr).to.equal(1); + }); });