From e70760a2aab53d5586cf353dd72c2f842ae29b36 Mon Sep 17 00:00:00 2001 From: Maximilian Kraft Date: Thu, 19 Oct 2023 16:32:17 +0200 Subject: [PATCH] class model of odp realtime --- HelloWorld/ODPRealtimeModel.swift | 143 ++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 HelloWorld/ODPRealtimeModel.swift diff --git a/HelloWorld/ODPRealtimeModel.swift b/HelloWorld/ODPRealtimeModel.swift new file mode 100644 index 0000000..6df9635 --- /dev/null +++ b/HelloWorld/ODPRealtimeModel.swift @@ -0,0 +1,143 @@ +// This file was generated from JSON Schema using quicktype, do not modify it directly. +// To parse the JSON, add this file to your project and do: +// +// let welcome = try? JSONDecoder().decode(Welcome.self, from: jsonData) + +import Foundation + +// MARK: - ODPResponse +struct ODPResponse: Codable { + let data: DataClass + let message: Message +} + +// MARK: - DataClass +struct DataClass: Codable { + let monitors: [Monitor] +} + +// MARK: - Monitor +struct Monitor: Codable { + let locationStop: LocationStop + let lines: [Line] + let attributes: MonitorAttributes +} + +// MARK: - MonitorAttributes +struct MonitorAttributes: Codable { +} + +// MARK: - Line +struct Line: Codable { + let name: Name + let towards: String + let direction: Direction + let platform, richtungsID: String + let barrierFree, realtimeSupported, trafficjam: Bool + let departures: Departures + let type: TypeEnum + let lineID: Int + + enum CodingKeys: String, CodingKey { + case name, towards, direction, platform + case richtungsID = "richtungsId" + case barrierFree, realtimeSupported, trafficjam, departures, type + case lineID = "lineId" + } +} + +// MARK: - Departures +struct Departures: Codable { + let departure: [Departure] +} + +// MARK: - Departure +struct Departure: Codable { + let departureTime: DepartureTime + let vehicle: Vehicle? +} + +// MARK: - DepartureTime +struct DepartureTime: Codable { + let timePlanned: String + let timeReal: String? + let countdown: Int +} + +// MARK: - Vehicle +struct Vehicle: Codable { + let name: Name + let towards: Towards + let direction: Direction + let platform, richtungsID: String + let barrierFree: Bool + let foldingRamp: Bool? + let foldingRampType: String? + let realtimeSupported, trafficjam: Bool + let type: TypeEnum + let attributes: MonitorAttributes + let linienID: Int + + enum CodingKeys: String, CodingKey { + case name, towards, direction, platform + case richtungsID = "richtungsId" + case barrierFree, foldingRamp, foldingRampType, realtimeSupported, trafficjam, type, attributes + case linienID = "linienId" + } +} + +enum Direction: String, Codable { + case r = "R" +} + +enum Name: String, Codable { + case u4 = "U4" +} + +enum Towards: String, Codable { + case hütteldorf = "HÜTTELDORF " + case hütteldorfSU = "Hütteldorf S U" +} + +enum TypeEnum: String, Codable { + case ptMetro = "ptMetro" +} + +// MARK: - LocationStop +struct LocationStop: Codable { + let type: String + let geometry: Geometry + let properties: Properties +} + +// MARK: - Geometry +struct Geometry: Codable { + let type: String + let coordinates: [Double] +} + +// MARK: - Properties +struct Properties: Codable { + let name, title, municipality: String + let municipalityID: Int + let type, coordName, gate: String + let attributes: PropertiesAttributes + + enum CodingKeys: String, CodingKey { + case name, title, municipality + case municipalityID = "municipalityId" + case type, coordName, gate, attributes + } +} + +// MARK: - PropertiesAttributes +struct PropertiesAttributes: Codable { + let rbl: Int +} + +// MARK: - Message +struct Message: Codable { + let value: String + let messageCode: Int + let serverTime: String +} \ No newline at end of file