diff --git a/modules/proxistoreBidAdapter.js b/modules/proxistoreBidAdapter.js index 0b553ce995bf..9b1675722bef 100644 --- a/modules/proxistoreBidAdapter.js +++ b/modules/proxistoreBidAdapter.js @@ -1,5 +1,4 @@ import { registerBidder } from '../src/adapters/bidderFactory.js'; - const BIDDER_CODE = 'proxistore'; const PROXISTORE_VENDOR_ID = 418; @@ -27,38 +26,35 @@ function _createServerRequest(bidRequests, bidderRequest) { language: bidRequests[0].params.language, gdpr: { applies: false, + consentGiven: false }, }; if (bidderRequest && bidderRequest.gdprConsent) { - if ( - typeof bidderRequest.gdprConsent.gdprApplies === 'boolean' && - bidderRequest.gdprConsent.gdprApplies - ) { + const { gdprConsent } = bidderRequest; + if (typeof gdprConsent.gdprApplies === 'boolean' && gdprConsent.gdprApplies) { payload.gdpr.applies = true; } - if ( - typeof bidderRequest.gdprConsent.consentString === 'string' && - bidderRequest.gdprConsent.consentString - ) { + if (typeof gdprConsent.consentString === 'string' && gdprConsent.consentString) { payload.gdpr.consentString = bidderRequest.gdprConsent.consentString; } - - if ( - bidderRequest.gdprConsent.vendorData && - bidderRequest.gdprConsent.vendorData.vendorConsents && - typeof bidderRequest.gdprConsent.vendorData.vendorConsents[PROXISTORE_VENDOR_ID.toString(10)] !== 'undefined' - ) { - payload.gdpr.consentGiven = !!bidderRequest.gdprConsent.vendorData - .vendorConsents[PROXISTORE_VENDOR_ID.toString(10)]; + if (gdprConsent.vendorData) { + const {vendorData} = gdprConsent; + const {apiVersion} = gdprConsent; + if (apiVersion === 2 && vendorData.vendor && vendorData.vendor.consents && typeof vendorData.vendor.consents[PROXISTORE_VENDOR_ID.toString(10)] !== 'undefined') { + payload.gdpr.consentGiven = !!vendorData.vendor.consents[PROXISTORE_VENDOR_ID.toString(10)]; + } else if (apiVersion === 1 && vendorData.vendorConsents && typeof vendorData.vendorConsents[PROXISTORE_VENDOR_ID.toString(10)] !== 'undefined') { + payload.gdpr.consentGiven = !!vendorData.vendorConsents[PROXISTORE_VENDOR_ID.toString(10)]; + } } } const options = { contentType: 'application/json', - withCredentials: !!payload.gdpr.consentGiven, + withCredentials: payload.gdpr.consentGiven, }; + const endPointUri = payload.gdpr.consentGiven || !payload.gdpr.applies ? `https://abs.proxistore.com/${payload.language}/v3/rtb/prebid/multi` : `https://abs.proxistore.com/${payload.language}/v3/rtb/prebid/multi/cookieless`; diff --git a/test/spec/modules/proxistoreBidAdapter_spec.js b/test/spec/modules/proxistoreBidAdapter_spec.js index f98d9633320c..e7db01828e0e 100644 --- a/test/spec/modules/proxistoreBidAdapter_spec.js +++ b/test/spec/modules/proxistoreBidAdapter_spec.js @@ -2,16 +2,20 @@ import { expect } from 'chai'; let { spec } = require('modules/proxistoreBidAdapter'); const BIDDER_CODE = 'proxistore'; describe('ProxistoreBidAdapter', function () { + const consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A=='; const bidderRequest = { bidderCode: BIDDER_CODE, auctionId: '1025ba77-5463-4877-b0eb-14b205cb9304', bidderRequestId: '10edf38ec1a719', gdprConsent: { + apiVersion: 2, gdprApplies: true, - consentString: 'CONSENT_STRING', + consentString: consentString, vendorData: { - vendorConsents: { - 418: true, + vendor: { + consents: { + 418: true, + }, }, }, }, @@ -75,6 +79,29 @@ describe('ProxistoreBidAdapter', function () { expect(request.url).equal(url.cookieBase); // doens't have gpdr consent bidderRequest.gdprConsent.vendorData = null; + + request = spec.buildRequests([bid], bidderRequest); + expect(request.url).equal(url.cookieLess); + + // api v2 + bidderRequest.gdprConsent = { + gdprApplies: true, + allowAuctionWithoutConsent: true, + consentString: consentString, + vendorData: { + vendor: { + consents: { + '418': true + } + }, + }, + apiVersion: 2 + }; + // has gdpr consent + request = spec.buildRequests([bid], bidderRequest); + expect(request.url).equal(url.cookieBase); + + bidderRequest.gdprConsent.vendorData.vendor = {}; request = spec.buildRequests([bid], bidderRequest); expect(request.url).equal(url.cookieLess); }); @@ -105,26 +132,29 @@ describe('ProxistoreBidAdapter', function () { expect(data.bids[0].floor).to.be.null; }); }); - describe('interpretResponse', function() { - const emptyResponseParam = {body: []}; - const fakeResponseParam = {body: [ - { ad: '', - cpm: 6.25, - creativeId: '22c3290b-8cd5-4cd6-8e8c-28a2de180ccd', - currency: 'EUR', - dealId: '2021-03_a63ec55e-b9bb-4ca4-b2c9-f456be67e656', - height: 600, - netRevenue: true, - requestId: '3543724f2a033c9', - segments: [], - ttl: 10, - vastUrl: null, - vastXml: null, - width: 300} - ] + describe('interpretResponse', function () { + const emptyResponseParam = { body: [] }; + const fakeResponseParam = { + body: [ + { + ad: '', + cpm: 6.25, + creativeId: '22c3290b-8cd5-4cd6-8e8c-28a2de180ccd', + currency: 'EUR', + dealId: '2021-03_a63ec55e-b9bb-4ca4-b2c9-f456be67e656', + height: 600, + netRevenue: true, + requestId: '3543724f2a033c9', + segments: [], + ttl: 10, + vastUrl: null, + vastXml: null, + width: 300, + }, + ], }; - it('should always return an array', function() { + it('should always return an array', function () { let response = spec.interpretResponse(emptyResponseParam, bid); expect(response).to.be.an('array'); expect(response.length).equal(0);