//
//  ListLeftVariableRadioButtonBodyTextModel.swift
//  MVMCoreUI
//
//  Created by Kevin Christiano on 4/1/20.
//  Copyright © 2020 Verizon Wireless. All rights reserved.
//


open class ListLeftVariableRadioButtonBodyTextModel: ListItemModel, MoleculeModelProtocol {
    //-----------------------------------------------------
    // MARK: - Properties
    //-----------------------------------------------------
    
    public static var identifier: String = "listLVRBBdy"
    public var radioButton: RadioButtonModel
    public var headlineBody: HeadlineBodyModel
            
    //-----------------------------------------------------
    // MARK: - Initializer
    //-----------------------------------------------------
    
    public init(radioButton: RadioButtonModel, headlineBody: HeadlineBodyModel) {
        self.radioButton = radioButton
        self.headlineBody = headlineBody
        super.init()
    }
    
    //-----------------------------------------------------
    // MARK: - Methods
    //-----------------------------------------------------
    
    open override func setDefaults() {
        super.setDefaults()
         headlineBody.style = .item
    }
    
    //-----------------------------------------------------
    // MARK: - Keys
    //-----------------------------------------------------
    
    private enum CodingKeys: String, CodingKey {
        case moleculeName
        case radioButton
        case headlineBody
    }
    
    //-----------------------------------------------------
    // MARK: - Codec
    //-----------------------------------------------------
    
    required public init(from decoder: Decoder) throws {
        let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
        radioButton = try typeContainer.decode(RadioButtonModel.self, forKey: .radioButton)
        headlineBody = try typeContainer.decode(HeadlineBodyModel.self, forKey: .headlineBody)
        try super.init(from: decoder)
    }
    
    public  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(radioButton, forKey: .radioButton)
        try container.encode(headlineBody, forKey: .headlineBody)
    }
}
