Skip to content

Commit

Permalink
chore: add fetch snapshot by ID (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba authored Oct 10, 2024
1 parent 6fa5aa3 commit 5af143b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Sources/Snapshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ public struct VOSnapshot {

// MARK: - Requests

public func fetch(_ id: String) async throws -> Entity {
try await withCheckedThrowingContinuation { continuation in
var request = URLRequest(url: urlForID(id))
request.httpMethod = "GET"
request.appendAuthorizationHeader(accessToken)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
handleJSONResponse(
continuation: continuation,
response: response,
data: data,
error: error,
type: Entity.self
)
}
task.resume()
}
}

public func fetchList(_ options: ListOptions) async throws -> List {
try await withCheckedThrowingContinuation { continuation in
var request = URLRequest(url: urlForList(options))
Expand Down

0 comments on commit 5af143b

Please sign in to comment.