//
//  ConsoleEntry.swift
//  Zockerhoehle
//
//  Created by Julian-Steffen Müller on 17.09.18.
//  Copyright © 2018 Julian-Steffen Müller. All rights reserved.
//

import Foundation

class ConsoleEntry : FlockeEntry {
    var generation : Int? {
        get {
            return self.content["Generation"] as? Int
        }
    }
    
    var manufacturer : String? {
        get {
            return self.content["Manufacturer"] as? String
        }
    }
    
    override init(entry: FlockeEntry) {
        super.init(entry: entry)
    }
    
    required init(from decoder: Decoder) throws {
        try super.init(from: decoder)
    }
    
    override func encodeContent(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy:  CodingKeys.self)
        
        var contentContainer = container.nestedContainer(keyedBy: CodingKeysContentConsoleEntry.self, forKey: CodingKeys.content)
        try contentContainer.encode(self.generation, forKey: CodingKeysContentConsoleEntry.Generation)
        try contentContainer.encode(self.manufacturer, forKey: CodingKeysContentConsoleEntry.Manufacturer)
    }
    
    enum CodingKeysContentConsoleEntry : String, CodingKey {
        case Generation  = "Generation"
        case Manufacturer
    }
}
