ViewModel was changed and searchbar is working now. You can text your group and find your schedule
This commit is contained in:
@ -12,8 +12,11 @@ final class NetworkManager {
|
||||
//MARK: Properties
|
||||
static let shared = NetworkManager()
|
||||
private let decoder = JSONDecoder()
|
||||
private let urlForGroup = "https://webictis.sfedu.ru/schedule-api/?query=ктбо2-6"
|
||||
private let urlForGroup = "https://webictis.sfedu.ru/schedule-api/?query="
|
||||
private let urlForWeek = "https://webictis.sfedu.ru/schedule-api/?group=51.html&week=15"
|
||||
private var groupString: String = ""
|
||||
private var numOfGroup: String = ""
|
||||
private var numOfWeek: String = ""
|
||||
|
||||
//MARK: Initializer
|
||||
private init() {
|
||||
@ -21,8 +24,13 @@ final class NetworkManager {
|
||||
}
|
||||
|
||||
//MARK: Methods
|
||||
func getSchedule() async throws -> Schedule {
|
||||
guard let url = URL(string: urlForGroup) else { throw NetworkError.invalidUrl}
|
||||
func makeURL(_ group: String) -> String {
|
||||
return urlForGroup + group
|
||||
}
|
||||
|
||||
func getSchedule(_ group: String) async throws -> Schedule {
|
||||
let newUrlForGroup = makeURL(group)
|
||||
guard let url = URL(string: newUrlForGroup) else {throw NetworkError.invalidUrl}
|
||||
let (data, response) = try await URLSession.shared.data(from: url)
|
||||
guard let response = response as? HTTPURLResponse, response.statusCode == 200 else {throw NetworkError.invalidResponse}
|
||||
|
||||
|
Reference in New Issue
Block a user