add fixture-backed admin and ios scaffold
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import Foundation
|
||||
|
||||
struct APIEnvironment {
|
||||
let baseURL: URL
|
||||
}
|
||||
|
||||
struct HermesAPIClient {
|
||||
let environment: APIEnvironment
|
||||
let session: URLSession
|
||||
|
||||
init(environment: APIEnvironment, session: URLSession = .shared) {
|
||||
self.environment = environment
|
||||
self.session = session
|
||||
}
|
||||
|
||||
func get(path: String) async throws -> (Data, HTTPURLResponse) {
|
||||
let url = environment.baseURL.appendingPathComponent(path)
|
||||
let (data, response) = try await session.data(from: url)
|
||||
guard let httpResponse = response as? HTTPURLResponse else {
|
||||
throw URLError(.badServerResponse)
|
||||
}
|
||||
return (data, httpResponse)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user