diff --git a/modules/rasBidAdapter.js b/modules/rasBidAdapter.js index 5a832d7f336..0fed99447f6 100644 --- a/modules/rasBidAdapter.js +++ b/modules/rasBidAdapter.js @@ -130,23 +130,23 @@ const getGdprParams = (bidderRequest) => { }; const parseAuctionConfigs = (serverResponse, bidRequest) => { - if (isEmpty(serverResponse) || isEmpty(bidRequest)) { + if (isEmpty(bidRequest)) { return null; } - let auctionConfigs = []; - const bidConfigs = Object.fromEntries(bidRequest.bidIds.map(x => [x.bidId, x])); + const auctionConfigs = []; + const gctx = serverResponse && serverResponse.body?.gctx; - serverResponse.ads.filter(bid => bidConfigs.hasOwnProperty(bid.id) && bidConfigs[bid.id].fledgeEnabled).forEach((bid) => { + bidRequest.bidIds.filter(bid => bid.fledgeEnabled).forEach((bid) => { auctionConfigs.push({ - 'bidId': bidConfigs[bid.id].bidId, + 'bidId': bid.bidId, 'config': { 'seller': 'https://csr.onet.pl', - 'decisionLogicUrl': `https://csr.onet.pl/${bidConfigs[bid.id].network}/v1/protected-audience-api/decision-logic.js`, + 'decisionLogicUrl': `https://csr.onet.pl/${encodeURIComponent(bid.params.network)}/v1/protected-audience-api/decision-logic.js`, 'interestGroupBuyers': ['https://csr.onet.pl'], 'auctionSignals': { - 'site': bidConfigs[bid.id].site, - 'kvismobile': bidConfigs[bid.id].isMobile, - 'iusizes': bidConfigs[bid.id].iusizes + 'params': bid.params, + 'sizes': bid.sizes, + 'gctx': gctx } } }); @@ -180,10 +180,8 @@ export const spec = { const bidIds = bidRequests.map((bid) => ({ slot: bid.params.slot, bidId: bid.bidId, - network: network, - site: bid.params.site, - isMobile: Boolean(bid.params.pageContext?.keyValues?.ismobile), - iusizes: getAdUnitSizes(bid), + sizes: getAdUnitSizes(bid), + params: bid.params, fledgeEnabled: fledgeEligible })); @@ -196,12 +194,9 @@ export const spec = { interpretResponse: function (serverResponse, bidRequest) { const response = serverResponse.body; - if (!response || !response.ads || response.ads.length === 0) { - return []; - } - const fledgeAuctionConfigs = parseAuctionConfigs(response, bidRequest); - const bids = response.ads.map(buildBid).filter((bid) => !isEmpty(bid)); + const fledgeAuctionConfigs = parseAuctionConfigs(serverResponse, bidRequest); + const bids = (!response || !response.ads || response.ads.length === 0) ? [] : response.ads.map(buildBid).filter((bid) => !isEmpty(bid)); if (fledgeAuctionConfigs) { // Return a tuple of bids and auctionConfigs. It is possible that bids could be null. diff --git a/test/spec/modules/rasBidAdapter_spec.js b/test/spec/modules/rasBidAdapter_spec.js index bfa72a2510e..719e15ad695 100644 --- a/test/spec/modules/rasBidAdapter_spec.js +++ b/test/spec/modules/rasBidAdapter_spec.js @@ -1,6 +1,7 @@ import { expect } from 'chai'; import { spec } from 'modules/rasBidAdapter.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; +import {getAdUnitSizes} from '../../../src/utils'; const CSR_ENDPOINT = 'https://csr.onet.pl/4178463/csr-006/csr.json?nid=4178463&'; @@ -192,5 +193,56 @@ describe('rasBidAdapter', function () { const resp = spec.interpretResponse({ body: res }, {}); expect(resp).to.deep.equal([]); }); + + it('should generate auctionConfig when fledge is enabled', function () { + let bidRequest = { + method: 'GET', + url: 'https://example.com', + bidIds: [{ + slot: 'top', + bidId: '123', + network: 'testnetwork', + sizes: ['300x250'], + params: { + site: 'testsite', + area: 'testarea', + network: 'testnetwork' + }, + fledgeEnabled: true + }, + { + slot: 'top', + bidId: '456', + network: 'testnetwork', + sizes: ['300x250'], + params: { + site: 'testsite', + area: 'testarea', + network: 'testnetwork' + }, + fledgeEnabled: false + }] + }; + + let auctionConfigs = [{ + 'bidId': '123', + 'config': { + 'seller': 'https://csr.onet.pl', + 'decisionLogicUrl': 'https://csr.onet.pl/testnetwork/v1/protected-audience-api/decision-logic.js', + 'interestGroupBuyers': ['https://csr.onet.pl'], + 'auctionSignals': { + 'params': { + site: 'testsite', + area: 'testarea', + network: 'testnetwork' + }, + 'sizes': ['300x250'], + 'gctx': '1234567890' + } + } + }]; + const resp = spec.interpretResponse({body: {gctx: '1234567890'}}, bidRequest); + expect(resp).to.deep.equal({bids: [], fledgeAuctionConfigs: auctionConfigs}); + }); }); });