import UIKit
import AdViewSDK

fileprivate let storedImpDisplayBanner = "POSIDjw2dypnd7yv8"

class InAppDisplayBannerViewController: BannerBaseViewController, BannerViewDelegate {

    private var adviewBannerView: BannerView!

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

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

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

        bannerView.addSubview(adviewBannerView)
        adviewBannerView.loadAd()
    }

    func bannerViewPresentationController() -> UIViewController? {
        self
    }

    func bannerView(_ bannerView: BannerView, didFailToReceiveAdWith error: Error) {
        AdViewDemoLogger.shared.error("\(error.localizedDescription)")
    }
}
