Campus
public enum Campus
Helper type for accessing a list of all building complexes.
-
Fetch all building complexes.
Declaration
Swift
public static func fetch(session: URLSession = .shared, rawDataHandler: ((Data) -> Void)? = nil, completion: @escaping (Result<[BuildingComplex]>) -> Void)Parameters
sessionsession to use, defaults to
.sharedrawDataHandlerreceives the raw data before being parsed
completionhandler
-
Fetch all building complexes if the current data hash differs from the given one.
Warning
Completion handler is only called on error or if newer data was found.Declaration
Swift
public static func fetch(ifNewerThanHash oldHash: String, session: URLSession = .shared, rawDataHandler: ((Data) -> Void)? = nil, completion: @escaping (Result<[BuildingComplex]>) -> Void)Parameters
oldHashgiven data hash
sessionsession to use, defaults to
.sharedrawDataHandlerreceives the raw data before being parsed
completionhandler
-
Decode a list of
BuildingComplex‘es from given data. This takes the data returned bym/json_gebaeude/all, which is the same asCampus.fetch(). Use this to provide initial data to be used if an internet connection is not present for the first start or if persisting the API responses directly.Throws
any errors occurring during JSON decodingDeclaration
Swift
public static func readFromLocal(data: Data) throws -> [BuildingComplex]Parameters
dataAPI response as data
Return Value
decoded API response
Campus Enum Reference