From 0476a7627330aa8f0f85d399de29242399fb5077 Mon Sep 17 00:00:00 2001 From: Christian Teran Montero Date: Thu, 7 Jun 2018 16:25:20 +1000 Subject: [PATCH] add GDPR remove video sample config form .md file --- modules/playgroundxyzBidAdapter.js | 12 +++-- modules/playgroundxyzBidAdapter.md | 42 ---------------- .../modules/playgroundxyzBidAdapter_spec.js | 49 +++++++++++++++++++ 3 files changed, 58 insertions(+), 45 deletions(-) diff --git a/modules/playgroundxyzBidAdapter.js b/modules/playgroundxyzBidAdapter.js index 75861bd63f1..0e0da35b66f 100644 --- a/modules/playgroundxyzBidAdapter.js +++ b/modules/playgroundxyzBidAdapter.js @@ -28,7 +28,7 @@ export const spec = { */ buildRequests: function (bidRequests, bidderRequest) { const topLocation = utils.getTopWindowLocation(); - const payload = JSON.stringify({ + const payload = { id: bidRequests[0].auctionId, site: { domain: window.location.protocol + '//' + topLocation.hostname, @@ -41,17 +41,23 @@ export const spec = { devicetype: isMobile() ? 1 : isConnectedTV() ? 3 : 2, }, imp: bidRequests.map(mapImpression) - }); + }; const options = { contentType: 'application/json', withCredentials: false }; + if (bidderRequest && bidderRequest.gdprConsent) { + payload.user = {ext: {consent: bidderRequest.gdprConsent.consentString}}; + const gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0; + payload.regs = {ext: {gdpr: gdpr}}; + } + return { method: 'POST', url: URL, - data: payload, + data: JSON.stringify(payload), options, bidderRequest }; diff --git a/modules/playgroundxyzBidAdapter.md b/modules/playgroundxyzBidAdapter.md index 345bf7d0693..c72b9f34dd3 100644 --- a/modules/playgroundxyzBidAdapter.md +++ b/modules/playgroundxyzBidAdapter.md @@ -25,48 +25,6 @@ var adUnits = [ placementId: '10433394' } }] - }, - // Video instream adUnit - { - code: 'video-instream', - sizes: [640, 480], - mediaTypes: { - video: { - context: 'instream' - }, - }, - bids: [{ - bidder: 'playgroundxyz', - params: { - placementId: '9333431', - video: { - skippable: true, - playback_methods: ['auto_play_sound_off'] - } - } - }] - }, - // Video outstream adUnit - { - code: 'video-outstream', - sizes: [[640, 480]], - mediaTypes: { - video: { - context: 'outstream' - } - }, - bids: [ - { - bidder: 'playgroundxyz', - params: { - placementId: '5768085', - video: { - skippable: true, - playback_method: ['auto_play_sound_off'] - } - } - } - ] } ]; ``` diff --git a/test/spec/modules/playgroundxyzBidAdapter_spec.js b/test/spec/modules/playgroundxyzBidAdapter_spec.js index 72cd1205c45..becd8612a9c 100644 --- a/test/spec/modules/playgroundxyzBidAdapter_spec.js +++ b/test/spec/modules/playgroundxyzBidAdapter_spec.js @@ -4,6 +4,7 @@ import { newBidder } from 'src/adapters/bidderFactory'; import { deepClone } from 'src/utils'; const URL = 'https://ads.playground.xyz/host-config/prebid'; +const GDPR_CONSENT = 'XYZ-CONSENT'; describe('playgroundxyzBidAdapter', () => { const adapter = newBidder(spec); @@ -133,4 +134,52 @@ describe('playgroundxyzBidAdapter', () => { expect(result.length).to.equal(0); }); }); + + describe('buildRequests', () => { + let bidRequests = [ + { + 'bidder': 'playgroundxyz', + 'params': { + 'publisherId': 'PUB_FAKE' + }, + 'adUnitCode': 'adunit-code', + 'sizes': [[300, 250]], + 'bidId': '321db112312as', + 'bidderRequestId': '23edabce2731sd6', + 'auctionId': '12as040790a475' + } + ]; + + it('should not populate GDPR', () => { + let bidRequest = Object.assign([], bidRequests); + const request = spec.buildRequests(bidRequest); + let data = JSON.parse(request.data); + expect(data).to.not.have.property('user'); + expect(data).to.not.have.property('regs'); + }); + + it('should populate GDPR and consent string when consetString is presented but not gdpApplies', () => { + let bidRequest = Object.assign([], bidRequests); + const request = spec.buildRequests(bidRequest, {gdprConsent: {consentString: GDPR_CONSENT}}); + let data = JSON.parse(request.data); + expect(data.regs.ext.gdpr).to.equal(0); + expect(data.user.ext.consent).to.equal('XYZ-CONSENT'); + }); + + it('should populate GDPR and consent string when gdpr is set to true', () => { + let bidRequest = Object.assign([], bidRequests); + const request = spec.buildRequests(bidRequest, {gdprConsent: {gdprApplies: true, consentString: GDPR_CONSENT}}); + let data = JSON.parse(request.data); + expect(data.regs.ext.gdpr).to.equal(1); + expect(data.user.ext.consent).to.equal('XYZ-CONSENT'); + }); + + it('should populate GDPR and consent string when gdpr is set to false', () => { + let bidRequest = Object.assign([], bidRequests); + const request = spec.buildRequests(bidRequest, {gdprConsent: {gdprApplies: false, consentString: GDPR_CONSENT}}); + let data = JSON.parse(request.data); + expect(data.regs.ext.gdpr).to.equal(0); + expect(data.user.ext.consent).to.equal('XYZ-CONSENT'); + }); + }); });