Skip to content

Commit

Permalink
refact: update doc of WorldServiceProtocol
Browse files Browse the repository at this point in the history
  • Loading branch information
makinosp committed Nov 2, 2024
1 parent c57b936 commit b93b928
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
3 changes: 0 additions & 3 deletions Sources/VRCKit/Protocols/AuthenticationServiceProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ public protocol AuthenticationServiceProtocol: Sendable {
func exists(userId: String) async throws -> Bool

/// Fetches the authenticated user's information or determines if two-factor authentication (2FA) verification is required.
///
/// - Returns: An `Either<User, VerifyType>` result, which is `.left(User)` if the user is successfully authenticated,
/// or `.right(VerifyType)` if two-factor authentication is needed.
///
/// - Throws: An error if the request fails or if the response cannot be decoded. If an unexpected decoding issue occurs,
/// it throws `VRCKitError.unexpected`.
func loginUserInfo() async throws -> Either<User, VerifyType>
Expand Down
17 changes: 17 additions & 0 deletions Sources/VRCKit/Protocols/WorldServiceProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@
//

public protocol WorldServiceProtocol: Sendable {
/// Fetches detailed information about a specific world.
/// - Parameter worldId: The ID of the world to retrieve.
/// - Returns: A `World` object containing the details of the specified world.
/// - Throws: An error if the request fails or decoding is unsuccessful.
func fetchWorld(worldId: String) async throws -> World

/// Retrieves the list of favorited worlds.
/// - Returns: An array of `FavoriteWorld` objects representing the user's favorited worlds.
/// - Throws: An error if any request fails or decoding is unsuccessful.
func fetchFavoritedWorlds() async throws -> [FavoriteWorld]

/// Fetches a paginated list of favorited worlds.
/// This function retrieves a subset of favorited worlds based on the specified limit and offset.
/// - Parameters:
/// - n: The maximum number of worlds to retrieve in the current request.
/// - offset: The offset used to paginate the results.
/// - Returns: An array of `FavoriteWorld` objects representing a subset of favorited worlds.
/// - Throws: An error if the request fails or decoding is unsuccessful.
func fetchFavoritedWorlds(n: Int, offset: Int) async throws -> [FavoriteWorld]
}
2 changes: 1 addition & 1 deletion Sources/VRCKit/Services/WorldService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public final actor WorldService: APIService, WorldServiceProtocol {
}
}

private func fetchFavoritedWorlds(n: Int, offset: Int) async throws -> [FavoriteWorld] {
public func fetchFavoritedWorlds(n: Int, offset: Int) async throws -> [FavoriteWorld] {
let queryItems = [
URLQueryItem(name: "n", value: n.description),
URLQueryItem(name: "offset", value: offset.description)
Expand Down

0 comments on commit b93b928

Please sign in to comment.