// Generated by SwiftModelGenerator
// Do not modify this file manually

import Foundation
import LeStorage
import SwiftUI

@Observable
class BaseCustomUser: SyncedModelObject, SyncedStorable {

    static func resourceName() -> String { return "users" }
    static func tokenExemptedMethods() -> [HTTPMethod] { return [.post] }

    var id: String = Store.randomId()
    var username: String = ""
    var email: String = ""
    var clubs: [String] = []
    var umpireCode: String? = nil
    var licenceId: String? = nil
    var firstName: String = ""
    var lastName: String = ""
    var phone: String? = nil
    var country: String? = nil
    var summonsMessageBody: String? = nil
    var summonsMessageSignature: String? = nil
    var summonsAvailablePaymentMethods: String? = nil
    var summonsDisplayFormat: Bool = false
    var summonsDisplayEntryFee: Bool = false
    var summonsUseFullCustomMessage: Bool = false
    var matchFormatsDefaultDuration: [MatchFormat: Int]? = nil
    var bracketMatchFormatPreference: MatchFormat? = nil
    var groupStageMatchFormatPreference: MatchFormat? = nil
    var loserBracketMatchFormatPreference: MatchFormat? = nil
    var loserBracketMode: LoserBracketMode = .automatic
    var deviceId: String? = nil
    var agents: [String] = []

    init(
        id: String = Store.randomId(),
        username: String = "",
        email: String = "",
        clubs: [String] = [],
        umpireCode: String? = nil,
        licenceId: String? = nil,
        firstName: String = "",
        lastName: String = "",
        phone: String? = nil,
        country: String? = nil,
        summonsMessageBody: String? = nil,
        summonsMessageSignature: String? = nil,
        summonsAvailablePaymentMethods: String? = nil,
        summonsDisplayFormat: Bool = false,
        summonsDisplayEntryFee: Bool = false,
        summonsUseFullCustomMessage: Bool = false,
        matchFormatsDefaultDuration: [MatchFormat: Int]? = nil,
        bracketMatchFormatPreference: MatchFormat? = nil,
        groupStageMatchFormatPreference: MatchFormat? = nil,
        loserBracketMatchFormatPreference: MatchFormat? = nil,
        loserBracketMode: LoserBracketMode = .automatic,
        deviceId: String? = nil,
        agents: [String] = []
    ) {
        super.init()
        self.id = id
        self.username = username
        self.email = email
        self.clubs = clubs
        self.umpireCode = umpireCode
        self.licenceId = licenceId
        self.firstName = firstName
        self.lastName = lastName
        self.phone = phone
        self.country = country
        self.summonsMessageBody = summonsMessageBody
        self.summonsMessageSignature = summonsMessageSignature
        self.summonsAvailablePaymentMethods = summonsAvailablePaymentMethods
        self.summonsDisplayFormat = summonsDisplayFormat
        self.summonsDisplayEntryFee = summonsDisplayEntryFee
        self.summonsUseFullCustomMessage = summonsUseFullCustomMessage
        self.matchFormatsDefaultDuration = matchFormatsDefaultDuration
        self.bracketMatchFormatPreference = bracketMatchFormatPreference
        self.groupStageMatchFormatPreference = groupStageMatchFormatPreference
        self.loserBracketMatchFormatPreference = loserBracketMatchFormatPreference
        self.loserBracketMode = loserBracketMode
        self.deviceId = deviceId
        self.agents = agents
    }
    required public override init() {
        super.init()
    }

    enum CodingKeys: String, CodingKey {
        case _id = "id"
        case _username = "username"
        case _email = "email"
        case _clubs = "clubs"
        case _umpireCode = "umpireCode"
        case _licenceId = "licenceId"
        case _firstName = "firstName"
        case _lastName = "lastName"
        case _phone = "phone"
        case _country = "country"
        case _summonsMessageBody = "summonsMessageBody"
        case _summonsMessageSignature = "summonsMessageSignature"
        case _summonsAvailablePaymentMethods = "summonsAvailablePaymentMethods"
        case _summonsDisplayFormat = "summonsDisplayFormat"
        case _summonsDisplayEntryFee = "summonsDisplayEntryFee"
        case _summonsUseFullCustomMessage = "summonsUseFullCustomMessage"
        case _matchFormatsDefaultDuration = "matchFormatsDefaultDuration"
        case _bracketMatchFormatPreference = "bracketMatchFormatPreference"
        case _groupStageMatchFormatPreference = "groupStageMatchFormatPreference"
        case _loserBracketMatchFormatPreference = "loserBracketMatchFormatPreference"
        case _loserBracketMode = "loserBracketMode"
        case _deviceId = "deviceId"
        case _agents = "agents"
    }

