Skip to content

Commit

Permalink
Merge pull request #99 from makinosp/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
makinosp authored Nov 11, 2024
2 parents c9b0a05 + 933fcae commit 25b6873
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github: makinosp
patreon: makinosp
ko_fi: makinosp
liberapay: makinon
3 changes: 3 additions & 0 deletions Sources/VRCKit/Models/Favorite/FavoriteListModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// Created by makinosp on 2024/10/06.
//

import MemberwiseInit

@MemberwiseInit(.public)
public struct FavoriteList: Sendable, Identifiable {
public let id: String
public let favorites: [Favorite]
Expand Down
13 changes: 12 additions & 1 deletion Sources/VRCKit/Models/World/InstanceModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public struct Instance: Sendable, Identifiable, Hashable, Decodable {
public let userCount: Int
public let world: World

@MemberwiseInit(.public)
public struct Platforms: Sendable, Hashable, Codable {
@Init(default: 0) public let android: Int
@Init(default: 0) public let ios: Int
Expand Down Expand Up @@ -93,6 +92,18 @@ public extension Instance {
}
}

public extension Instance.Platforms {
/// Initialize from an array of UserPlatform
/// - Parameter platforms: An array of UserPlatform
init(_ platforms: [UserPlatform]) {
self.init(
android: platforms.contains(.android) ? 1 : 0,
ios: platforms.contains(.ios) ? 1 : 0,
standalonewindows: platforms.contains(.standalonewindows) ? 1 : 0
)
}
}

extension Instance.GroupAccessType {
var typeDescription: Instance.InstanceTypeAlias {
switch self {
Expand Down
8 changes: 4 additions & 4 deletions Sources/VRCKit/Protocols/AuthenticationServiceProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public protocol AuthenticationServiceProtocol: Sendable {
/// - Returns: A boolean indicating if the user exists.
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,
/// - Throws: An error if the request fails or if the response cannot be decoded. If an unexpected decoding issue occurs,
/// it throws `VRCKitError.unexpected`.
/// Fetches the authenticated user's information or determines if 2FA verification is required.
/// - Returns: An `Either<User, VerifyType>` result.
/// - 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>

/// Verifies 2-factor authentication using either TOTP or Email OTP.
Expand Down
3 changes: 2 additions & 1 deletion Sources/VRCKit/Protocols/ImageUrlRepresentableProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public protocol ImageUrlRepresentable: Sendable {
///
/// - Parameters:
/// - url: The original image URL to modify.
/// - resolution: The desired image resolution as an `ImageResolution` value. The original resolution is `.origin`.
/// - resolution: The desired image resolution as an `ImageResolution` value.
/// The original resolution is `.origin`.
///
/// - Returns: A new URL with the last numeric component replaced by the specified resolution.
func imageUrl(_ resolution: ImageResolution) -> URL?
Expand Down
2 changes: 1 addition & 1 deletion Sources/VRCKit/Services/AuthenticationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public final actor AuthenticationService: APIService, AuthenticationServiceProto
} catch _ as DecodingError {
let result: RequiresTwoFactorAuthResponse = try Serializer.shared.decode(response.data)
guard let requires = result.requires else {
throw VRCKitError.invalidResponse("\(result.requires?.rawValue)")
throw VRCKitError.invalidResponse(String(describing: result.requires?.rawValue))
}
return .right(requires)
}
Expand Down

0 comments on commit 25b6873

Please sign in to comment.