//
//  ListFourColumnDataUsageListItemModel.swift
//  MVMCoreUI
//
//  Created by Kruthika KP on 27/03/20.
//  Copyright © 2020 Verizon Wireless. All rights reserved.
//


public class ListFourColumnDataUsageListItemModel: ListItemModel, MoleculeModelProtocol {
    //--------------------------------------------------
    // MARK: - Properties
    //--------------------------------------------------
    
    public static var identifier: String = "list4C"
    public var label1: LabelModel
    public var arrow: ArrowModel
    public var label2: LabelModel
    public var label3: LabelModel
    public var label4: LabelModel
    
    //--------------------------------------------------
    // MARK: - Initializer
    //--------------------------------------------------
    
    public init(label1:LabelModel, label2:LabelModel, label3:LabelModel,label4:LabelModel, arrow:ArrowModel) {
        self.label1 = label1
        self.label2 = label2
        self.label3 = label3
        self.label4 = label4
        self.arrow = arrow
        super.init()
    }
    
    //--------------------------------------------------
    // MARK: - Keys
    //--------------------------------------------------
    
    private enum CodingKeys: String, CodingKey {
        case moleculeName
        case label1
        case label2
        case label3
        case label4
        case arrow
    }
    
    //--------------------------------------------------
    // MARK: - Codec
    //--------------------------------------------------
    
    required public init(from decoder: Decoder) throws {
        let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
        label1 = try typeContainer.decode(LabelModel.self, forKey: .label1)
        label2 = try typeContainer.decode(LabelModel.self, forKey: .label2)
        label3 = try typeContainer.decode(LabelModel.self, forKey: .label3)
        label4 = try typeContainer.decode(LabelModel.self, forKey: .label4)
        arrow = try typeContainer.decode(ArrowModel.self, forKey: .arrow)
        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(label1, forKey: .label1)
        try container.encode(label2, forKey: .label2)
        try container.encode(label3, forKey: .label3)
        try container.encode(label4, forKey: .label4)
        try container.encode(arrow, forKey: .arrow)
    }
}
