This commit is contained in:
Vladimir Dubovik
2024-12-03 14:32:38 +03:00
parent 155a175635
commit 0410575c8d
11 changed files with 41 additions and 40 deletions

View File

@ -1,6 +1,6 @@
//
// NetworkError.swift
// NewsApp
// Schedule ICTIS
//
// Created by Mironov Egor on 18.11.2024.
//

View File

@ -1,8 +1,8 @@
//
// NetworkManager.swift
// NewsApp
// Schedule ICTIS
//
// Created by Egor Mironov on 18.11.2024.
// Created by Mironov Egor on 18.11.2024.
//
import Foundation
@ -12,7 +12,8 @@ final class NetworkManager {
//MARK: Properties
static let shared = NetworkManager()
private let decoder = JSONDecoder()
private let urlString = "https://webictis.sfedu.ru/schedule-api/?query=%D0%BA%D1%82%D0%B1%D0%BE2-6"
private let urlForGroup = "https://webictis.sfedu.ru/schedule-api/?query=ктбо2-6"
private let urlForWeek = "https://webictis.sfedu.ru/schedule-api/?group=51.html&week=15"
//MARK: Initializer
private init() {
@ -21,7 +22,7 @@ final class NetworkManager {
//MARK: Methods
func getSchedule() async throws -> Schedule {
guard let url = URL(string: urlString) else { throw NetworkError.invalidUrl}
guard let url = URL(string: urlForGroup) 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}