diff --git a/modules/arteebeeBidAdapter.js b/modules/arteebeeBidAdapter.js index 65510b43bc0..e8d319c8845 100644 --- a/modules/arteebeeBidAdapter.js +++ b/modules/arteebeeBidAdapter.js @@ -16,11 +16,11 @@ export const spec = { return 'params' in bidRequest && bidRequest.params.pub !== undefined && bidRequest.params.source !== undefined; }, - buildRequests: function (validBidRequests) { + buildRequests: function (validBidRequests, bidderRequest) { var requests = []; for (let i = 0; i < validBidRequests.length; i++) { - let prebidReq = makePrebidRequest(validBidRequests[i]); + let prebidReq = makePrebidRequest(validBidRequests[i], bidderRequest); if (prebidReq) { requests.push(prebidReq); } @@ -58,20 +58,20 @@ export const spec = { } return bidResponses; }, - getUserSyncs: function (syncOptions, serverResponses) { + getUserSyncs: function (syncOptions, serverResponses, gdprConsent) { return []; } } registerBidder(spec); -function makePrebidRequest(req) { +function makePrebidRequest(req, bidderRequest) { var host = req.params.host || DEFAULT_HOST; var ssp = req.params.ssp || DEFAULT_SSP; var url = window.location.protocol + '//' + host + '/rtb/bid/' + ssp + '?type=json®ister=0'; - const payload = makeRtbRequest(req); + const payload = makeRtbRequest(req, bidderRequest); const payloadString = JSON.stringify(payload); return { @@ -81,8 +81,8 @@ function makePrebidRequest(req) { }; } -function makeRtbRequest(req) { - var auctionId = req.requestId; +function makeRtbRequest(req, bidderRequest) { + var auctionId = req.bidderRequestId; var imp = []; imp.push(makeImp(req)); @@ -100,6 +100,18 @@ function makeRtbRequest(req) { rtbReq.regs = {coppa: 1}; } + if (bidderRequest && bidderRequest.gdprConsent) { + if ((typeof bidderRequest.gdprConsent.gdprApplies === 'boolean') && bidderRequest.gdprConsent.gdprApplies) { + if (!rtbReq.regs) { + rtbReq.regs = {}; + } + rtbReq.regs['ext'] = {'gdpr': 1}; + } + if ((typeof bidderRequest.gdprConsent.consentString === 'string') && bidderRequest.gdprConsent.consentString) { + rtbReq['user'] = {'ext': {'consent': bidderRequest.gdprConsent.consentString}}; + } + } + if (req.params.test) { rtbReq.test = 1; } diff --git a/test/spec/modules/arteebeeBidAdapter_spec.js b/test/spec/modules/arteebeeBidAdapter_spec.js index fe5bbf7ff25..041b48b0bc9 100644 --- a/test/spec/modules/arteebeeBidAdapter_spec.js +++ b/test/spec/modules/arteebeeBidAdapter_spec.js @@ -94,6 +94,34 @@ describe('Arteebee adapater', () => { expect(req).to.not.have.property('test'); expect(req.imp[0]).to.not.have.property('secure'); }); + + it('test gdpr', () => { + let bid = { + bidder: 'arteebee', + params: { + pub: 'prebidtest', + source: 'prebidtest' + }, + sizes: [[300, 250]] + }; + let consentString = 'ABCD'; + let bidderRequest = { + 'gdprConsent': { + consentString: consentString, + gdprApplies: true + } + }; + + const req = JSON.parse(spec.buildRequests([bid], bidderRequest)[0].data); + + expect(req.regs).to.exist; + expect(req.regs.ext).to.exist; + expect(req.regs.ext).to.have.property('gdpr', 1); + + expect(req.user).to.exist; + expect(req.user.ext).to.exist; + expect(req.user.ext).to.have.property('consent', consentString); + }); }); describe('Test interpret response', () => {