//
//  ListRightVariableButtonAllTextAndLinksModel.swift
//  MVMCoreUI
//
//  Created by Dhamodaram Nandi on 17/03/20.
//  Copyright © 2020 Verizon Wireless. All rights reserved.
//


public class ListRightVariableButtonAllTextAndLinksModel: ListItemModel, MoleculeModelProtocol {
    //--------------------------------------------------
    // MARK: - Properties
    //--------------------------------------------------
    
    public static var identifier: String = "listRVBtn"
    public var button: ButtonModel
    public var eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel
    
    //--------------------------------------------------
    // MARK: - Initializer
    //--------------------------------------------------
    
    public init(button: ButtonModel, eyebrowHeadlineBodyLink: EyebrowHeadlineBodyLinkModel) {
        self.button = button
        self.eyebrowHeadlineBodyLink = eyebrowHeadlineBodyLink
        super.init()
    }
    
    //--------------------------------------------------
    // MARK: - Methods
    //--------------------------------------------------
    
    override public func setDefaults() {
        super.setDefaults()
        self.button.size = .tiny
        self.button.style = .secondary
    }
    
    //--------------------------------------------------
    // MARK: - Keys
    //--------------------------------------------------
    
    private enum CodingKeys: String, CodingKey {
        case moleculeName
        case button
        case eyebrowHeadlineBodyLink
    }
    
    //--------------------------------------------------
    // MARK: - codec
    //--------------------------------------------------
    
    required public init(from decoder: Decoder) throws {
        let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
        button = try typeContainer.decode(ButtonModel.self, forKey: .button)
        eyebrowHeadlineBodyLink = try typeContainer.decode(EyebrowHeadlineBodyLinkModel.self, forKey: .eyebrowHeadlineBodyLink)
        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(button, forKey: .button)
        try container.encode(eyebrowHeadlineBodyLink, forKey: .eyebrowHeadlineBodyLink)
    }
}
