From 3dda9d211d91e46080936349390f4a4dae610753 Mon Sep 17 00:00:00 2001 From: Nick Llerandi Date: Mon, 15 Apr 2024 13:25:28 -0400 Subject: [PATCH] KRKPD-996: refactors interpretResponse (#30) (#11340) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactors interpretResponse * updates comment * simpler * removes unnecessary comment * removes more unnecessary comments * revert ttl * reverts ttl test values * revert some || changes * removes comments --------- Co-authored-by: “Nick <“nick.llerandi”@kargo.com> --- modules/kargoBidAdapter.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/modules/kargoBidAdapter.js b/modules/kargoBidAdapter.js index fe22915223e..f3b3166ccad 100644 --- a/modules/kargoBidAdapter.js +++ b/modules/kargoBidAdapter.js @@ -195,25 +195,19 @@ function buildRequests(validBidRequests, bidderRequest) { } function interpretResponse(response, bidRequest) { - let bids = response.body; + const bids = response.body; const bidResponses = []; - if (isEmpty(bids)) { + if (isEmpty(bids) || typeof bids !== 'object') { return bidResponses; } - if (typeof bids !== 'object') { - return bidResponses; - } - - Object.entries(bids).forEach((entry) => { - const [bidID, adUnit] = entry; - + for (const [bidID, adUnit] of Object.entries(bids)) { let meta = { mediaType: adUnit.mediaType && BIDDER.SUPPORTED_MEDIA_TYPES.includes(adUnit.mediaType) ? adUnit.mediaType : BANNER }; - if (adUnit.metadata && adUnit.metadata.landingPageDomain) { + if (adUnit.metadata?.landingPageDomain) { meta.clickUrl = adUnit.metadata.landingPageDomain[0]; meta.advertiserDomains = adUnit.metadata.landingPageDomain; } @@ -243,7 +237,7 @@ function interpretResponse(response, bidRequest) { } bidResponses.push(bidResponse); - }) + } return bidResponses; }