19 lines
569 B
Swift
19 lines
569 B
Swift
import Foundation
|
|
|
|
struct VideoCatalogResponse: Decodable {
|
|
let videos: [TrainingVideoSummary]
|
|
}
|
|
|
|
enum VideoCatalogAPI {
|
|
static func fetch() async throws -> (videos: [TrainingVideoSummary], baseURL: String) {
|
|
let result = try await HTTPClient.getJSON(
|
|
VideoCatalogResponse.self,
|
|
baseURL: AppConfig.serverBaseURL,
|
|
path: "api/v1/videos",
|
|
timeout: AppConfig.readTimeout
|
|
)
|
|
let ready = result.value.videos.filter { $0.status == "ready" }
|
|
return (ready, result.effectiveBaseURL)
|
|
}
|
|
}
|