    required init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId()
        self.username = try container.decodeIfPresent(String.self, forKey: ._username) ?? ""
        self.email = try container.decodeIfPresent(String.self, forKey: ._email) ?? ""
        self.clubs = try container.decodeIfPresent([String].self, forKey: ._clubs) ?? []
        self.umpireCode = try container.decodeIfPresent(String.self, forKey: ._umpireCode) ?? nil
        self.licenceId = try container.decodeIfPresent(String.self, forKey: ._licenceId) ?? nil
        self.firstName = try container.decodeIfPresent(String.self, forKey: ._firstName) ?? ""
        self.lastName = try container.decodeIfPresent(String.self, forKey: ._lastName) ?? ""
        self.phone = try container.decodeIfPresent(String.self, forKey: ._phone) ?? nil
        self.country = try container.decodeIfPresent(String.self, forKey: ._country) ?? nil
        self.summonsMessageBody = try container.decodeIfPresent(String.self, forKey: ._summonsMessageBody) ?? nil
        self.summonsMessageSignature = try container.decodeIfPresent(String.self, forKey: ._summonsMessageSignature) ?? nil
        self.summonsAvailablePaymentMethods = try container.decodeIfPresent(String.self, forKey: ._summonsAvailablePaymentMethods) ?? nil
        self.summonsDisplayFormat = try container.decodeIfPresent(Bool.self, forKey: ._summonsDisplayFormat) ?? false
        self.summonsDisplayEntryFee = try container.decodeIfPresent(Bool.self, forKey: ._summonsDisplayEntryFee) ?? false
        self.summonsUseFullCustomMessage = try container.decodeIfPresent(Bool.self, forKey: ._summonsUseFullCustomMessage) ?? false
        self.matchFormatsDefaultDuration = try container.decodeIfPresent([MatchFormat: Int].self, forKey: ._matchFormatsDefaultDuration) ?? nil
        self.bracketMatchFormatPreference = try container.decodeIfPresent(MatchFormat.self, forKey: ._bracketMatchFormatPreference) ?? nil
        self.groupStageMatchFormatPreference = try container.decodeIfPresent(MatchFormat.self, forKey: ._groupStageMatchFormatPreference) ?? nil
        self.loserBracketMatchFormatPreference = try container.decodeIfPresent(MatchFormat.self, forKey: ._loserBracketMatchFormatPreference) ?? nil
        self.loserBracketMode = try container.decodeIfPresent(LoserBracketMode.self, forKey: ._loserBracketMode) ?? .automatic
        self.deviceId = try container.decodeIfPresent(String.self, forKey: ._deviceId) ?? nil
        self.agents = try container.decodeIfPresent([String].self, forKey: ._agents) ?? []
        try super.init(from: decoder)
    }

    override func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: CodingKeys.self)
        try container.encode(self.id, forKey: ._id)
        try container.encode(self.username, forKey: ._username)
        try container.encode(self.email, forKey: ._email)
        try container.encode(self.clubs, forKey: ._clubs)
        try container.encode(self.umpireCode, forKey: ._umpireCode)
        try container.encode(self.licenceId, forKey: ._licenceId)
        try container.encode(self.firstName, forKey: ._firstName)
        try container.encode(self.lastName, forKey: ._lastName)
        try container.encode(self.phone, forKey: ._phone)
        try container.encode(self.country, forKey: ._country)
        try container.encode(self.summonsMessageBody, forKey: ._summonsMessageBody)
        try container.encode(self.summonsMessageSignature, forKey: ._summonsMessageSignature)
        try container.encode(self.summonsAvailablePaymentMethods, forKey: ._summonsAvailablePaymentMethods)
        try container.encode(self.summonsDisplayFormat, forKey: ._summonsDisplayFormat)
        try container.encode(self.summonsDisplayEntryFee, forKey: ._summonsDisplayEntryFee)
        try container.encode(self.summonsUseFullCustomMessage, forKey: ._summonsUseFullCustomMessage)
        try container.encode(self.matchFormatsDefaultDuration, forKey: ._matchFormatsDefaultDuration)
        try container.encode(self.bracketMatchFormatPreference, forKey: ._bracketMatchFormatPreference)
        try container.encode(self.groupStageMatchFormatPreference, forKey: ._groupStageMatchFormatPreference)
        try container.encode(self.loserBracketMatchFormatPreference, forKey: ._loserBracketMatchFormatPreference)
        try container.encode(self.loserBracketMode, forKey: ._loserBracketMode)
        try container.encode(self.deviceId, forKey: ._deviceId)
        try container.encode(self.agents, forKey: ._agents)
        try super.encode(to: encoder)
    }

    func copy(from other: any Storable) {
        guard let customuser = other as? BaseCustomUser else { return }
        self.id = customuser.id
        self.username = customuser.username
        self.email = customuser.email
        self.clubs = customuser.clubs
        self.umpireCode = customuser.umpireCode
        self.licenceId = customuser.licenceId
        self.firstName = customuser.firstName
        self.lastName = customuser.lastName
        self.phone = customuser.phone
        self.country = customuser.country
        self.summonsMessageBody = customuser.summonsMessageBody
        self.summonsMessageSignature = customuser.summonsMessageSignature
        self.summonsAvailablePaymentMethods = customuser.summonsAvailablePaymentMethods
        self.summonsDisplayFormat = customuser.summonsDisplayFormat
        self.summonsDisplayEntryFee = customuser.summonsDisplayEntryFee
        self.summonsUseFullCustomMessage = customuser.summonsUseFullCustomMessage
        self.matchFormatsDefaultDuration = customuser.matchFormatsDefaultDuration
        self.bracketMatchFormatPreference = customuser.bracketMatchFormatPreference
        self.groupStageMatchFormatPreference = customuser.groupStageMatchFormatPreference
        self.loserBracketMatchFormatPreference = customuser.loserBracketMatchFormatPreference
        self.loserBracketMode = customuser.loserBracketMode
        self.deviceId = customuser.deviceId
        self.agents = customuser.agents
    }

    static func relationships() -> [Relationship] {
        return []
    }

}