//
//  NativeAdModel.swift
//  sdk-demo-ios
//
//  Created by Smaato Inc on 15.04.20.
//  Copyright © 2020 Smaato Inc. All rights reserved.
//

import UIKit
import SmaatoSDKNative

struct NativeAdModel: AdModel {
    var mode: RenderMode
    var adSpaceId: String
    var name: String

    init(mode: RenderMode, adSpaceId: String, name: String) {
        self.mode = mode
        self.adSpaceId = adSpaceId
        self.name = name
    }

    init?(dictionary: [String: Any]) {
        guard let mode = dictionary["mode"] as? Int,
              let adSpaceId = dictionary["adSpaceId"] as? String,
              let name = dictionary["name"]  as? String else {
            return nil
        }
        self.init(mode: RenderMode(rawValue: mode)!, adSpaceId: adSpaceId, name: name)
    }
}

enum RenderMode: Int, CaseIterable {
    case auto
    case manual

    var description: String {
        switch self {
        case .auto:
            return "Auto rendering by NextGen SDK"
        case .manual:
            return "Manual rendering by publisher"
        }
    }
}

