diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index c3a3dd3..dc6fd3f 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -1919,7 +1919,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 13; + CURRENT_PROJECT_VERSION = 14; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; @@ -1957,7 +1957,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 13; + CURRENT_PROJECT_VERSION = 14; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; diff --git a/PadelClub/Data/AppSettings.swift b/PadelClub/Data/AppSettings.swift index 60828c1..da30d59 100644 --- a/PadelClub/Data/AppSettings.swift +++ b/PadelClub/Data/AppSettings.swift @@ -14,41 +14,11 @@ class AppSettings: MicroStorable { var lastDataSource: String? = nil - var callMessageBody : String? = nil - var callMessageSignature: String? = nil - var callDisplayFormat: Bool = false - var callDisplayEntryFee: Bool = false - var callUseFullCustomMessage: Bool = false - var matchFormatsDefaultDuration: [MatchFormat: Int]? = nil - var bracketMatchFormatPreference: MatchFormat? - var groupStageMatchFormatPreference: MatchFormat? - var loserBracketMatchFormatPreference: MatchFormat? - //bracket naming preference (index or alphabetical) - required init() { } - - func saveMatchFormatsDefaultDuration(_ matchFormat: MatchFormat, estimatedDuration: Int) { - if estimatedDuration == matchFormat.defaultEstimatedDuration { - matchFormatsDefaultDuration?.removeValue(forKey: matchFormat) - } else { - matchFormatsDefaultDuration = matchFormatsDefaultDuration ?? [MatchFormat: Int]() - matchFormatsDefaultDuration?[matchFormat] = estimatedDuration - } - } - + enum CodingKeys: String, CodingKey { case _lastDataSource = "lastDataSource" - case _callMessageBody = "callMessageBody" - case _callMessageSignature = "summonsMessageSignature" - case _callDisplayFormat = "callDisplayFormat" - case _callDisplayEntryFee = "callDisplayEntryFee" - case _callUseFullCustomMessage = "callUseFullCustomMessage" - case _matchFormatsDefaultDuration = "matchFormatsDefaultDuration" - case _bracketMatchFormatPreference = "bracketMatchFormatPreference" - case _groupStageMatchFormatPreference = "groupStageMatchFormatPreference" - case _loserBracketMatchFormatPreference = "loserBracketMatchFormatPreference" - } } diff --git a/PadelClub/Data/Club.swift b/PadelClub/Data/Club.swift index 52d33f8..9a5117b 100644 --- a/PadelClub/Data/Club.swift +++ b/PadelClub/Data/Club.swift @@ -86,6 +86,66 @@ class Club : ModelObject, Storable, Hashable { case _longitude = "longitude" case _courtCount = "courtCount" } + + func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: ._id) + + if let creator = creator { + try container.encode(creator, forKey: ._creator) + } else { + try container.encodeNil(forKey: ._creator) + } + + try container.encode(name, forKey: ._name) + try container.encode(acronym, forKey: ._acronym) + + if let phone = phone { + try container.encode(phone, forKey: ._phone) + } else { + try container.encodeNil(forKey: ._phone) + } + + if let code = code { + try container.encode(code, forKey: ._code) + } else { + try container.encodeNil(forKey: ._code) + } + + if let address = address { + try container.encode(address, forKey: ._address) + } else { + try container.encodeNil(forKey: ._address) + } + + if let city = city { + try container.encode(city, forKey: ._city) + } else { + try container.encodeNil(forKey: ._city) + } + + if let zipCode = zipCode { + try container.encode(zipCode, forKey: ._zipCode) + } else { + try container.encodeNil(forKey: ._zipCode) + } + + if let latitude = latitude { + try container.encode(latitude, forKey: ._latitude) + } else { + try container.encodeNil(forKey: ._latitude) + } + + if let longitude = longitude { + try container.encode(longitude, forKey: ._longitude) + } else { + try container.encodeNil(forKey: ._longitude) + } + + try container.encode(courtCount, forKey: ._courtCount) + } + } extension Club { diff --git a/PadelClub/Data/Court.swift b/PadelClub/Data/Court.swift index 39bf025..e68e50c 100644 --- a/PadelClub/Data/Court.swift +++ b/PadelClub/Data/Court.swift @@ -70,4 +70,22 @@ class Court : ModelObject, Storable, Hashable { case _exitAllowed = "exitAllowed" case _indoor = "indoor" } + + func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: ._id) + try container.encode(index, forKey: ._index) + try container.encode(club, forKey: ._club) + + if let name = name { + try container.encode(name, forKey: ._name) + } else { + try container.encodeNil(forKey: ._name) + } + + try container.encode(exitAllowed, forKey: ._exitAllowed) + try container.encode(indoor, forKey: ._indoor) + } + } diff --git a/PadelClub/Data/Event.swift b/PadelClub/Data/Event.swift index fd419d3..f28945d 100644 --- a/PadelClub/Data/Event.swift +++ b/PadelClub/Data/Event.swift @@ -101,4 +101,37 @@ extension Event { // case _roundFormat = "roundFormat" // case _loserRoundFormat = "loserRoundFormat" } + + func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: ._id) + + if let creator = creator { + try container.encode(creator, forKey: ._creator) + } else { + try container.encodeNil(forKey: ._creator) + } + + if let club = club { + try container.encode(club, forKey: ._club) + } else { + try container.encodeNil(forKey: ._club) + } + + try container.encode(creationDate, forKey: ._creationDate) + + if let name = name { + try container.encode(name, forKey: ._name) + } else { + try container.encodeNil(forKey: ._name) + } + + if let tenupId = tenupId { + try container.encode(tenupId, forKey: ._tenupId) + } else { + try container.encodeNil(forKey: ._tenupId) + } + } + } diff --git a/PadelClub/Data/GroupStage.swift b/PadelClub/Data/GroupStage.swift index 0998547..7be2fdb 100644 --- a/PadelClub/Data/GroupStage.swift +++ b/PadelClub/Data/GroupStage.swift @@ -303,6 +303,34 @@ class GroupStage: ModelObject, Storable { override func deleteDependencies() throws { try Store.main.deleteDependencies(items: self._matches()) } + + func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: ._id) + try container.encode(tournament, forKey: ._tournament) + try container.encode(index, forKey: ._index) + try container.encode(size, forKey: ._size) + + if let format = format { + try container.encode(format, forKey: ._format) + } else { + try container.encodeNil(forKey: ._format) + } + + if let startDate = startDate { + try container.encode(startDate, forKey: ._startDate) + } else { + try container.encodeNil(forKey: ._startDate) + } + + if let name = name { + try container.encode(name, forKey: ._name) + } else { + try container.encodeNil(forKey: ._name) + } + } + } extension GroupStage { diff --git a/PadelClub/Data/Match.swift b/PadelClub/Data/Match.swift index 5738e59..bb10814 100644 --- a/PadelClub/Data/Match.swift +++ b/PadelClub/Data/Match.swift @@ -718,6 +718,77 @@ class Match: ModelObject, Storable { // case _order = "order" case _disabled = "disabled" } + + func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: ._id) + + if let round = round { + try container.encode(round, forKey: ._round) + } else { + try container.encodeNil(forKey: ._round) + } + + if let groupStage = groupStage { + try container.encode(groupStage, forKey: ._groupStage) + } else { + try container.encodeNil(forKey: ._groupStage) + } + + if let startDate = startDate { + try container.encode(startDate, forKey: ._startDate) + } else { + try container.encodeNil(forKey: ._startDate) + } + + if let endDate = endDate { + try container.encode(endDate, forKey: ._endDate) + } else { + try container.encodeNil(forKey: ._endDate) + } + + try container.encode(index, forKey: ._index) + + if let format = format { + try container.encode(format, forKey: ._format) + } else { + try container.encodeNil(forKey: ._format) + } + + if let servingTeamId = servingTeamId { + try container.encode(servingTeamId, forKey: ._servingTeamId) + } else { + try container.encodeNil(forKey: ._servingTeamId) + } + + if let winningTeamId = winningTeamId { + try container.encode(winningTeamId, forKey: ._winningTeamId) + } else { + try container.encodeNil(forKey: ._winningTeamId) + } + + if let losingTeamId = losingTeamId { + try container.encode(losingTeamId, forKey: ._losingTeamId) + } else { + try container.encodeNil(forKey: ._losingTeamId) + } + + if let name = name { + try container.encode(name, forKey: ._name) + } else { + try container.encodeNil(forKey: ._name) + } + + try container.encode(disabled, forKey: ._disabled) + + if let courtIndex = courtIndex { + try container.encode(courtIndex, forKey: ._courtIndex) + } else { + try container.encodeNil(forKey: ._courtIndex) + } + } + } enum MatchDateSetup: Hashable, Identifiable { diff --git a/PadelClub/Data/PlayerRegistration.swift b/PadelClub/Data/PlayerRegistration.swift index 0fabc2c..19f2722 100644 --- a/PadelClub/Data/PlayerRegistration.swift +++ b/PadelClub/Data/PlayerRegistration.swift @@ -296,6 +296,103 @@ class PlayerRegistration: ModelObject, Storable { } + func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: ._id) + + if let teamRegistration = teamRegistration { + try container.encode(teamRegistration, forKey: ._teamRegistration) + } else { + try container.encodeNil(forKey: ._teamRegistration) + } + + try container.encode(firstName, forKey: ._firstName) + try container.encode(lastName, forKey: ._lastName) + + if let licenceId = licenceId { + try container.encode(licenceId, forKey: ._licenceId) + } else { + try container.encodeNil(forKey: ._licenceId) + } + + if let rank = rank { + try container.encode(rank, forKey: ._rank) + } else { + try container.encodeNil(forKey: ._rank) + } + + if let paymentType = paymentType { + try container.encode(paymentType, forKey: ._paymentType) + } else { + try container.encodeNil(forKey: ._paymentType) + } + + if let sex = sex { + try container.encode(sex, forKey: ._sex) + } else { + try container.encodeNil(forKey: ._sex) + } + + if let tournamentPlayed = tournamentPlayed { + try container.encode(tournamentPlayed, forKey: ._tournamentPlayed) + } else { + try container.encodeNil(forKey: ._tournamentPlayed) + } + + if let points = points { + try container.encode(points, forKey: ._points) + } else { + try container.encodeNil(forKey: ._points) + } + + if let clubName = clubName { + try container.encode(clubName, forKey: ._clubName) + } else { + try container.encodeNil(forKey: ._clubName) + } + + if let ligueName = ligueName { + try container.encode(ligueName, forKey: ._ligueName) + } else { + try container.encodeNil(forKey: ._ligueName) + } + + if let assimilation = assimilation { + try container.encode(assimilation, forKey: ._assimilation) + } else { + try container.encodeNil(forKey: ._assimilation) + } + + if let phoneNumber = phoneNumber { + try container.encode(phoneNumber, forKey: ._phoneNumber) + } else { + try container.encodeNil(forKey: ._phoneNumber) + } + + if let email = email { + try container.encode(email, forKey: ._email) + } else { + try container.encodeNil(forKey: ._email) + } + + if let birthdate = birthdate { + try container.encode(birthdate, forKey: ._birthdate) + } else { + try container.encodeNil(forKey: ._birthdate) + } + + try container.encode(computedRank, forKey: ._computedRank) + + if let source = source { + try container.encode(source, forKey: ._source) + } else { + try container.encodeNil(forKey: ._source) + } + + try container.encode(hasArrived, forKey: ._hasArrived) + } + enum PlayerDataSource: Int, Codable { case frenchFederation = 0 case beachPadel = 1 diff --git a/PadelClub/Data/Round.swift b/PadelClub/Data/Round.swift index 8b9da7a..9eeadda 100644 --- a/PadelClub/Data/Round.swift +++ b/PadelClub/Data/Round.swift @@ -483,6 +483,33 @@ class Round: ModelObject, Storable { case _format = "format" case _startDate = "startDate" } + + func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: ._id) + try container.encode(tournament, forKey: ._tournament) + try container.encode(index, forKey: ._index) + + if let parent = parent { + try container.encode(parent, forKey: ._parent) + } else { + try container.encodeNil(forKey: ._parent) + } + + if let format = format { + try container.encode(format, forKey: ._format) + } else { + try container.encodeNil(forKey: ._format) + } + + if let startDate = startDate { + try container.encode(startDate, forKey: ._startDate) + } else { + try container.encodeNil(forKey: ._startDate) + } + } + } extension Round: Selectable { diff --git a/PadelClub/Data/TeamRegistration.swift b/PadelClub/Data/TeamRegistration.swift index 4f22611..bf3ecf6 100644 --- a/PadelClub/Data/TeamRegistration.swift +++ b/PadelClub/Data/TeamRegistration.swift @@ -355,6 +355,92 @@ class TeamRegistration: ModelObject, Storable { case _qualified = "qualified" } + func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: ._id) + try container.encode(tournament, forKey: ._tournament) + + if let groupStage = groupStage { + try container.encode(groupStage, forKey: ._groupStage) + } else { + try container.encodeNil(forKey: ._groupStage) + } + + if let registrationDate = registrationDate { + try container.encode(registrationDate, forKey: ._registrationDate) + } else { + try container.encodeNil(forKey: ._registrationDate) + } + + if let callDate = callDate { + try container.encode(callDate, forKey: ._callDate) + } else { + try container.encodeNil(forKey: ._callDate) + } + + if let bracketPosition = bracketPosition { + try container.encode(bracketPosition, forKey: ._bracketPosition) + } else { + try container.encodeNil(forKey: ._bracketPosition) + } + + if let groupStagePosition = groupStagePosition { + try container.encode(groupStagePosition, forKey: ._groupStagePosition) + } else { + try container.encodeNil(forKey: ._groupStagePosition) + } + + if let comment = comment { + try container.encode(comment, forKey: ._comment) + } else { + try container.encodeNil(forKey: ._comment) + } + + if let source = source { + try container.encode(source, forKey: ._source) + } else { + try container.encodeNil(forKey: ._source) + } + + if let sourceValue = sourceValue { + try container.encode(sourceValue, forKey: ._sourceValue) + } else { + try container.encodeNil(forKey: ._sourceValue) + } + + if let logo = logo { + try container.encode(logo, forKey: ._logo) + } else { + try container.encodeNil(forKey: ._logo) + } + + if let name = name { + try container.encode(name, forKey: ._name) + } else { + try container.encodeNil(forKey: ._name) + } + + try container.encode(walkOut, forKey: ._walkOut) + try container.encode(wildCardBracket, forKey: ._wildCardBracket) + try container.encode(wildCardGroupStage, forKey: ._wildCardGroupStage) + try container.encode(weight, forKey: ._weight) + + if let lockedWeight = lockedWeight { + try container.encode(lockedWeight, forKey: ._lockedWeight) + } else { + try container.encodeNil(forKey: ._lockedWeight) + } + + if let confirmationDate = confirmationDate { + try container.encode(confirmationDate, forKey: ._confirmationDate) + } else { + try container.encodeNil(forKey: ._confirmationDate) + } + + try container.encode(qualified, forKey: ._qualified) + } + } extension TeamRegistration: Hashable { diff --git a/PadelClub/Data/TeamScore.swift b/PadelClub/Data/TeamScore.swift index bba788f..ed2217d 100644 --- a/PadelClub/Data/TeamScore.swift +++ b/PadelClub/Data/TeamScore.swift @@ -67,4 +67,37 @@ class TeamScore: ModelObject, Storable { case _luckyLoser = "luckyLoser" } + func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: ._id) + try container.encode(match, forKey: ._match) + + if let teamRegistration = teamRegistration { + try container.encode(teamRegistration, forKey: ._teamRegistration) + } else { + try container.encodeNil(forKey: ._teamRegistration) + } + + try container.encode(playerRegistrations, forKey: ._playerRegistrations) + + if let score = score { + try container.encode(score, forKey: ._score) + } else { + try container.encodeNil(forKey: ._score) + } + + if let walkOut = walkOut { + try container.encode(walkOut, forKey: ._walkOut) + } else { + try container.encodeNil(forKey: ._walkOut) + } + + if let luckyLoser = luckyLoser { + try container.encode(luckyLoser, forKey: ._luckyLoser) + } else { + try container.encodeNil(forKey: ._luckyLoser) + } + } + } diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index 27222ae..303166a 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -200,31 +200,70 @@ class Tournament : ModelObject, Storable { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(id, forKey: ._id) - try container.encodeIfPresent(event, forKey: ._event) - try container.encodeIfPresent(name, forKey: ._name) + if let event { + try container.encode(event, forKey: ._event) + } else { + try container.encodeNil(forKey: ._event) + } + if let name { + try container.encode(name, forKey: ._name) + } else { + try container.encodeNil(forKey: ._name) + } try container.encode(startDate, forKey: ._startDate) - try container.encodeIfPresent(endDate, forKey: ._endDate) + if let endDate { + try container.encode(endDate, forKey: ._endDate) + } else { + try container.encodeNil(forKey: ._endDate) + } + try container.encode(creationDate, forKey: ._creationDate) try container.encode(isPrivate, forKey: ._isPrivate) - try container.encodeIfPresent(groupStageFormat, forKey: ._groupStageFormat) - try container.encodeIfPresent(roundFormat, forKey: ._roundFormat) - try container.encodeIfPresent(loserRoundFormat, forKey: ._loserRoundFormat) + if let groupStageFormat { + try container.encode(groupStageFormat, forKey: ._groupStageFormat) + } else { + try container.encodeNil(forKey: ._groupStageFormat) + } + if let roundFormat { + try container.encode(roundFormat, forKey: ._roundFormat) + } else { + try container.encodeNil(forKey: ._roundFormat) + } + if let loserRoundFormat { + try container.encode(loserRoundFormat, forKey: ._loserRoundFormat) + } else { + try container.encodeNil(forKey: ._loserRoundFormat) + } try container.encode(groupStageSortMode, forKey: ._groupStageSortMode) try container.encode(groupStageCount, forKey: ._groupStageCount) - try container.encodeIfPresent(rankSourceDate, forKey: ._rankSourceDate) + if let rankSourceDate { + try container.encode(rankSourceDate, forKey: ._rankSourceDate) + } else { + try container.encodeNil(forKey: ._rankSourceDate) + } try container.encode(dayDuration, forKey: ._dayDuration) try container.encode(teamCount, forKey: ._teamCount) try container.encode(teamSorting, forKey: ._teamSorting) try container.encode(federalCategory, forKey: ._federalCategory) try container.encode(federalLevelCategory, forKey: ._federalLevelCategory) try container.encode(federalAgeCategory, forKey: ._federalAgeCategory) - try container.encodeIfPresent(closedRegistrationDate, forKey: ._closedRegistrationDate) + if let closedRegistrationDate { + try container.encode(closedRegistrationDate, forKey: ._closedRegistrationDate) + } else { + try container.encodeNil(forKey: ._closedRegistrationDate) + } + try container.encode(groupStageAdditionalQualified, forKey: ._groupStageAdditionalQualified) try container.encode(courtCount, forKey: ._courtCount) try container.encode(prioritizeClubMembers, forKey: ._prioritizeClubMembers) try container.encode(qualifiedPerGroupStage, forKey: ._qualifiedPerGroupStage) try container.encode(teamsPerGroupStage, forKey: ._teamsPerGroupStage) - try container.encodeIfPresent(entryFee, forKey: ._entryFee) + if let entryFee { + try container.encode(entryFee, forKey: ._entryFee) + } else { + try container.encodeNil(forKey: ._entryFee) + } + try self._encodePayment(container: &container) try container.encode(additionalEstimationDuration, forKey: ._additionalEstimationDuration) try container.encode(isDeleted, forKey: ._isDeleted) diff --git a/PadelClub/Data/User.swift b/PadelClub/Data/User.swift index cf79f18..dde81c2 100644 --- a/PadelClub/Data/User.swift +++ b/PadelClub/Data/User.swift @@ -122,6 +122,88 @@ class User: ModelObject, UserBase, Storable { } + func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + + try container.encode(id, forKey: ._id) + try container.encode(username, forKey: ._username) + try container.encode(email, forKey: ._email) + try container.encode(clubs, forKey: ._clubs) + + if let umpireCode = umpireCode { + try container.encode(umpireCode, forKey: ._umpireCode) + } else { + try container.encodeNil(forKey: ._umpireCode) + } + + if let licenceId = licenceId { + try container.encode(licenceId, forKey: ._licenceId) + } else { + try container.encodeNil(forKey: ._licenceId) + } + + try container.encode(firstName, forKey: ._firstName) + try container.encode(lastName, forKey: ._lastName) + + if let phone = phone { + try container.encode(phone, forKey: ._phone) + } else { + try container.encodeNil(forKey: ._phone) + } + + if let country = country { + try container.encode(country, forKey: ._country) + } else { + try container.encodeNil(forKey: ._country) + } + + if let summonsMessageBody = summonsMessageBody { + try container.encode(summonsMessageBody, forKey: ._summonsMessageBody) + } else { + try container.encodeNil(forKey: ._summonsMessageBody) + } + + if let summonsMessageSignature = summonsMessageSignature { + try container.encode(summonsMessageSignature, forKey: ._summonsMessageSignature) + } else { + try container.encodeNil(forKey: ._summonsMessageSignature) + } + + if let summonsAvailablePaymentMethods = summonsAvailablePaymentMethods { + try container.encode(summonsAvailablePaymentMethods, forKey: ._summonsAvailablePaymentMethods) + } else { + try container.encodeNil(forKey: ._summonsAvailablePaymentMethods) + } + + try container.encode(summonsDisplayFormat, forKey: ._summonsDisplayFormat) + try container.encode(summonsDisplayEntryFee, forKey: ._summonsDisplayEntryFee) + try container.encode(summonsUseFullCustomMessage, forKey: ._summonsUseFullCustomMessage) + + if let matchFormatsDefaultDuration = matchFormatsDefaultDuration { + try container.encode(matchFormatsDefaultDuration, forKey: ._matchFormatsDefaultDuration) + } else { + try container.encodeNil(forKey: ._matchFormatsDefaultDuration) + } + + if let bracketMatchFormatPreference = bracketMatchFormatPreference { + try container.encode(bracketMatchFormatPreference, forKey: ._bracketMatchFormatPreference) + } else { + try container.encodeNil(forKey: ._bracketMatchFormatPreference) + } + + if let groupStageMatchFormatPreference = groupStageMatchFormatPreference { + try container.encode(groupStageMatchFormatPreference, forKey: ._groupStageMatchFormatPreference) + } else { + try container.encodeNil(forKey: ._groupStageMatchFormatPreference) + } + + if let loserBracketMatchFormatPreference = loserBracketMatchFormatPreference { + try container.encode(loserBracketMatchFormatPreference, forKey: ._loserBracketMatchFormatPreference) + } else { + try container.encodeNil(forKey: ._loserBracketMatchFormatPreference) + } + } + static func placeHolder() -> User { return User(username: "", email: "", firstName: "", lastName: "", phone: nil, country: nil) }