From f52b28494f26c1926e6b8a46108e4cc943446a7c Mon Sep 17 00:00:00 2001 From: Christophe Oudar Date: Thu, 8 Feb 2024 16:55:30 +0100 Subject: [PATCH] Teads adapter: add dsa info support in bid request & response --- modules/teadsBidAdapter.js | 8 ++++ test/spec/modules/teadsBidAdapter_spec.js | 45 ++++++++++++++++++++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/modules/teadsBidAdapter.js b/modules/teadsBidAdapter.js index 1c12b0e39681..6ff540197c71 100644 --- a/modules/teadsBidAdapter.js +++ b/modules/teadsBidAdapter.js @@ -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', @@ -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); }); } diff --git a/test/spec/modules/teadsBidAdapter_spec.js b/test/spec/modules/teadsBidAdapter_spec.js index 98f706f5193b..4517f9378354 100644 --- a/test/spec/modules/teadsBidAdapter_spec.js +++ b/test/spec/modules/teadsBidAdapter_spec.js @@ -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() { @@ -1031,7 +1070,8 @@ describe('teadsBidAdapter', () => { 'width': 350, 'creativeId': 'fs3ff', 'placementId': 34, - 'dealId': 'ABC_123' + 'dealId': 'ABC_123', + 'dsaAdRender': 1 }] } }; @@ -1057,7 +1097,8 @@ describe('teadsBidAdapter', () => { 'currency': 'USD', 'netRevenue': true, 'meta': { - advertiserDomains: [] + advertiserDomains: [], + adrender: 1 }, 'ttl': 360, 'ad': AD_SCRIPT,