//
//  ListLeftVariableCheckboxAllTextAndLinksModel.swift
//  MVMCoreUI
//
//  Created by Lekshmi S on 11/02/20.
//  Copyright © 2020 Verizon Wireless. All rights reserved.
//


open class ListLeftVariableCheckboxAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol {
    //--------------------------------------------------
    // MARK: - Properties
    //--------------------------------------------------
    
    open class var identifier: String {
        return "listLVCB"
    }
    
    public var checkbox: CheckboxModel
    public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel
    
    //--------------------------------------------------
    // MARK: - Initializer
    //--------------------------------------------------
    
    public init(checkbox: CheckboxModel, eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel) {
        self.checkbox = checkbox
        self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink
        super.init()
    }
    
    //--------------------------------------------------
    // MARK: - Keys
    //--------------------------------------------------
    
    private enum CodingKeys: String, CodingKey {
        case moleculeName
        case eyebrowHeadlineBodyLink
        case checkbox
    }
    
    //--------------------------------------------------
    // MARK: - Codec
    //--------------------------------------------------
    
    required public init(from decoder: Decoder) throws {
        let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
        eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink)
        checkbox = try typeContainer.decodeIfPresent(CheckboxModel.self, forKey: .checkbox) ?? CheckboxModel()
        try super.init(from: decoder)
    }
    
    open override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        try container.encode(moleculeName, forKey: .moleculeName)
        try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink)
        try container.encode(checkbox, forKey: .checkbox)
    }
}
