Skip to content

Commit

Permalink
KRKPD-996: refactors interpretResponse (#30) (#11340)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
nickllerandi and “Nick committed Apr 15, 2024
1 parent 2fd1b74 commit 3dda9d2
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions modules/kargoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -243,7 +237,7 @@ function interpretResponse(response, bidRequest) {
}

bidResponses.push(bidResponse);
})
}

return bidResponses;
}
Expand Down

0 comments on commit 3dda9d2

Please sign in to comment.