diff --git a/modules/aduptechBidAdapter.js b/modules/aduptechBidAdapter.js index d83f2a814ed..c7138e43cfe 100644 --- a/modules/aduptechBidAdapter.js +++ b/modules/aduptechBidAdapter.js @@ -1,4 +1,4 @@ -import {getAdUnitSizes, isArray, isBoolean, isEmpty, isFn, isPlainObject} from '../src/utils.js'; +import {deepClone, getAdUnitSizes, isArray, isBoolean, isEmpty, isFn, isPlainObject} from '../src/utils.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {BANNER, NATIVE} from '../src/mediaTypes.js'; import { convertOrtbRequestToProprietaryNative } from '../src/native.js'; @@ -21,14 +21,14 @@ export const internal = { * @returns {null|Object.} */ extractGdpr: (bidderRequest) => { - if (bidderRequest && bidderRequest.gdprConsent) { - return { - consentString: bidderRequest.gdprConsent.consentString, - consentRequired: (isBoolean(bidderRequest.gdprConsent.gdprApplies)) ? bidderRequest.gdprConsent.gdprApplies : true - }; + if (!bidderRequest?.gdprConsent) { + return null; } - return null; + return { + consentString: bidderRequest.gdprConsent.consentString, + consentRequired: (isBoolean(bidderRequest.gdprConsent.gdprApplies)) ? bidderRequest.gdprConsent.gdprApplies : true + }; }, /** @@ -60,30 +60,34 @@ export const internal = { * @returns {null|Object.} */ extractBannerConfig: (bidRequest) => { - const sizes = getAdUnitSizes(bidRequest); - if (isArray(sizes) && !isEmpty(sizes)) { - const banner = { sizes: sizes }; + const adUnitSizes = getAdUnitSizes(bidRequest); + if (!isArray(adUnitSizes) || isEmpty(adUnitSizes)) { + return null; + } - // try to add floor for each banner size - banner.sizes.forEach(size => { - const floor = internal.getFloor(bidRequest, { mediaType: BANNER, size }); - if (floor) { - size.push(floor.floor); - size.push(floor.currency); - } - }); + const banner = { sizes: [] }; - // try to add default floor for banner - const floor = internal.getFloor(bidRequest, { mediaType: BANNER, size: '*' }); + adUnitSizes.forEach(adUnitSize => { + const size = deepClone(adUnitSize); + + // try to add floor for each banner size + const floor = internal.getFloor(bidRequest, { mediaType: BANNER, size: adUnitSize }); if (floor) { - banner.floorPrice = floor.floor; - banner.floorCurrency = floor.currency; + size.push(floor.floor); + size.push(floor.currency); } - return banner; + banner.sizes.push(size); + }); + + // try to add default floor for banner + const floor = internal.getFloor(bidRequest, { mediaType: BANNER, size: '*' }); + if (floor) { + banner.floorPrice = floor.floor; + banner.floorCurrency = floor.currency; } - return null; + return banner; }, /** @@ -93,20 +97,20 @@ export const internal = { * @returns {null|Object.} */ extractNativeConfig: (bidRequest) => { - if (bidRequest?.mediaTypes?.native) { - const native = bidRequest.mediaTypes.native; + if (!bidRequest?.mediaTypes?.native) { + return null; + } - // try to add default floor for native - const floor = internal.getFloor(bidRequest, { mediaType: NATIVE, size: '*' }); - if (floor) { - native.floorPrice = floor.floor; - native.floorCurrency = floor.currency; - } + const native = deepClone(bidRequest.mediaTypes.native); - return native; + // try to add default floor for native + const floor = internal.getFloor(bidRequest, { mediaType: NATIVE, size: '*' }); + if (floor) { + native.floorPrice = floor.floor; + native.floorCurrency = floor.currency; } - return null; + return native; }, /** @@ -116,11 +120,11 @@ export const internal = { * @returns {null|Object.} */ extractParams: (bidRequest) => { - if (bidRequest && bidRequest.params) { - return bidRequest.params + if (!bidRequest?.params) { + return null; } - return null; + return deepClone(bidRequest.params); }, /**