Skip to content

Commit

Permalink
Fidelity: Add SCHAIN Support (#4945)
Browse files Browse the repository at this point in the history
* Add SCHAIN Support

* Add SCHAIN support

* Add SCHAIN Support - 2
  • Loading branch information
onaydenov authored Apr 3, 2020
1 parent 136baaa commit b0a2818
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
22 changes: 22 additions & 0 deletions modules/fidelityBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const spec = {
tmax: bidderRequest.timeout,
defloc: bidderRequest.refererInfo.referer,
referrer: getTopWindowReferrer(),
schain: getSupplyChain(bidRequest.schain),
};
setConsentParams(bidderRequest.gdprConsent, bidderRequest.uspConsent, payload);

Expand Down Expand Up @@ -118,4 +119,25 @@ function setConsentParams(gdprConsent, uspConsent, payload) {
}
}

function getSupplyChain(schain) {
var supplyChain = '';
if (schain != null && schain.nodes) {
supplyChain = schain.ver + ',' + schain.complete;
for (let i = 0; i < schain.nodes.length; i++) {
supplyChain += '!';
supplyChain += (schain.nodes[i].asi) ? encodeURIComponent(schain.nodes[i].asi) : '';
supplyChain += ',';
supplyChain += (schain.nodes[i].sid) ? encodeURIComponent(schain.nodes[i].sid) : '';
supplyChain += ',';
supplyChain += (schain.nodes[i].hp) ? encodeURIComponent(schain.nodes[i].hp) : '';
supplyChain += ',';
supplyChain += (schain.nodes[i].rid) ? encodeURIComponent(schain.nodes[i].rid) : '';
supplyChain += ',';
supplyChain += (schain.nodes[i].name) ? encodeURIComponent(schain.nodes[i].name) : '';
supplyChain += ',';
supplyChain += (schain.nodes[i].domain) ? encodeURIComponent(schain.nodes[i].domain) : '';
}
}
return supplyChain;
}
registerBidder(spec);
21 changes: 18 additions & 3 deletions test/spec/modules/fidelityBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,19 @@ describe('FidelityAdapter', function () {
bidId: '2ffb201a808da7',
bidderRequestId: '178e34bad3658f',
requestId: 'c45dd708-a418-42ec-b8a7-b70a6c6fab0a',
transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b'
transactionId: 'd45dd707-a418-42ec-b8a7-b70a6c6fab0b',
schain: {
ver: '1.0',
complete: 1,
nodes: [{
asi: 'exchange1.com',
sid: '1234',
hp: 1,
rid: 'bid-request-1',
name: 'publisher',
domain: 'publisher.com'
}]
}
}
],
start: 1472239426002,
Expand All @@ -78,7 +90,8 @@ describe('FidelityAdapter', function () {
}
};

it('should add source and verison to the tag', function () {
it('should add params to the request', function () {
let schainString = '1.0,1!exchange1.com,1234,1,bid-request-1,publisher,publisher.com';
const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
const payload = request.data;
expect(payload.from).to.exist;
Expand All @@ -92,9 +105,11 @@ describe('FidelityAdapter', function () {
expect(payload.flashver).to.exist;
expect(payload.tmax).to.exist;
expect(payload.defloc).to.exist;
expect(payload.schain).to.exist.and.to.be.a('string');
expect(payload.schain).to.equal(schainString);
});

it('should add gdpr consent information to the request', function () {
it('should add consent information to the request', function () {
let consentString = 'BOJ8RZsOJ8RZsABAB8AAAAAZ+A==';
let uspConsentString = '1YN-';
bidderRequest.gdprConsent = {
Expand Down

0 comments on commit b0a2818

Please sign in to comment.