From 98162dc9d9b5318ea7042e4a23c5ef1d7b8b4c27 Mon Sep 17 00:00:00 2001 From: naru-tsujine <159880063+naru-tsujine@users.noreply.github.com> Date: Sat, 24 Feb 2024 13:55:55 +0900 Subject: [PATCH] Logicad Bid Adapter: Add paapi support (#11123) * Logicad Bid Adapter: Add paapi support * Logicad Bid Adapter: fix * Logicad Bid Adapter: fix test --- modules/logicadBidAdapter.js | 50 +++++++++++----- test/spec/modules/logicadBidAdapter_spec.js | 63 ++++++++++++++++++++- 2 files changed, 98 insertions(+), 15 deletions(-) diff --git a/modules/logicadBidAdapter.js b/modules/logicadBidAdapter.js index 07f9b893887..fe4dd83c9e2 100644 --- a/modules/logicadBidAdapter.js +++ b/modules/logicadBidAdapter.js @@ -31,13 +31,25 @@ export const spec = { }, interpretResponse: function (serverResponse, bidderRequest) { serverResponse = serverResponse.body; + const bids = []; + if (!serverResponse || serverResponse.error) { return bids; } + serverResponse.seatbid.forEach(function (seatbid) { bids.push(seatbid.bid); }) + + const fledgeAuctionConfigs = deepAccess(serverResponse, 'ext.fledgeAuctionConfigs') || []; + if (fledgeAuctionConfigs.length) { + return { + bids, + fledgeAuctionConfigs, + }; + } + return bids; }, getUserSyncs: function (syncOptions, serverResponses) { @@ -52,32 +64,42 @@ export const spec = { }, }; -function newBidRequest(bid, bidderRequest) { +function newBidRequest(bidRequest, bidderRequest) { + const bid = { + adUnitCode: bidRequest.adUnitCode, + bidId: bidRequest.bidId, + transactionId: bidRequest.ortb2Imp?.ext?.tid, + sizes: bidRequest.sizes, + params: bidRequest.params, + mediaTypes: bidRequest.mediaTypes, + } + + const fledgeEnabled = deepAccess(bidderRequest, 'fledgeEnabled') + if (fledgeEnabled) { + const ae = deepAccess(bidRequest, 'ortb2Imp.ext.ae'); + if (ae) { + bid.ae = ae; + } + } + const data = { // TODO: fix auctionId leak: https://github.com/prebid/Prebid.js/issues/9781 - auctionId: bid.auctionId, - bidderRequestId: bid.bidderRequestId, - bids: [{ - adUnitCode: bid.adUnitCode, - bidId: bid.bidId, - transactionId: bid.ortb2Imp?.ext?.tid, - sizes: bid.sizes, - params: bid.params, - mediaTypes: bid.mediaTypes - }], + auctionId: bidRequest.auctionId, + bidderRequestId: bidRequest.bidderRequestId, + bids: [bid], prebidJsVersion: '$prebid.version$', // TODO: is 'page' the right value here? referrer: bidderRequest.refererInfo.page, auctionStartTime: bidderRequest.auctionStart, - eids: bid.userIdAsEids, + eids: bidRequest.userIdAsEids, }; - const sua = deepAccess(bid, 'ortb2.device.sua'); + const sua = deepAccess(bidRequest, 'ortb2.device.sua'); if (sua) { data.sua = sua; } - const userData = deepAccess(bid, 'ortb2.user.data'); + const userData = deepAccess(bidRequest, 'ortb2.user.data'); if (userData) { data.userData = userData; } diff --git a/test/spec/modules/logicadBidAdapter_spec.js b/test/spec/modules/logicadBidAdapter_spec.js index 3c1383781b9..12e8ca31cbb 100644 --- a/test/spec/modules/logicadBidAdapter_spec.js +++ b/test/spec/modules/logicadBidAdapter_spec.js @@ -36,6 +36,11 @@ describe('LogicadAdapter', function () { } }] }], + ortb2Imp: { + ext: { + ae: 1 + } + }, ortb2: { device: { sua: { @@ -176,7 +181,8 @@ describe('LogicadAdapter', function () { numIframes: 1, stack: [] }, - auctionStart: 1563337198010 + auctionStart: 1563337198010, + fledgeEnabled: true }; const serverResponse = { body: { @@ -203,6 +209,49 @@ describe('LogicadAdapter', function () { } } }; + + const paapiServerResponse = { + body: { + seatbid: + [{ + bid: { + requestId: '51ef8751f9aead', + cpm: 101.0234, + width: 300, + height: 250, + creativeId: '2019', + currency: 'JPY', + netRevenue: true, + ttl: 60, + ad: '