Skip to content

Commit

Permalink
try to fix duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
vrishko committed Jun 19, 2024
1 parent 01abf1e commit b59be78
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions modules/smartyadsBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,27 @@ const adUrls = {
const URL_SYNC = 'https://as.ck-ie.com/prebidjs?p=7c47322e527cf8bdeb7facc1bb03387a';

function isBidResponseValid(bid) {
if (!bid.requestId || !bid.cpm || !bid.creativeId ||
!bid.ttl || !bid.currency) {
return false;
}
switch (bid['mediaType']) {
if (!bid) return false;

const { requestId, cpm, creativeId, ttl, currency } = bid;

const isValid = [requestId, cpm, creativeId, ttl, currency].every(item => !!item);
if (!isValid) return false;

switch (bid.mediaType) {
case BANNER:
return Boolean(bid.width && bid.height && bid.ad);
return !!(bid.ad && bid.width && bid.height);
case VIDEO:
return Boolean(bid.vastUrl) || Boolean(bid.vastXml);
return !!(bid.vastUrl || bid.vastXml);
case NATIVE:
return Boolean(bid.native && bid.native.title && bid.native.image && bid.native.impressionTrackers);
const native = bid.native;
return !!(native && native.image && native.impressionTrackers);
default:
return false;
}
}


function getAdUrlByRegion(bid) {
let adUrl;

Expand Down

0 comments on commit b59be78

Please sign in to comment.