import Foundation

struct TwoFactorModel: Codable {
    
    let api_status : Int?
    let timezone : String?
    let access_token : String?
    let user_id : String?
    
    enum CodingKeys: String, CodingKey {
        case api_status = "api_status"
        case timezone = "timezone"
        case access_token = "access_token"
        case user_id = "user_id"
    }
    
    init(from decoder: Decoder) throws {
        let values = try decoder.container(keyedBy: CodingKeys.self)
        api_status = try values.decodeIfPresent(Int.self, forKey: .api_status)
        timezone = try values.decodeIfPresent(String.self, forKey: .timezone)
        access_token = try values.decodeIfPresent(String.self, forKey: .access_token)
        user_id = try values.decodeIfPresent(String.self, forKey: .user_id)
    }
    
    func getStringAnyData() -> [String: Any] {
        do {
            let encoder = JSONEncoder()
            let data = try encoder.encode(self)
            
            // Decode the Data into a [String: Any] dictionary using JSONSerialization
            if let dictionary = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
                // Now, 'dictionary' contains the model data as a dictionary
                print(dictionary)
                return dictionary
            }
        } catch {
            print("Error encoding/decoding the model: \(error)")
        }
        return ["": ""]
    }
    
}

struct UpdateTwoFactorModel: Codable {
    
    var apiStatus: Int?
    var message: String?
    
    enum CodingKeys: String, CodingKey {
        case apiStatus = "api_status"
        case message
    }
    
}
