import UIKit
import AdViewSDK

fileprivate let storedMrecImpDisplayBanner = "POSIDcsts715vz17x"

class InAppMrecBannerViewController: BannerBaseViewController, BannerViewDelegate {

    private var adviewBannerView: BannerView!

    override func loadView() {
        super.loadView()
        createAd()
    }

    func createAd() {
        adviewBannerView = BannerView(frame: CGRect(origin: .zero, size: adSize), configID: storedMrecImpDisplayBanner, adSize: adSize)

        adviewBannerView.delegate = self
        adviewBannerView.adFormat = .banner
        adviewBannerView.videoParameters.placement = .InBanner

        bannerView.backgroundColor = .clear
        bannerView.addSubview(adviewBannerView)

        adviewBannerView.loadAd()
    }

    func bannerViewPresentationController() -> UIViewController? {
        self
    }

    func bannerView(_ bannerView: BannerView, didFailToReceiveAdWith error: Error) {
        AdViewDemoLogger.shared.error("Banner view did fail to receive ad with error: \(error)")
    }
}
