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

151 lines
5.9 KiB

// Generated by LeStorageGenerator
// Do not modify this file manually
import Foundation
import LeStorage
import SwiftUI
@Observable
public class BaseClub: SyncedModelObject, SyncedStorable {
public static func resourceName() -> String { return "clubs" }
public static func tokenExemptedMethods() -> [HTTPMethod] { return [] }
public static var copyServerResponse: Bool = true
public static func storeParent() -> Bool { return false }
public var id: String = Store.randomId()
public var creator: String? = nil
public var name: String = ""
public var acronym: String = ""
public var phone: String? = nil
public var code: String? = nil
public var address: String? = nil
public var city: String? = nil
public var zipCode: String? = nil
public var latitude: Double? = nil
public var longitude: Double? = nil
public var courtCount: Int = 2
public var broadcastCode: String? = nil
public var timezone: String? = TimeZone.current.identifier
public init(
id: String = Store.randomId(),
creator: String? = nil,
name: String = "",
acronym: String = "",
phone: String? = nil,
code: String? = nil,
address: String? = nil,
city: String? = nil,
zipCode: String? = nil,
latitude: Double? = nil,
longitude: Double? = nil,
courtCount: Int = 2,
broadcastCode: String? = nil,
timezone: String? = TimeZone.current.identifier
) {
super.init()
self.id = id
self.creator = creator
self.name = name
self.acronym = acronym
self.phone = phone
self.code = code
self.address = address
self.city = city
self.zipCode = zipCode
self.latitude = latitude
self.longitude = longitude
self.courtCount = courtCount
self.broadcastCode = broadcastCode
self.timezone = timezone
}
required public override init() {
super.init()
}
public enum CodingKeys: String, CodingKey {
case _id = "id"
case _creator = "creator"
case _name = "name"
case _acronym = "acronym"
case _phone = "phone"
case _code = "code"
case _address = "address"
case _city = "city"
case _zipCode = "zipCode"
case _latitude = "latitude"
case _longitude = "longitude"
case _courtCount = "courtCount"
case _broadcastCode = "broadcastCode"
case _timezone = "timezone"
}
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.creator = try container.decodeIfPresent(String.self, forKey: ._creator) ?? nil
self.name = try container.decodeIfPresent(String.self, forKey: ._name) ?? ""
self.acronym = try container.decodeIfPresent(String.self, forKey: ._acronym) ?? ""
self.phone = try container.decodeIfPresent(String.self, forKey: ._phone) ?? nil
self.code = try container.decodeIfPresent(String.self, forKey: ._code) ?? nil
self.address = try container.decodeIfPresent(String.self, forKey: ._address) ?? nil
self.city = try container.decodeIfPresent(String.self, forKey: ._city) ?? nil
self.zipCode = try container.decodeIfPresent(String.self, forKey: ._zipCode) ?? nil
self.latitude = try container.decodeIfPresent(Double.self, forKey: ._latitude) ?? nil
self.longitude = try container.decodeIfPresent(Double.self, forKey: ._longitude) ?? nil
self.courtCount = try container.decodeIfPresent(Int.self, forKey: ._courtCount) ?? 2
self.broadcastCode = try container.decodeIfPresent(String.self, forKey: ._broadcastCode) ?? nil
self.timezone = try container.decodeIfPresent(String.self, forKey: ._timezone) ?? TimeZone.current.identifier
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.creator, forKey: ._creator)
try container.encode(self.name, forKey: ._name)
try container.encode(self.acronym, forKey: ._acronym)
try container.encode(self.phone, forKey: ._phone)
try container.encode(self.code, forKey: ._code)
try container.encode(self.address, forKey: ._address)
try container.encode(self.city, forKey: ._city)
try container.encode(self.zipCode, forKey: ._zipCode)
try container.encode(self.latitude, forKey: ._latitude)
try container.encode(self.longitude, forKey: ._longitude)
try container.encode(self.courtCount, forKey: ._courtCount)
try container.encode(self.broadcastCode, forKey: ._broadcastCode)
try container.encode(self.timezone, forKey: ._timezone)
try super.encode(to: encoder)
}
func creatorValue() -> CustomUser? {
guard let creator = self.creator else { return nil }
return self.store?.findById(creator)
}
public func copy(from other: any Storable) {
guard let club = other as? BaseClub else { return }
self.id = club.id
self.creator = club.creator
self.name = club.name
self.acronym = club.acronym
self.phone = club.phone
self.code = club.code
self.address = club.address
self.city = club.city
self.zipCode = club.zipCode
self.latitude = club.latitude
self.longitude = club.longitude
self.courtCount = club.courtCount
self.broadcastCode = club.broadcastCode
self.timezone = club.timezone
}
public static func relationships() -> [Relationship] {
return [
Relationship(type: CustomUser.self, keyPath: \BaseClub.creator, mainStoreLookup: false),
]
}
}