added ios module
This commit is contained in:
18
ios/OralTrainer/Services/VideoCatalogAPI.swift
Normal file
18
ios/OralTrainer/Services/VideoCatalogAPI.swift
Normal file
@@ -0,0 +1,18 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user