This repository has been archived by the owner on Jan 10, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Start to refactor the API buy generalizing all the API methods into one MainAPI enum independent of the API (TUMCabe, TUMOnline, CampusOnline, etc.), the respective data type which (i.e. Grades, Movie, StudyRoom, etc.) and independent of the decoder (XML or JSON). * Created for each API an new enum conforming to the new protocol API to be used with the newly created method makeRequest<T,S> in the enum MainAPI * Refactored Calendar to work with the Asyn-Await-Pattern, the state enum and the new API. This includes, that Calendar now shows the error screen, if the fetching failed * Refactored LecturesSearch to the new API and introduced the asnc-await-pattern with the state enum * Refactored the API for PersonSearch and added the new async-await pattern and error handling for this view. * Completely rewritten the ProfileDetailView and its ViewModel to adopt to the async-await-pattern, and the state-enum and handling errors properly * Refactoring the complete Authentication procress to work with the new API and to work with asnc-await * Refactored the ProfileViewModel, ProfileView, Model, to work with the new API, including async-await pattern and many many adjustments alongside. * Adding the empty profile image placeholder and removing the old TUMOnlineAPI/CampusOnlineAPI completely. * Renamed the ProfileView2/ProfileViewModel2 -> to ProfileView/ProfileViewModel * Refactoring the News for the API including async-await-pattern, error-handling, state-enum * Renamed the new NewsViewModel, NewsView to the old names * Extracted the new NewsScreen into a own file * Refactored the MovieView for the new API, including error-handling, async-await, and state-enum * Refactored the StudyRoomViewModel for fetching the RoomImageMapping. Adapted for the async-await-patter and enum-state * Removed the old TUMCabeAPI * Refactoring the Cafeterias to work with the new API * Refactored the MealPlanViewModel/View, to work with the new API, adding async-await pattern and error-handling * Refactored the DishLabels to work with the new API * Refactored the StudyRoomService to work with the new API for the StudyRoomApiResponse * Removed the old TUMDevAppAPI completely * Fixed the links for the TUMSexyView, when using the built in WebView. Refactored to the new API, added async-await-pattern and error-handling * Removed the EntityImporter the old AuthenticationHanlder, the defualt Session and the Entity-Protocol * Refactored the Lectures to be a struct instead of the old RowSet-Enum-Construct. This is obsolet since the TUMOnlineAPI response enum can be used for decoding * Refactored LectureDetails to work with the TUMOnlineAPI.Response instead of its own old LectureDetailsComponents * Fixing an issue for MealPlan. When next week's menu isn't ready the API throws a 404 error, but we can fetch meals for the current week. Thus, we need to be patient, i.e. no error needs to be thrown. And the this weeks menu can be shown without any error * Refactoring each view from .onAppear{Task{}} to .task{} since this can be cancled by the view (see https://stackoverflow.com/questions/68114509/what-is-the-difference-between-onappear-and-task-in-swiftui-3) * Deleted a print out and comment * Renaming the APIs to its original naming scheme. And creating files for each API and rename all temporarily created ViewModels to their original naming scheme. Fixing the problem with Cafeterias, which do not have any menus and the API is returning a 404 error. Now just a plain 'No Menus available' text shows up instead of an error message. Fixing a problem with the PersonSearch where the pIdentNr for the API was the wrong number, so the response was an error, now the API gets called with the obfuscated_id and the right results are retrieved. * Fix issue after logout via Profile sheet * Readding old if clause to fix weird bevaiour; Add comments
- Loading branch information
Showing
150 changed files
with
5,198 additions
and
2,613 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// EatAPIError.swift | ||
// Campus-iOS | ||
// | ||
// Created by David Lin on 10.02.23. | ||
// | ||
|
||
import Foundation | ||
|
||
enum EatAPIError: APIError, LocalizedError { | ||
case unknown(String) | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case message | ||
} | ||
|
||
init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
let error = try container.decode(String.self, forKey: .message) | ||
|
||
switch error { | ||
default: | ||
self = .unknown(error) | ||
} | ||
} | ||
|
||
init(message: String) { | ||
self = .unknown(message) | ||
} | ||
|
||
public var errorDescription: String? { | ||
switch self { | ||
case let .unknown(message): | ||
return "\("Unkonw error".localized): \(message)" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// MVGAPIError.swift | ||
// Campus-iOS | ||
// | ||
// Created by David Lin on 10.02.23. | ||
// | ||
|
||
import Foundation | ||
|
||
enum MVGAPIError: APIError, LocalizedError { | ||
case unknown(String) | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case message | ||
} | ||
|
||
init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
let error = try container.decode(String.self, forKey: .message) | ||
|
||
switch error { | ||
default: | ||
self = .unknown(error) | ||
} | ||
} | ||
|
||
init(message: String) { | ||
self = .unknown(message) | ||
} | ||
|
||
public var errorDescription: String? { | ||
switch self { | ||
case let .unknown(message): | ||
return "\("Unkonw error".localized): \(message)" | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
Campus-iOS/Base/Networking/APIErrors/NavigaTUMAPIError.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// NAvigaTUMAPIError.swift | ||
// Campus-iOS | ||
// | ||
// Created by David Lin on 10.04.23. | ||
// | ||
|
||
import Foundation | ||
|
||
enum NavigaTUMAPIError: APIError, LocalizedError { | ||
case unknown(String) | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case message | ||
} | ||
|
||
init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
let error = try container.decode(String.self, forKey: .message) | ||
|
||
switch error { | ||
default: | ||
self = .unknown(error) | ||
} | ||
} | ||
|
||
init(message: String) { | ||
self = .unknown(message) | ||
} | ||
|
||
public var errorDescription: String? { | ||
switch self { | ||
case let .unknown(message): | ||
return "\("Unkonw error".localized): \(message)" | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
Campus-iOS/Base/Networking/APIErrors/TUMCabeAPIError.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// TUMCabeAPIError.swift | ||
// Campus-iOS | ||
// | ||
// Created by David Lin on 10.02.23. | ||
// | ||
|
||
import Foundation | ||
|
||
enum TUMCabeAPIError: APIError, LocalizedError { | ||
case unknown(String) | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case message | ||
} | ||
|
||
init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
let error = try container.decode(String.self, forKey: .message) | ||
|
||
switch error { | ||
default: | ||
self = .unknown(error) | ||
} | ||
} | ||
|
||
init(message: String) { | ||
self = .unknown(message) | ||
} | ||
|
||
public var errorDescription: String? { | ||
switch self { | ||
case let .unknown(message): | ||
return "\("Unkonw error".localized): \(message)" | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
Campus-iOS/Base/Networking/APIErrors/TUMDevAppAPIError.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// TUMDevAppAPI.swift | ||
// Campus-iOS | ||
// | ||
// Created by David Lin on 10.02.23. | ||
// | ||
|
||
import Foundation | ||
|
||
enum TUMDevAppAPIError: APIError, LocalizedError { | ||
case unknown(String) | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case message | ||
} | ||
|
||
init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
let error = try container.decode(String.self, forKey: .message) | ||
|
||
switch error { | ||
default: | ||
self = .unknown(error) | ||
} | ||
} | ||
|
||
init(message: String) { | ||
self = .unknown(message) | ||
} | ||
|
||
public var errorDescription: String? { | ||
switch self { | ||
case let .unknown(message): | ||
return "\("Unkonw error".localized): \(message)" | ||
} | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
Campus-iOS/Base/Networking/APIErrors/TUMOnlineAPIError.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
// TUMOnlineAPIError.swift | ||
// Campus-iOS | ||
// | ||
// Created by David Lin on 10.02.23. | ||
// | ||
|
||
import Foundation | ||
|
||
enum TUMOnlineAPIError: APIError, LocalizedError { | ||
case noPermission | ||
case tokenNotConfirmed | ||
case invalidToken | ||
case unknown(String) | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case message = "message" | ||
} | ||
|
||
init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
let error = try container.decode(String.self, forKey: .message) | ||
|
||
switch error { | ||
case let str where str.contains("Keine Rechte für Funktion"): | ||
self = .noPermission | ||
case "Token ist nicht bestätigt!": | ||
self = .tokenNotConfirmed | ||
case "Token ist ungültig!": | ||
self = .invalidToken | ||
default: | ||
self = .unknown(error) | ||
} | ||
} | ||
|
||
init(message: String) { | ||
self = .unknown(message) | ||
} | ||
|
||
public var errorDescription: String? { | ||
switch self { | ||
case .noPermission: | ||
return "No Permission".localized | ||
case .tokenNotConfirmed: | ||
return "Token not confirmed".localized | ||
case .invalidToken: | ||
return "Token invalid".localized | ||
case let .unknown(message): | ||
return "\("Unkonw error".localized): \(message)" | ||
|
||
} | ||
} | ||
|
||
public var recoverySuggestion: String? { | ||
switch self { | ||
case .noPermission: | ||
return "Make sure to enable the right permissions for your token.".localized | ||
case .tokenNotConfirmed: | ||
return "Go to TUMonline and confirm your token.".localized | ||
case .invalidToken: | ||
return "Try creating a new token.".localized | ||
default: | ||
return nil | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
Campus-iOS/Base/Networking/APIErrors/TUMSexyAPIError.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// TUMSexyAPIError.swift | ||
// Campus-iOS | ||
// | ||
// Created by David Lin on 10.02.23. | ||
// | ||
|
||
import Foundation | ||
|
||
enum TUMSexyAPIError: APIError, LocalizedError { | ||
case unknown(String) | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case message | ||
} | ||
|
||
init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
let error = try container.decode(String.self, forKey: .message) | ||
|
||
switch error { | ||
default: | ||
self = .unknown(error) | ||
} | ||
} | ||
|
||
init(message: String) { | ||
self = .unknown(message) | ||
} | ||
|
||
public var errorDescription: String? { | ||
switch self { | ||
case let .unknown(message): | ||
return "\("Unkonw error".localized): \(message)" | ||
} | ||
} | ||
} |
Oops, something went wrong.