diff --git a/Source/BidMachineAdapterAd.swift b/Source/BidMachineAdapterAd.swift index 783be8f..60277db 100644 --- a/Source/BidMachineAdapterAd.swift +++ b/Source/BidMachineAdapterAd.swift @@ -28,7 +28,14 @@ class BidMachineAdapterAd: NSObject { /// The completion for the ongoing show operation. var showCompletion: ((Result) -> Void)? - + + /// Waterfall item price + var price: Double? { + let setting = self.request.partnerSettings["price"] + let priceNSNum = setting as? NSNumber + return priceNSNum?.doubleValue + } + init(adapter: PartnerAdapter, request: PartnerAdLoadRequest, delegate: PartnerAdDelegate) { self.adapter = adapter self.request = request diff --git a/Source/BidMachineAdapterBannerAd.swift b/Source/BidMachineAdapterBannerAd.swift index 34b43f0..752863a 100644 --- a/Source/BidMachineAdapterBannerAd.swift +++ b/Source/BidMachineAdapterBannerAd.swift @@ -43,9 +43,7 @@ final class BidMachineAdapterBannerAd: BidMachineAdapterAd, PartnerAd { config.populate { $0.withPayload(adm) } } else { config.populate { - let setting = self.request.partnerSettings["price"] - let priceNSNum = setting as? NSNumber - guard let price = priceNSNum?.doubleValue else { + guard let price else { let error = error(.loadFailureInvalidAdRequest) self.log(.loadFailed(error)) completion(.failure(error)) diff --git a/Source/BidMachineAdapterInterstitialAd.swift b/Source/BidMachineAdapterInterstitialAd.swift index 54664f0..60afebd 100644 --- a/Source/BidMachineAdapterInterstitialAd.swift +++ b/Source/BidMachineAdapterInterstitialAd.swift @@ -34,9 +34,7 @@ final class BidMachineAdapterInterstitialAd: BidMachineAdapterAd, PartnerAd { config.populate { $0.withPayload(adm) } } else { config.populate { - let setting = self.request.partnerSettings["price"] - let priceNSNum = setting as? NSNumber - guard let price = priceNSNum?.doubleValue else { + guard let price else { let error = error(.loadFailureInvalidAdRequest) self.log(.loadFailed(error)) completion(.failure(error)) diff --git a/Source/BidMachineAdapterRewardedAd.swift b/Source/BidMachineAdapterRewardedAd.swift index f1fa0c9..8a19e48 100644 --- a/Source/BidMachineAdapterRewardedAd.swift +++ b/Source/BidMachineAdapterRewardedAd.swift @@ -34,9 +34,7 @@ final class BidMachineAdapterRewardedAd: BidMachineAdapterAd, PartnerAd { config.populate { $0.withPayload(adm) } } else { config.populate { - let setting = self.request.partnerSettings["price"] - let priceNSNum = setting as? NSNumber - guard let price = priceNSNum?.doubleValue else { + guard let price else { let error = error(.loadFailureInvalidAdRequest) self.log(.loadFailed(error)) completion(.failure(error))