Skip to content

Commit

Permalink
A4G Adapter GDPR support (#2501)
Browse files Browse the repository at this point in the history
* A4G Adapter GDPR support

* Resolve formatting errors
  • Loading branch information
adilets authored and harpere committed May 8, 2018
1 parent 9bbd122 commit 2dd6e1a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
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

0 comments on commit 2dd6e1a

Please sign in to comment.