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.
 
 
PadelClub/PadelClub/Data/Gen/BaseEvent.swift

95 lines
3.3 KiB

// Generated by SwiftModelGenerator
// Do not modify this file manually
import Foundation
import LeStorage
import SwiftUI
@Observable
class BaseEvent: ModelObject, SyncedStorable, Codable {
static func resourceName() -> String { return "events" }
static func tokenExemptedMethods() -> [HTTPMethod] { return [] }
static func filterByStoreIdentifier() -> Bool { return false }
var id: String = Store.randomId()
var lastUpdate: Date = Date()
var creator: String? = nil
var club: String? = nil
var creationDate: Date = Date()
var name: String? = nil
var tenupId: String? = nil
init(
id: String = Store.randomId(),
lastUpdate: Date = Date(),
creator: String? = nil,
club: String? = nil,
creationDate: Date = Date(),
name: String? = nil,
tenupId: String? = nil
) {
super.init()
self.id = id
self.lastUpdate = lastUpdate
self.creator = creator
self.club = club
self.creationDate = creationDate
self.name = name
self.tenupId = tenupId
}
enum CodingKeys: String, CodingKey {
case _id = "id"
case _lastUpdate = "lastUpdate"
case _creator = "creator"
case _club = "club"
case _creationDate = "creationDate"
case _name = "name"
case _tenupId = "tenupId"
}
required init(from decoder: Decoder) throws {
super.init()
let container = try decoder.container(keyedBy: CodingKeys.self)
self.id = try container.decodeIfPresent(String.self, forKey: ._id) ?? Store.randomId()
self.lastUpdate = try container.decodeIfPresent(Date.self, forKey: ._lastUpdate) ?? Date()
self.creator = try container.decodeIfPresent(String.self, forKey: ._creator) ?? nil
self.club = try container.decodeIfPresent(String.self, forKey: ._club) ?? nil
self.creationDate = try container.decodeIfPresent(Date.self, forKey: ._creationDate) ?? Date()
self.name = try container.decodeIfPresent(String.self, forKey: ._name) ?? nil
self.tenupId = try container.decodeIfPresent(String.self, forKey: ._tenupId) ?? nil
}
func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(self.id, forKey: ._id)
try container.encode(self.lastUpdate, forKey: ._lastUpdate)
try container.encode(self.creator, forKey: ._creator)
try container.encode(self.club, forKey: ._club)
try container.encode(self.creationDate, forKey: ._creationDate)
try container.encode(self.name, forKey: ._name)
try container.encode(self.tenupId, forKey: ._tenupId)
}
func creatorValue() -> CustomUser? {
guard let creator = self.creator else { return nil }
return Store.main.findById(creator)
}
func clubValue() -> Club? {
guard let club = self.club else { return nil }
return Store.main.findById(club)
}
func copy(from other: any Storable) {
guard let event = other as? BaseEvent else { return }
self.id = event.id
self.lastUpdate = event.lastUpdate
self.creator = event.creator
self.club = event.club
self.creationDate = event.creationDate
self.name = event.name
self.tenupId = event.tenupId
}
}