Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triplelift Bid Adapter: PAAPI bid response support #10385

Merged
merged 14 commits into from
Aug 23, 2023
Merged
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