You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
PadelClubData/PadelClubData/Data/Gen/BaseMatch.swift

169 lines
6.7 KiB

// Generated by SwiftModelGenerator
// Do not modify this file manually
import Foundation
import LeStorage
import SwiftUI
@Observable
public class BaseMatch: SyncedModelObject, SyncedStorable {
public static func resourceName() -> String { return "matches" }
public static func tokenExemptedMethods() -> [HTTPMethod] { return [] }
public static var copyServerResponse: Bool = false
public var id: String = Store.randomId()
public var round: String? = nil
public var groupStage: String? = nil
public var startDate: Date? = nil {
didSet {
self.didSetStartDate()
}
}
public var endDate: Date? = nil
public var index: Int = 0
public var format: MatchFormat? = nil
public var servingTeamId: String? = nil
public var winningTeamId: String? = nil
public var losingTeamId: String? = nil
public var name: String? = nil
public var disabled: Bool = false
public var courtIndex: Int? = nil
public var confirmed: Bool = false
public var plannedStartDate: Date? = nil
public init(
id: String = Store.randomId(),
round: String? = nil,
groupStage: String? = nil,
startDate: Date? = nil,
endDate: Date? = nil,
index: Int = 0,
format: MatchFormat? = nil,
servingTeamId: String? = nil,
winningTeamId: String? = nil,
losingTeamId: String? = nil,
name: String? = nil,
disabled: Bool = false,
courtIndex: Int? = nil,
confirmed: Bool = false,
plannedStartDate: Date? = nil
) {
super.init()
self.id = id
self.round = round
self.groupStage = groupStage
self.startDate = startDate
self.endDate = endDate
self.index = index
self.format = format
self.servingTeamId = servingTeamId
self.winningTeamId = winningTeamId
self.losingTeamId = losingTeamId
self.name = name
self.disabled = disabled
self.courtIndex = courtIndex
self.confirmed = confirmed
self.plannedStartDate = plannedStartDate
}
required public override init() {
super.init()
}
public func didSetStartDate() {}
public enum CodingKeys: String, CodingKey {
case _id = "id"
case _round = "round"
case _groupStage = "groupStage"
case _startDate = "startDate"
case _endDate = "endDate"
case _index = "index"
case _format = "format"
case _servingTeamId = "servingTeamId"
case _winningTeamId = "winningTeamId"
case _losingTeamId = "losingTeamId"
case _name = "name"
case _disabled = "disabled"
case _courtIndex = "courtIndex"
case _confirmed = "confirmed"
case _plannedStartDate = "plannedStartDate"
}
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.round = try container.decodeIfPresent(String.self, forKey: ._round) ?? nil
self.groupStage = try container.decodeIfPresent(String.self, forKey: ._groupStage) ?? nil
self.startDate = try container.decodeIfPresent(Date.self, forKey: ._startDate) ?? nil
self.endDate = try container.decodeIfPresent(Date.self, forKey: ._endDate) ?? nil
self.index = try container.decodeIfPresent(Int.self, forKey: ._index) ?? 0
self.format = try container.decodeIfPresent(MatchFormat.self, forKey: ._format) ?? nil
self.servingTeamId = try container.decodeIfPresent(String.self, forKey: ._servingTeamId) ?? nil
self.winningTeamId = try container.decodeIfPresent(String.self, forKey: ._winningTeamId) ?? nil
self.losingTeamId = try container.decodeIfPresent(String.self, forKey: ._losingTeamId) ?? nil
self.name = try container.decodeIfPresent(String.self, forKey: ._name) ?? nil
self.disabled = try container.decodeIfPresent(Bool.self, forKey: ._disabled) ?? false
self.courtIndex = try container.decodeIfPresent(Int.self, forKey: ._courtIndex) ?? nil
self.confirmed = try container.decodeIfPresent(Bool.self, forKey: ._confirmed) ?? false
self.plannedStartDate = try container.decodeIfPresent(Date.self, forKey: ._plannedStartDate) ?? nil
try super.init(from: decoder)
}
public 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.round, forKey: ._round)
try container.encode(self.groupStage, forKey: ._groupStage)
try container.encode(self.startDate, forKey: ._startDate)
try container.encode(self.endDate, forKey: ._endDate)
try container.encode(self.index, forKey: ._index)
try container.encode(self.format, forKey: ._format)
try container.encode(self.servingTeamId, forKey: ._servingTeamId)
try container.encode(self.winningTeamId, forKey: ._winningTeamId)
try container.encode(self.losingTeamId, forKey: ._losingTeamId)
try container.encode(self.name, forKey: ._name)
try container.encode(self.disabled, forKey: ._disabled)
try container.encode(self.courtIndex, forKey: ._courtIndex)
try container.encode(self.confirmed, forKey: ._confirmed)
try container.encode(self.plannedStartDate, forKey: ._plannedStartDate)
try super.encode(to: encoder)
}
func roundValue() -> Round? {
guard let round = self.round else { return nil }
return self.store?.findById(round)
}
func groupStageValue() -> GroupStage? {
guard let groupStage = self.groupStage else { return nil }
return self.store?.findById(groupStage)
}
public func copy(from other: any Storable) {
guard let match = other as? BaseMatch else { return }
self.id = match.id
self.round = match.round
self.groupStage = match.groupStage
self.startDate = match.startDate
self.endDate = match.endDate
self.index = match.index
self.format = match.format
self.servingTeamId = match.servingTeamId
self.winningTeamId = match.winningTeamId
self.losingTeamId = match.losingTeamId
self.name = match.name
self.disabled = match.disabled
self.courtIndex = match.courtIndex
self.confirmed = match.confirmed
self.plannedStartDate = match.plannedStartDate
}
public static func relationships() -> [Relationship] {
return [
Relationship(type: Round.self, keyPath: \BaseMatch.round),
Relationship(type: GroupStage.self, keyPath: \BaseMatch.groupStage),
]
}
}