Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A4G Adapter GDPR support #2501

Merged
merged 2 commits into from
May 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions modules/a4gBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const spec = {
return bid.params && !!bid.params.zoneId;
},

buildRequests: function(validBidRequests) {
buildRequests: function(validBidRequests, bidderRequest) {
let deliveryUrl = '';
const idParams = [];
const sizeParams = [];
Expand All @@ -41,16 +41,25 @@ export const spec = {
deliveryUrl = A4G_DEFAULT_BID_URL;
}

let data = {
[IFRAME_PARAM_NAME]: 0,
[LOCATION_PARAM_NAME]: utils.getTopWindowUrl(),
[SIZE_PARAM_NAME]: sizeParams.join(ARRAY_PARAM_SEPARATOR),
[ID_PARAM_NAME]: idParams.join(ARRAY_PARAM_SEPARATOR),
[ZONE_ID_PARAM_NAME]: zoneIds.join(ARRAY_PARAM_SEPARATOR)
};

if (bidderRequest && bidderRequest.gdprConsent) {
data.gdpr = {
applies: bidderRequest.gdprConsent.gdprApplies,
consent: bidderRequest.gdprConsent.consentString
};
}

return {
method: 'GET',
url: deliveryUrl,
data: {
[IFRAME_PARAM_NAME]: 0,
[LOCATION_PARAM_NAME]: utils.getTopWindowUrl(),
[SIZE_PARAM_NAME]: sizeParams.join(ARRAY_PARAM_SEPARATOR),
[ID_PARAM_NAME]: idParams.join(ARRAY_PARAM_SEPARATOR),
[ZONE_ID_PARAM_NAME]: zoneIds.join(ARRAY_PARAM_SEPARATOR)
}
data: data
};
},

Expand Down
20 changes: 20 additions & 0 deletions test/spec/modules/a4gBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,26 @@ describe('a4gAdapterTests', () => {
const request = spec.buildRequests(bidRequests);
expect(request.data.zoneId).to.equal('59304;59354');
});

it('bidRequest gdpr consent', () => {
const consentString = 'consentString';
const bidderRequest = {
bidderCode: 'a4g',
auctionId: '18fd8b8b0bd757',
bidderRequestId: '418b37f85e772c',
timeout: 3000,
gdprConsent: {
consentString: consentString,
gdprApplies: true
}
};

const request = spec.buildRequests(bidRequests, bidderRequest);

expect(request.data.gdpr).to.exist;
expect(request.data.gdpr.applies).to.exist.and.to.be.true;
expect(request.data.gdpr.consent).to.exist.and.to.equal(consentString);
});
});

describe('interpretResponse', () => {
Expand Down