//
//  PenguinModel.swift
//  Runner
//
//  Created by Amir  on 06/08/2024.
//

import Foundation

// Define the model class
struct PenguinModel {
    let baseURL: String
    let dataURL: String
    let dataServiceName: String
    let positionURL: String
    let clientKey: String
    let storyboardName: String
    let mapBoxKey: String
    let clientID: String
    let positionServiceName: String
    let username: String
    let isSimulationModeEnabled: Bool
    let isShowUserName: Bool
    let isUpdateUserLocationSmoothly: Bool
    let isEnableReportIssue: Bool
    let languageCode: String
    let clinicID: String
    let patientID: String
    let projectID: Int

    // Initialize the model from a dictionary
    init?(from dictionary: [String: Any]) {
    
        guard
            let baseURL = dictionary["baseURL"] as? String,
            let dataURL = dictionary["dataURL"] as? String,
            let dataServiceName = dictionary["dataServiceName"] as? String,
            let positionURL = dictionary["positionURL"] as? String,
            let clientKey = dictionary["clientKey"] as? String,
            let storyboardName = dictionary["storyboardName"] as? String,
            let mapBoxKey = dictionary["mapBoxKey"] as? String,
            let clientID = dictionary["clientID"] as? String,
            let positionServiceName = dictionary["positionServiceName"] as? String,
            let username = dictionary["username"] as? String,
            let isSimulationModeEnabled = dictionary["isSimulationModeEnabled"] as? Bool,
            let isShowUserName = dictionary["isShowUserName"] as? Bool,
            let isUpdateUserLocationSmoothly = dictionary["isUpdateUserLocationSmoothly"] as? Bool,
            let isEnableReportIssue = dictionary["isEnableReportIssue"] as? Bool,
            let languageCode = dictionary["languageCode"] as? String,
            let clinicID = dictionary["clinicID"] as? String,
            let patientID = dictionary["patientID"] as? String,
            let projectID = dictionary["projectID"] as? Int
        else {
            print("Initialization failed due to missing or invalid keys.")
            return nil
        }

        self.baseURL = baseURL
        self.dataURL = dataURL
        self.dataServiceName = dataServiceName
        self.positionURL = positionURL
        self.clientKey = clientKey
        self.storyboardName = storyboardName
        self.mapBoxKey = mapBoxKey
        self.clientID = clientID
        self.positionServiceName = positionServiceName
        self.username = username
        self.isSimulationModeEnabled = isSimulationModeEnabled
        self.isShowUserName = isShowUserName
        self.isUpdateUserLocationSmoothly = isUpdateUserLocationSmoothly
        self.isEnableReportIssue = isEnableReportIssue
        self.languageCode = languageCode
        self.clinicID = clinicID
        self.patientID = patientID
        self.projectID = projectID
    }
}
