Skip to content

Commit 322a7b8

Browse files
jdrobieckimike-chowla
authored andcommitted
AdOcean adapter: GDPR support (#2988)
* GDPR support * do not send empty gdpr_consent * AdOcean adapter: tests for gdpr_support * remove old comment
1 parent e1e03db commit 322a7b8

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

modules/adoceanBidAdapter.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@ function buildEndpointUrl(emiter, payload) {
1515
return 'https://' + emiter + '/ad.json?' + payloadString;
1616
}
1717

18-
function buildRequest(masterBidRequests, masterId) {
18+
function buildRequest(masterBidRequests, masterId, gdprConsent) {
1919
const firstBid = masterBidRequests[0];
2020
const payload = {
2121
id: masterId,
2222
};
23+
if (gdprConsent) {
24+
payload.gdpr_consent = gdprConsent.consentString || undefined;
25+
payload.gdpr = gdprConsent.gdprApplies ? 1 : 0;
26+
}
2327

2428
const bidIdMap = {};
2529

@@ -72,15 +76,15 @@ export const spec = {
7276
return !!(bid.params.slaveId && bid.params.masterId && bid.params.emiter);
7377
},
7478

75-
buildRequests: function(validBidRequests) {
79+
buildRequests: function(validBidRequests, bidderRequest) {
7680
const bidRequestsByMaster = {};
7781
let requests = [];
7882

79-
utils._each(validBidRequests, function(v) {
80-
assignToMaster(v, bidRequestsByMaster);
83+
utils._each(validBidRequests, function(bidRequest) {
84+
assignToMaster(bidRequest, bidRequestsByMaster);
8185
});
82-
requests = utils._map(bidRequestsByMaster, function(v, k) {
83-
return buildRequest(v, k);
86+
requests = utils._map(bidRequestsByMaster, function(requests, masterId) {
87+
return buildRequest(requests, masterId, bidderRequest.gdprConsent);
8488
});
8589

8690
return requests;

test/spec/modules/adoceanBidAdapter_spec.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,36 @@ describe('AdoceanAdapter', () => {
5757
}
5858
];
5959

60+
const bidderRequest = {
61+
gdprConsent: {
62+
consentString: 'BOQHk-4OSlWKFBoABBPLBd-AAAAgWAHAACAAsAPQBSACmgFTAOkA',
63+
gdprApplies: true
64+
}
65+
};
66+
6067
it('should add bidIdMap with slaveId => bidId mapping', () => {
61-
const request = spec.buildRequests(bidRequests)[0];
68+
const request = spec.buildRequests(bidRequests, bidderRequest)[0];
6269
expect(request.bidIdMap).to.exists;
6370
const bidIdMap = request.bidIdMap;
6471
expect(bidIdMap[bidRequests[0].params.slaveId]).to.equal(bidRequests[0].bidId);
6572
});
6673

6774
it('sends bid request to url via GET', () => {
68-
const request = spec.buildRequests(bidRequests)[0];
75+
const request = spec.buildRequests(bidRequests, bidderRequest)[0];
6976
expect(request.method).to.equal('GET');
7077
expect(request.url).to.match(new RegExp(`^https://${bidRequests[0].params.emiter}/ad.json`));
7178
});
7279

7380
it('should attach id to url', () => {
74-
const request = spec.buildRequests(bidRequests)[0];
81+
const request = spec.buildRequests(bidRequests, bidderRequest)[0];
7582
expect(request.url).to.include('id=' + bidRequests[0].params.masterId);
7683
});
84+
85+
it('should attach consent information to url', () => {
86+
const request = spec.buildRequests(bidRequests, bidderRequest)[0];
87+
expect(request.url).to.include('gdpr=1');
88+
expect(request.url).to.include('gdpr_consent=' + bidderRequest.gdprConsent.consentString);
89+
});
7790
})
7891

7992
describe('interpretResponse', () => {

0 commit comments

Comments
 (0)