Skip to content

Commit

Permalink
Merge pull request #90 from makinosp/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
makinosp authored Oct 7, 2024
2 parents 511936f + a91467b commit 28121a8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
22 changes: 15 additions & 7 deletions Sources/VRCKit/Models/Favorite/FavoriteGroupModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,24 @@ public struct FavoriteGroup: Codable, Sendable, Identifiable, Hashable {
}
}

public extension FavoriteGroup {
/// Initialize by updatable values
init(source: FavoriteGroup, displayName: String, visibility: Visibility) {
self.init(
id: source.id,
displayName: displayName,
name: source.name,
ownerId: source.ownerId,
tags: source.tags,
type: source.type,
visibility: visibility
)
}
}

@MemberwiseInit
struct RequestToUpdateFavoriteGroup: Codable, Sendable {
let displayName: String?
let visibility: FavoriteGroup.Visibility?
@Init(default: []) let tags: [String]
}

@MemberwiseInit(.public)
public struct FavoriteGroupParams: Sendable {
public let type: FavoriteType
public let name: String
public let userId: String
}
4 changes: 2 additions & 2 deletions Sources/VRCKit/Protocols/FavoriteServiceProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public protocol FavoriteServiceProtocol: Sendable {
func fetchFavoriteList(favoriteGroups: [FavoriteGroup]) async throws -> [FavoriteList]
func addFavorite(type: FavoriteType, favoriteId: String, tag: String) async throws -> Favorite
func updateFavoriteGroup(
params: FavoriteGroupParams,
source: FavoriteGroup,
displayName: String,
visibility: FavoriteGroup.Visibility
) async throws -> SuccessResponse
) async throws -> FavoriteGroup
func removeFavorite(favoriteId: String) async throws -> SuccessResponse
}
8 changes: 4 additions & 4 deletions Sources/VRCKit/Services/FavoriteService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ public final actor FavoriteService: APIService, FavoriteServiceProtocol {
/// - userId: The ID of the user associated with the favorite group.
/// - displayName: The new display name to update the favorite group with.
/// - visibility: The new visibility setting for the favorite group.
/// - Returns: A `SuccessResponse` if the update is successful.
/// - Returns: A `FavoriteGroup` if the update is successful.
public func updateFavoriteGroup(
params: FavoriteGroupParams,
source: FavoriteGroup,
displayName: String,
visibility: FavoriteGroup.Visibility
) async throws -> SuccessResponse {
let pathParams = ["favorite", "groups", params.type.rawValue, params.name, params.userId]
) async throws -> FavoriteGroup {
let pathParams = ["favorite", "group", source.type.rawValue, source.name, source.ownerId]
let path = pathParams.joined(separator: "/")
let body = RequestToUpdateFavoriteGroup(displayName: displayName, visibility: visibility)
let requestData = try await Serializer.shared.encode(body)
Expand Down

0 comments on commit 28121a8

Please sign in to comment.