//
//  LKFErrorDef.swift
//  LKF
//
//  Created by Alexander Holzer on 27.03.23.
//  Copyright © 2023 Alexander Holzer. All rights reserved.
//

import Foundation

public class LKFErrorDef {

    public let code : String
    public let facility: String
    public let severity: String
    public let fonds: String
    public let nfonds: String
    public let addInfo: String
    public let text: String
    public let value: String
    
    init? (line: String) {
        
        let parts = line.components(separatedBy: ";")
        guard parts.count >= 8 else {
            return nil
        }
        
        self.code = parts[0].trimmingCharacters(in: .whitespaces)
        self.facility = parts[1].trimmingCharacters(in: .whitespaces)
        self.severity = parts[2].trimmingCharacters(in: .whitespaces)
        self.fonds = parts[3].trimmingCharacters(in: .whitespaces)
        self.nfonds = parts[4].trimmingCharacters(in: .whitespaces)
        self.addInfo = parts[5].trimmingCharacters(in: .whitespaces)
        self.text = parts[6].trimmingCharacters(in: .whitespaces)
        self.value = parts[7].trimmingCharacters(in: .whitespaces)
    }
}
