Skip to content

Commit

Permalink
Adform Bid Adapter: add DSA support (#11066)
Browse files Browse the repository at this point in the history
  • Loading branch information
braizhas authored Feb 7, 2024
1 parent 9f5e205 commit 9270339
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 2 deletions.
9 changes: 8 additions & 1 deletion modules/adfBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const spec = {
const cur = currency && [ currency ];
const eids = setOnAny(validBidRequests, 'userIdAsEids');
const schain = setOnAny(validBidRequests, 'schain');
const dsa = commonFpd.regs?.ext?.dsa;

const imp = validBidRequests.map((bid, id) => {
bid.netRevenue = pt;
Expand Down Expand Up @@ -179,6 +180,10 @@ export const spec = {
deepSetValue(request, 'source.ext.schain', schain);
}

if (dsa) {
deepSetValue(request, 'regs.ext.dsa', dsa);
}

return {
method: 'POST',
url: 'https://' + adxDomain + '/adx/openrtb',
Expand All @@ -201,6 +206,7 @@ export const spec = {
const bidResponse = bidResponses[id];
if (bidResponse) {
const mediaType = deepAccess(bidResponse, 'ext.prebid.type');
const dsa = deepAccess(bidResponse, 'ext.dsa');
const result = {
requestId: bid.bidId,
cpm: bidResponse.price,
Expand All @@ -214,7 +220,8 @@ export const spec = {
dealId: bidResponse.dealid,
meta: {
mediaType,
advertiserDomains: bidResponse.adomain
advertiserDomains: bidResponse.adomain,
dsa
}
};

Expand Down
63 changes: 62 additions & 1 deletion test/spec/modules/adfBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,49 @@ describe('Adf adapter', function () {
assert.equal(request.user, undefined);
assert.equal(request.regs, undefined);
});

it('should transfer DSA info', function () {
let validBidRequests = [ { bidId: 'bidId', params: { siteId: 'siteId' } } ];

let request = JSON.parse(
spec.buildRequests(validBidRequests, {
refererInfo: { page: 'page' },
ortb2: {
regs: {
ext: {
dsa: {
dsarequired: '1',
pubrender: '2',
datatopub: '3',
transparency: [
{
domain: 'test.com',
dsaparams: [1, 2, 3]
}
]
}
}
}
}
}).data
);

assert.deepEqual(request.regs, {
ext: {
dsa: {
dsarequired: '1',
pubrender: '2',
datatopub: '3',
transparency: [
{
domain: 'test.com',
dsaparams: [1, 2, 3]
}
]
}
}
});
});
});

it('should add test and is_debug to request, if test is set in parameters', function () {
Expand Down Expand Up @@ -1007,7 +1050,16 @@ describe('Adf adapter', function () {
adomain: [ 'demo.com' ],
ext: {
prebid: {
type: 'native'
type: 'native',
},
dsa: {
behalf: 'some-behalf',
paid: 'some-paid',
transparency: [{
domain: 'test.com',
dsaparams: [1, 2, 3]
}],
adrender: 1
}
}
}
Expand Down Expand Up @@ -1070,6 +1122,15 @@ describe('Adf adapter', function () {
assert.deepEqual(bids[0].mediaType, 'native');
assert.deepEqual(bids[0].meta.mediaType, 'native');
assert.deepEqual(bids[0].meta.advertiserDomains, [ 'demo.com' ]);
assert.deepEqual(bids[0].meta.dsa, {
behalf: 'some-behalf',
paid: 'some-paid',
transparency: [{
domain: 'test.com',
dsaparams: [1, 2, 3]
}],
adrender: 1
});
assert.deepEqual(bids[0].dealId, 'deal-id');
});
it('should set correct native params', function () {
Expand Down

0 comments on commit 9270339

Please sign in to comment.