|
|
|
|
@ -10,7 +10,7 @@ import PadelClubData |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: - FederalTournament |
|
|
|
|
struct FederalTournament: Identifiable, Codable { |
|
|
|
|
struct FederalTournament: Identifiable, Codable, Hashable { |
|
|
|
|
|
|
|
|
|
func getEvent() -> Event { |
|
|
|
|
let club = DataStore.shared.user.clubsObjects().first(where: { $0.code == codeClub }) |
|
|
|
|
@ -313,7 +313,7 @@ extension FederalTournament: FederalTournamentHolder { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MARK: - CategorieAge |
|
|
|
|
struct CategorieAge: Codable { |
|
|
|
|
struct CategorieAge: Codable, Hashable { |
|
|
|
|
var ageJoueurMin, ageMin, ageJoueurMax, ageRechercheMax: Int? |
|
|
|
|
var categoriesAgeTypePratique: [CategoriesAgeTypePratique]? |
|
|
|
|
var ageMax: Int? |
|
|
|
|
@ -335,18 +335,18 @@ struct CategorieAge: Codable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MARK: - CategoriesAgeTypePratique |
|
|
|
|
struct CategoriesAgeTypePratique: Codable { |
|
|
|
|
struct CategoriesAgeTypePratique: Codable, Hashable { |
|
|
|
|
var id: ID? |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MARK: - ID |
|
|
|
|
struct ID: Codable { |
|
|
|
|
struct ID: Codable, Hashable { |
|
|
|
|
var typePratique: String? |
|
|
|
|
var idCategorieAge: Int? |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MARK: - CategorieTournoi |
|
|
|
|
struct CategorieTournoi: Codable { |
|
|
|
|
struct CategorieTournoi: Codable, Hashable { |
|
|
|
|
var code, codeTaxe: String? |
|
|
|
|
var compteurGda: CompteurGda? |
|
|
|
|
var libelle, niveauHierarchique: String? |
|
|
|
|
@ -354,14 +354,14 @@ struct CategorieTournoi: Codable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MARK: - CompteurGda |
|
|
|
|
struct CompteurGda: Codable { |
|
|
|
|
struct CompteurGda: Codable, Hashable { |
|
|
|
|
var classementMax: Classement? |
|
|
|
|
var libelle: String? |
|
|
|
|
var classementMin: Classement? |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MARK: - Classement |
|
|
|
|
struct Classement: Codable { |
|
|
|
|
struct Classement: Codable, Hashable { |
|
|
|
|
var nature, libelle: String? |
|
|
|
|
var serie: Serie? |
|
|
|
|
var sexe: String? |
|
|
|
|
@ -371,7 +371,7 @@ struct Classement: Codable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MARK: - Serie |
|
|
|
|
struct Serie: Codable { |
|
|
|
|
struct Serie: Codable, Hashable { |
|
|
|
|
var code, libelle: String? |
|
|
|
|
var valide: Bool? |
|
|
|
|
var sexe: String? |
|
|
|
|
@ -382,7 +382,7 @@ struct Serie: Codable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MARK: - Epreuve |
|
|
|
|
struct Epreuve: Codable { |
|
|
|
|
struct Epreuve: Codable, Hashable { |
|
|
|
|
var inscriptionEnLigneEnCours: Bool? |
|
|
|
|
var categorieAge: CategorieAge? |
|
|
|
|
var typeEpreuve: TypeEpreuve? |
|
|
|
|
@ -419,7 +419,7 @@ struct Epreuve: Codable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MARK: - TypeEpreuve |
|
|
|
|
struct TypeEpreuve: Codable { |
|
|
|
|
struct TypeEpreuve: Codable, Hashable { |
|
|
|
|
let code: String? |
|
|
|
|
let delai: Int? |
|
|
|
|
let libelle: String? |
|
|
|
|
@ -437,12 +437,12 @@ struct TypeEpreuve: Codable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MARK: - BorneAnneesNaissance |
|
|
|
|
struct BorneAnneesNaissance: Codable { |
|
|
|
|
struct BorneAnneesNaissance: Codable, Hashable { |
|
|
|
|
var min, max: Int? |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MARK: - Installation |
|
|
|
|
struct Installation: Codable { |
|
|
|
|
struct Installation: Codable, Hashable { |
|
|
|
|
var ville: String? |
|
|
|
|
var lng: Double? |
|
|
|
|
var surfaces: [JSONAny]? |
|
|
|
|
@ -457,7 +457,7 @@ struct Installation: Codable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MARK: - JugeArbitre |
|
|
|
|
struct JugeArbitre: Codable { |
|
|
|
|
struct JugeArbitre: Codable, Hashable { |
|
|
|
|
var idCRM, id: Int? |
|
|
|
|
var nom, prenom: String? |
|
|
|
|
|
|
|
|
|
@ -468,7 +468,7 @@ struct JugeArbitre: Codable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MARK: - ModeleDeBalle |
|
|
|
|
struct ModeleDeBalle: Codable { |
|
|
|
|
struct ModeleDeBalle: Codable, Hashable { |
|
|
|
|
var libelle: String? |
|
|
|
|
var marqueDeBalle: MarqueDeBalle? |
|
|
|
|
var id: Int? |
|
|
|
|
@ -476,7 +476,7 @@ struct ModeleDeBalle: Codable { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MARK: - MarqueDeBalle |
|
|
|
|
struct MarqueDeBalle: Codable { |
|
|
|
|
struct MarqueDeBalle: Codable, Hashable { |
|
|
|
|
var id: Int? |
|
|
|
|
var valide: Bool? |
|
|
|
|
var marque: String? |
|
|
|
|
@ -529,9 +529,13 @@ class JSONCodingKey: CodingKey { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class JSONAny: Codable { |
|
|
|
|
class JSONAny: Codable, Hashable, Equatable { |
|
|
|
|
|
|
|
|
|
let value: Any |
|
|
|
|
var value: Any |
|
|
|
|
|
|
|
|
|
init() { |
|
|
|
|
self.value = () |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static func decodingError(forCodingPath codingPath: [CodingKey]) -> DecodingError { |
|
|
|
|
let context = DecodingError.Context(codingPath: codingPath, debugDescription: "Cannot decode JSONAny") |
|
|
|
|
@ -722,4 +726,70 @@ class JSONAny: Codable { |
|
|
|
|
try JSONAny.encode(to: &container, value: self.value) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static func == (lhs: JSONAny, rhs: JSONAny) -> Bool { |
|
|
|
|
switch (lhs.value, rhs.value) { |
|
|
|
|
case (let l as Bool, let r as Bool): return l == r |
|
|
|
|
case (let l as Int64, let r as Int64): return l == r |
|
|
|
|
case (let l as Double, let r as Double): return l == r |
|
|
|
|
case (let l as String, let r as String): return l == r |
|
|
|
|
case (let l as JSONNull, let r as JSONNull): return true |
|
|
|
|
case (let l as [Any], let r as [Any]): |
|
|
|
|
guard l.count == r.count else { return false } |
|
|
|
|
return zip(l, r).allSatisfy { (a, b) in |
|
|
|
|
// Recursively wrap in JSONAny for comparison |
|
|
|
|
JSONAny(value: a) == JSONAny(value: b) |
|
|
|
|
} |
|
|
|
|
case (let l as [String: Any], let r as [String: Any]): |
|
|
|
|
guard l.count == r.count else { return false } |
|
|
|
|
for (key, lVal) in l { |
|
|
|
|
guard let rVal = r[key], JSONAny(value: lVal) == JSONAny(value: rVal) else { return false } |
|
|
|
|
} |
|
|
|
|
return true |
|
|
|
|
default: |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public func hash(into hasher: inout Hasher) { |
|
|
|
|
switch value { |
|
|
|
|
case let v as Bool: |
|
|
|
|
hasher.combine(0) |
|
|
|
|
hasher.combine(v) |
|
|
|
|
case let v as Int64: |
|
|
|
|
hasher.combine(1) |
|
|
|
|
hasher.combine(v) |
|
|
|
|
case let v as Double: |
|
|
|
|
hasher.combine(2) |
|
|
|
|
hasher.combine(v) |
|
|
|
|
case let v as String: |
|
|
|
|
hasher.combine(3) |
|
|
|
|
hasher.combine(v) |
|
|
|
|
case is JSONNull: |
|
|
|
|
hasher.combine(4) |
|
|
|
|
case let v as [Any]: |
|
|
|
|
hasher.combine(5) |
|
|
|
|
for elem in v { |
|
|
|
|
JSONAny(value: elem).hash(into: &hasher) |
|
|
|
|
} |
|
|
|
|
case let v as [String: Any]: |
|
|
|
|
hasher.combine(6) |
|
|
|
|
// Order of hashing dictionary keys shouldn't matter |
|
|
|
|
for key in v.keys.sorted() { |
|
|
|
|
hasher.combine(key) |
|
|
|
|
if let val = v[key] { |
|
|
|
|
JSONAny(value: val).hash(into: &hasher) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
default: |
|
|
|
|
hasher.combine(-1) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Helper init for internal use |
|
|
|
|
convenience init(value: Any) { |
|
|
|
|
self.init() |
|
|
|
|
self.value = value |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|