@@ -14,17 +14,12 @@ public final actor FavoriteService: APIService, FavoriteServiceProtocol {
14
14
private let limit = 100
15
15
private let maxCount = 400
16
16
17
- /// Asynchronously retrieves a list of favorite groups from the server.
18
- /// - Returns: An array of `FavoriteGroup` objects.
19
17
public func listFavoriteGroups( ) async throws -> [ FavoriteGroup ] {
20
18
let path = " favorite/groups "
21
19
let response = try await client. request ( path: path, method: . get)
22
20
return try Serializer . shared. decode ( response. data)
23
21
}
24
22
25
- /// Lists a user's all favorites with the specified parameters.
26
- /// - Parameter type: The type of favorite (e.g., friend, world).
27
- /// - Returns: An array of `Favorite` objects.
28
23
public func listFavorites( type: FavoriteType ) async throws -> [ Favorite ] {
29
24
try await withThrowingTaskGroup ( of: [ Favorite ] . self) { taskGroup in
30
25
for offset in stride ( from: . zero, to: maxCount, by: limit) {
@@ -41,13 +36,7 @@ public final actor FavoriteService: APIService, FavoriteServiceProtocol {
41
36
}
42
37
}
43
38
44
- /// Lists a user's favorites with the specified parameters.
45
- /// - Parameters:
46
- /// - n: The number of favorites to retrieve. Default is `60``.
47
- /// - type: The type of favorite (e.g., friend, world).
48
- /// - tag: An optional tag to filter favorites.
49
- /// - Returns: An array of `Favorite` objects.
50
- private func listFavorites(
39
+ public func listFavorites(
51
40
n: Int = 100 ,
52
41
offset: Int = 0 ,
53
42
type: FavoriteType ,
@@ -66,11 +55,6 @@ public final actor FavoriteService: APIService, FavoriteServiceProtocol {
66
55
return try Serializer . shared. decode ( response. data)
67
56
}
68
57
69
- /// Fetches details of favorite groups asynchronously.
70
- /// - Parameters:
71
- /// - favoriteGroups: An array of `FavoriteGroup` objects.
72
- /// - type: The type of favorite (e.g., friend, world).
73
- /// - Returns: An array of `FavoriteDetail` objects containing detailed information about the favorite groups.
74
58
public func fetchFavoriteList( favoriteGroups: [ FavoriteGroup ] , type: FavoriteType ) async throws -> [ FavoriteList ] {
75
59
try await withThrowingTaskGroup ( of: FavoriteList . self) { taskGroup in
76
60
for favoriteGroup in favoriteGroups. filter ( { $0. type == type } ) {
@@ -88,12 +72,6 @@ public final actor FavoriteService: APIService, FavoriteServiceProtocol {
88
72
}
89
73
}
90
74
91
- /// Adds a new favorite to a specific group.
92
- /// - Parameters:
93
- /// - type: The type of favorite (e.g., friend, world).
94
- /// - favoriteId: The ID of the item to favorite.
95
- /// - tag: The tag to associate with the favorite.
96
- /// - Returns: The newly added `Favorite` object.
97
75
public func addFavorite(
98
76
type: FavoriteType ,
99
77
favoriteId: String ,
@@ -107,14 +85,6 @@ public final actor FavoriteService: APIService, FavoriteServiceProtocol {
107
85
return try Serializer . shared. decode ( response. data)
108
86
}
109
87
110
- /// Updates a favorite group with the given parameters, display name, and visibility.
111
- /// - Parameters:
112
- /// - params: A tuple containing the favorite group's details:
113
- /// - type: The type of the favorite group, defined by `FavoriteType`.
114
- /// - name: The name of the favorite group.
115
- /// - userId: The ID of the user associated with the favorite group.
116
- /// - displayName: The new display name to update the favorite group with.
117
- /// - visibility: The new visibility setting for the favorite group.
118
88
public func updateFavoriteGroup(
119
89
source: FavoriteGroup ,
120
90
displayName: String ,
@@ -127,9 +97,6 @@ public final actor FavoriteService: APIService, FavoriteServiceProtocol {
127
97
_ = try await client. request ( path: path, method: . put, body: requestData)
128
98
}
129
99
130
- /// Asynchronously remove favorite.
131
- /// - Parameter favoriteId: The ID of the favorite to remove.
132
- /// - Returns: A `SuccessResponse` objects.
133
100
public func removeFavorite( favoriteId: String ) async throws -> SuccessResponse {
134
101
let path = " favorites/ \( favoriteId) "
135
102
let response = try await client. request ( path: path, method: . delete)
0 commit comments