Skip to content

Commit

Permalink
Teads adapter: add dsa info support in bid request & response
Browse files Browse the repository at this point in the history
  • Loading branch information
github-christophe-oudar committed Feb 8, 2024
1 parent cd4717c commit f52b284
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
8 changes: 8 additions & 0 deletions modules/teadsBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ export const spec = {
payload.userAgentClientHints = userAgentClientHints;
}

const dsa = deepAccess(bidderRequest, 'ortb2.regs.ext.dsa');
if (dsa) {
payload.dsa = dsa;
}

const payloadString = JSON.stringify(payload);
return {
method: 'POST',
Expand Down Expand Up @@ -138,6 +143,9 @@ export const spec = {
if (bid.dealId) {
bidResponse.dealId = bid.dealId
}
if (bid.adrender) {
bidResponse.meta.adrender = bid.dsaAdRender;
}
bidResponses.push(bidResponse);
});
}
Expand Down
45 changes: 43 additions & 2 deletions test/spec/modules/teadsBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,45 @@ describe('teadsBidAdapter', () => {
}
});
}

it('should add dsa info to payload if available', function () {
const bidRequestWithDsa = Object.assign({}, bidderRequestDefault, {
ortb2: {
regs: {
ext: {
dsa: {
dsarequired: '1',
pubrender: '2',
datatopub: '3',
transparency: [{
domain: 'test.com',
dsaparams: [1, 2, 3]
}]
}
}
}
}
});

const requestWithDsa = spec.buildRequests(bidRequests, bidRequestWithDsa);
const payload = JSON.parse(requestWithDsa.data);

expect(payload.dsa).to.exist;
expect(payload.dsa).to.deep.equal(
{
dsarequired: '1',
pubrender: '2',
datatopub: '3',
transparency: [{
domain: 'test.com',
dsaparams: [1, 2, 3]
}]
}
);

const defaultRequest = spec.buildRequests(bidRequests, bidderRequestDefault);
expect(JSON.parse(defaultRequest.data).dsa).to.not.exist;
});
});

describe('interpretResponse', function() {
Expand All @@ -1031,7 +1070,8 @@ describe('teadsBidAdapter', () => {
'width': 350,
'creativeId': 'fs3ff',
'placementId': 34,
'dealId': 'ABC_123'
'dealId': 'ABC_123',
'dsaAdRender': 1
}]
}
};
Expand All @@ -1057,7 +1097,8 @@ describe('teadsBidAdapter', () => {
'currency': 'USD',
'netRevenue': true,
'meta': {
advertiserDomains: []
advertiserDomains: [],
adrender: 1
},
'ttl': 360,
'ad': AD_SCRIPT,
Expand Down

0 comments on commit f52b284

Please sign in to comment.