Skip to content

Commit

Permalink
Triplelift Bid Adapter: PAAPI bid response support (#10385)
Browse files Browse the repository at this point in the history
* Add ortb2 changes

* Added unit test

* Linting requirements

* fledge / paapi support

* code refactor

* unit tests v1

* unit tests update

* removes unused let

---------

Co-authored-by: nllerandi3lift <[email protected]>
Co-authored-by: Nick Llerandi <[email protected]>
  • Loading branch information
3 people committed Aug 23, 2023
1 parent a094e35 commit c0048a9
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 3 deletions.
23 changes: 20 additions & 3 deletions modules/tripleliftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,26 @@ export const tripleliftAdapterSpec = {

interpretResponse: function(serverResponse, {bidderRequest}) {
let bids = serverResponse.body.bids || [];
return bids.map(function(bid) {
return _buildResponseObject(bidderRequest, bid);
});
const paapi = serverResponse.body.paapi || [];

bids = bids.map(bid => _buildResponseObject(bidderRequest, bid));

if (paapi.length > 0) {
const fledgeAuctionConfigs = paapi.map(config => {
return {
bidId: bidderRequest.bids[config.imp_id].bidId,
config: config.auctionConfig
};
});

logMessage('Response with FLEDGE:', { bids, fledgeAuctionConfigs });
return {
bids,
fledgeAuctionConfigs
};
} else {
return bids;
}
},

getUserSyncs: function(syncOptions, responses, gdprConsent, usPrivacy, gppConsent) {
Expand Down
51 changes: 51 additions & 0 deletions test/spec/modules/tripleliftBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1548,6 +1548,57 @@ describe('triplelift adapter', function () {
expect(result[2].meta.networkId).to.equal('5989');
expect(result[3].meta.networkId).to.equal('5989');
});

it('should return fledgeAuctionConfigs if PAAPI response is received', function() {
response.body.paapi = [
{
imp_id: '0',
auctionConfig: {
seller: 'https://3lift.com',
decisionLogicUrl: 'https://3lift.com/decision_logic.js',
interestGroupBuyers: ['https://some_buyer.com'],
perBuyerSignals: {
'https://some_buyer.com': { a: 1 }
}
}
},
{
imp_id: '2',
auctionConfig: {
seller: 'https://3lift.com',
decisionLogicUrl: 'https://3lift.com/decision_logic.js',
interestGroupBuyers: ['https://some_other_buyer.com'],
perBuyerSignals: {
'https://some_other_buyer.com': { b: 2 }
}
}
}
];

let result = tripleliftAdapterSpec.interpretResponse(response, {bidderRequest});

expect(result).to.have.property('bids');
expect(result).to.have.property('fledgeAuctionConfigs');
expect(result.fledgeAuctionConfigs.length).to.equal(2);
expect(result.fledgeAuctionConfigs[0].bidId).to.equal('30b31c1838de1e');
expect(result.fledgeAuctionConfigs[1].bidId).to.equal('73edc0ba8de203');
expect(result.fledgeAuctionConfigs[0].config).to.deep.equal(
{
'seller': 'https://3lift.com',
'decisionLogicUrl': 'https://3lift.com/decision_logic.js',
'interestGroupBuyers': ['https://some_buyer.com'],
'perBuyerSignals': { 'https://some_buyer.com': { 'a': 1 } }
}
);
expect(result.fledgeAuctionConfigs[1].config).to.deep.equal(
{
'seller': 'https://3lift.com',
'decisionLogicUrl': 'https://3lift.com/decision_logic.js',
'interestGroupBuyers': ['https://some_other_buyer.com'],
'perBuyerSignals': { 'https://some_other_buyer.com': { 'b': 2 } }
}
);
});
});

describe('getUserSyncs', function() {
Expand Down

0 comments on commit c0048a9

Please sign in to comment.