Skip to content

Commit

Permalink
vidazoo adapter - GDPR support (prebid#2834)
Browse files Browse the repository at this point in the history
  • Loading branch information
thewizarodofoz authored and AlessandroDG committed Sep 13, 2018
1 parent 8d10cd4 commit 28227af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
7 changes: 4 additions & 3 deletions modules/vidazooBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function isBidRequestValid(bid) {
return !!(params.cId && params.pId);
}

function buildRequest(bid, topWindowUrl, size) {
function buildRequest(bid, topWindowUrl, size, bidderRequest) {
const {params, bidId} = bid;
const {bidFloor, cId, pId, ext} = params;
// Prebid's util function returns AppNexus style sizes (i.e. 300x250)
Expand All @@ -34,6 +34,7 @@ function buildRequest(bid, topWindowUrl, size) {
bidFloor: bidFloor,
bidId: bidId,
publisherId: pId,
consent: bidderRequest.gdprConsent && bidderRequest.gdprConsent.consentString,
width,
height
}
Expand All @@ -46,13 +47,13 @@ function buildRequest(bid, topWindowUrl, size) {
return dto;
}

function buildRequests(validBidRequests) {
function buildRequests(validBidRequests, bidderRequest) {
const topWindowUrl = utils.getTopWindowUrl();
const requests = [];
validBidRequests.forEach(validBidRequest => {
const sizes = utils.parseSizesInput(validBidRequest.sizes);
sizes.forEach(size => {
const request = buildRequest(validBidRequest, topWindowUrl, size);
const request = buildRequest(validBidRequest, topWindowUrl, size, bidderRequest);
requests.push(request);
});
});
Expand Down
11 changes: 10 additions & 1 deletion test/spec/modules/vidazooBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {expect} from 'chai';
import {spec as adapter, URL} from 'modules/vidazooBidAdapter';
import * as utils from 'src/utils';

const BID = {
'bidId': '2d52001cabd527',
'params': {
Expand All @@ -19,6 +20,12 @@ const BID = {
'requestId': 'b0777d85-d061-450e-9bc7-260dd54bbb7a'
};

const BIDDER_REQUEST = {
'gdprConsent': {
'consentString': 'consent_string'
}
};

const SERVER_RESPONSE = {
body: {
'ad': '<iframe>console.log("hello world")</iframe>',
Expand Down Expand Up @@ -109,12 +116,13 @@ describe('VidazooBidAdapter', () => {
});

it('should build request for each size', () => {
const requests = adapter.buildRequests([BID]);
const requests = adapter.buildRequests([BID], BIDDER_REQUEST);
expect(requests).to.have.length(2);
expect(requests[0]).to.deep.equal({
method: 'GET',
url: `${URL}/prebid/59db6b3b4ffaa70004f45cdc`,
data: {
consent: 'consent_string',
width: '300',
height: '250',
url: 'http://www.greatsite.com',
Expand All @@ -130,6 +138,7 @@ describe('VidazooBidAdapter', () => {
method: 'GET',
url: `${URL}/prebid/59db6b3b4ffaa70004f45cdc`,
data: {
consent: 'consent_string',
width: '300',
height: '600',
url: 'http://www.greatsite.com',
Expand Down

0 comments on commit 28227af

Please sign in to comment.