Commit
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
//
|
||||
// NetworkError.swift
|
||||
// NewsApp
|
||||
// Schedule ICTIS
|
||||
//
|
||||
// Created by Mironov Egor on 18.11.2024.
|
||||
//
|
||||
|
@ -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}
|
||||
|
||||
|
Reference in New Issue
Block a user