Skip to content

Commit 32aef56

Browse files
margsliujsnellbaker
authored andcommitted
Add schain support for LockerDome adapter (#4360)
1 parent 94233d4 commit 32aef56

File tree

2 files changed

+64
-10
lines changed

2 files changed

+64
-10
lines changed

modules/lockerdomeBidAdapter.js

+15-8
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ export const spec = {
99
return !!bid.params.adUnitId;
1010
},
1111
buildRequests: function(bidRequests, bidderRequest) {
12+
let schain;
13+
1214
const adUnitBidRequests = bidRequests.map(function (bid) {
15+
if (bid.schain) schain = schain || bid.schain;
1316
return {
1417
requestId: bid.bidId,
1518
adUnitCode: bid.adUnitCode,
1619
adUnitId: utils.getBidIdParameter('adUnitId', bid.params),
1720
sizes: bid.mediaTypes && bid.mediaTypes.banner && bid.mediaTypes.banner.sizes
18-
}
21+
};
1922
});
2023

2124
const bidderRequestCanonicalUrl = (bidderRequest && bidderRequest.refererInfo && bidderRequest.refererInfo.canonicalUrl) || '';
@@ -25,12 +28,16 @@ export const spec = {
2528
url: encodeURIComponent(bidderRequestCanonicalUrl),
2629
referrer: encodeURIComponent(bidderRequestReferer)
2730
};
28-
29-
if (bidderRequest && bidderRequest.gdprConsent) {
30-
payload.gdpr = {
31-
applies: bidderRequest.gdprConsent.gdprApplies,
32-
consent: bidderRequest.gdprConsent.consentString
33-
};
31+
if (schain) {
32+
payload.schain = schain;
33+
}
34+
if (bidderRequest) {
35+
if (bidderRequest.gdprConsent) {
36+
payload.gdpr = {
37+
applies: bidderRequest.gdprConsent.gdprApplies,
38+
consent: bidderRequest.gdprConsent.consentString
39+
};
40+
}
3441
}
3542

3643
const payloadString = JSON.stringify(payload);
@@ -58,5 +65,5 @@ export const spec = {
5865
};
5966
});
6067
},
61-
}
68+
};
6269
registerBidder(spec);

test/spec/modules/lockerdomeBidAdapter_spec.js

+49-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,18 @@ describe('LockerDomeAdapter', function () {
1717
transactionId: 'b55e97d7-792c-46be-95a5-3df40b115734',
1818
bidId: '2652ca954bce9',
1919
bidderRequestId: '14a54fade69854',
20-
auctionId: 'd4c83108-615d-4c2c-9384-dac9ffd4fd72'
20+
auctionId: 'd4c83108-615d-4c2c-9384-dac9ffd4fd72',
21+
schain: {
22+
ver: '1.0',
23+
complete: 1,
24+
nodes: [
25+
{
26+
asi: 'indirectseller.com',
27+
sid: '00001',
28+
hp: 1
29+
}
30+
]
31+
}
2132
}, {
2233
bidder: 'lockerdome',
2334
params: {
@@ -32,7 +43,18 @@ describe('LockerDomeAdapter', function () {
3243
transactionId: '73459f05-c482-4706-b2b7-72e6f6264ce6',
3344
bidId: '4510f2834773ce',
3445
bidderRequestId: '14a54fade69854',
35-
auctionId: 'd4c83108-615d-4c2c-9384-dac9ffd4fd72'
46+
auctionId: 'd4c83108-615d-4c2c-9384-dac9ffd4fd72',
47+
schain: {
48+
ver: '1.0',
49+
complete: 1,
50+
nodes: [
51+
{
52+
asi: 'indirectseller.com',
53+
sid: '00001',
54+
hp: 1
55+
}
56+
]
57+
}
3658
}];
3759

3860
describe('isBidRequestValid', function () {
@@ -103,6 +125,31 @@ describe('LockerDomeAdapter', function () {
103125
});
104126
});
105127

128+
it('should add schain to request if available', function () {
129+
const bidderRequest = {
130+
refererInfo: {
131+
canonicalUrl: 'https://example.com/canonical',
132+
referer: 'https://example.com'
133+
}
134+
};
135+
const schainExpected = {
136+
ver: '1.0',
137+
complete: 1,
138+
nodes: [
139+
{
140+
asi: 'indirectseller.com',
141+
sid: '00001',
142+
hp: 1
143+
}
144+
]
145+
};
146+
147+
const request = spec.buildRequests(bidRequests, bidderRequest);
148+
const requestData = JSON.parse(request.data);
149+
expect(requestData.schain).to.be.an('object');
150+
expect(requestData.schain).to.deep.equal(schainExpected);
151+
});
152+
106153
describe('interpretResponse', function () {
107154
it('should return an empty array if an invalid response is passed', function () {
108155
const interpretedResponse = spec.interpretResponse({ body: {} });

0 commit comments

Comments
 (0)