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/BaseCourt.swift

93 lines
3.0 KiB

// Generated by SwiftModelGenerator
// Do not modify this file manually
import Foundation
import LeStorage
import SwiftUI
@Observable
public class BaseCourt: SyncedModelObject, SyncedStorable {
public static func resourceName() -> String { return "courts" }
public static func tokenExemptedMethods() -> [HTTPMethod] { return [] }
public static var copyServerResponse: Bool = false
public var id: String = Store.randomId()
public var index: Int = 0
public var club: String = ""
public var name: String? = nil
public var exitAllowed: Bool = false
public var indoor: Bool = false
public init(
id: String = Store.randomId(),
index: Int = 0,
club: String = "",
name: String? = nil,
exitAllowed: Bool = false,
indoor: Bool = false
) {
super.init()
self.id = id
self.index = index
self.club = club
self.name = name
self.exitAllowed = exitAllowed
self.indoor = indoor
}
required public override init() {
super.init()
}
public enum CodingKeys: String, CodingKey {
case _id = "id"
case _index = "index"
case _club = "club"
case _name = "name"
case _exitAllowed = "exitAllowed"
case _indoor = "indoor"
}
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.index = try container.decodeIfPresent(Int.self, forKey: ._index) ?? 0
self.club = try container.decodeIfPresent(String.self, forKey: ._club) ?? ""
self.name = try container.decodeIfPresent(String.self, forKey: ._name) ?? nil
self.exitAllowed = try container.decodeIfPresent(Bool.self, forKey: ._exitAllowed) ?? false
self.indoor = try container.decodeIfPresent(Bool.self, forKey: ._indoor) ?? false
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.index, forKey: ._index)
try container.encode(self.club, forKey: ._club)
try container.encode(self.name, forKey: ._name)
try container.encode(self.exitAllowed, forKey: ._exitAllowed)
try container.encode(self.indoor, forKey: ._indoor)
try super.encode(to: encoder)
}
func clubValue() -> Club? {
return Store.main.findById(club)
}
public func copy(from other: any Storable) {
guard let court = other as? BaseCourt else { return }
self.id = court.id
self.index = court.index
self.club = court.club
self.name = court.name
self.exitAllowed = court.exitAllowed
self.indoor = court.indoor
}
public static func relationships() -> [Relationship] {
return [
Relationship(type: Club.self, keyPath: \BaseCourt.club),
]
}
}