|
7 | 7 |
|
8 | 8 | import Foundation
|
9 | 9 |
|
10 |
| -public struct User: Codable, ProfileDetailRepresentable { |
| 10 | +public struct User: ProfileDetailRepresentable { |
11 | 11 | public let activeFriends: [String]
|
12 | 12 | public let allowAvatarCopying: Bool
|
13 | 13 | public let bio: String?
|
14 |
| - @NullableArray public var bioLinks: [URL] |
| 14 | + public var bioLinks: [String] |
15 | 15 | public let currentAvatar: String
|
16 | 16 | public let currentAvatarAssetUrl: String
|
17 | 17 | public let currentAvatarImageUrl: String?
|
@@ -54,6 +54,45 @@ public struct User: Codable, ProfileDetailRepresentable {
|
54 | 54 | }
|
55 | 55 | }
|
56 | 56 |
|
| 57 | +extension User: Codable { |
| 58 | + public init(from decoder: any Decoder) throws { |
| 59 | + let container = try decoder.container(keyedBy: CodingKeys.self) |
| 60 | + self.activeFriends = try container.decode([String].self, forKey: .activeFriends) |
| 61 | + self.allowAvatarCopying = try container.decode(Bool.self, forKey: .allowAvatarCopying) |
| 62 | + self.bio = try container.decodeIfPresent(String.self, forKey: .bio) |
| 63 | + self.bioLinks = try container.decodeIfPresent([String].self, forKey: .bioLinks) ?? [] |
| 64 | + self.currentAvatar = try container.decode(String.self, forKey: .currentAvatar) |
| 65 | + self.currentAvatarAssetUrl = try container.decode(String.self, forKey: .currentAvatarAssetUrl) |
| 66 | + self.currentAvatarImageUrl = try container.decodeIfPresent(String.self, forKey: .currentAvatarImageUrl) |
| 67 | + self.currentAvatarThumbnailImageUrl = try container.decodeIfPresent( |
| 68 | + String.self, |
| 69 | + forKey: .currentAvatarThumbnailImageUrl |
| 70 | + ) |
| 71 | + self.dateJoined = try container.decode(String.self, forKey: .dateJoined) |
| 72 | + self.displayName = try container.decode(String.self, forKey: .displayName) |
| 73 | + self.friendKey = try container.decode(String.self, forKey: .friendKey) |
| 74 | + self.friends = try container.decode([String].self, forKey: .friends) |
| 75 | + self.homeLocation = try container.decode(String.self, forKey: .homeLocation) |
| 76 | + self.id = try container.decode(String.self, forKey: .id) |
| 77 | + self.isFriend = try container.decode(Bool.self, forKey: .isFriend) |
| 78 | + self.lastActivity = try container.decode(Date.self, forKey: .lastActivity) |
| 79 | + self.lastLogin = try container.decode(Date.self, forKey: .lastLogin) |
| 80 | + self.lastPlatform = try container.decode(String.self, forKey: .lastPlatform) |
| 81 | + self.offlineFriends = try container.decode([String].self, forKey: .offlineFriends) |
| 82 | + self.onlineFriends = try container.decode([String].self, forKey: .onlineFriends) |
| 83 | + self.pastDisplayNames = try container.decode([User.DisplayName].self, forKey: .pastDisplayNames) |
| 84 | + self.profilePicOverride = try container.decodeIfPresent(String.self, forKey: .profilePicOverride) |
| 85 | + self.state = try container.decode(User.State.self, forKey: .state) |
| 86 | + self.status = try container.decode(UserStatus.self, forKey: .status) |
| 87 | + self.statusDescription = try container.decode(String.self, forKey: .statusDescription) |
| 88 | + self.tags = try container.decode([Tag].self, forKey: .tags) |
| 89 | + self.twoFactorAuthEnabled = try container.decode(Bool.self, forKey: .twoFactorAuthEnabled) |
| 90 | + self.userIcon = try container.decodeIfPresent(String.self, forKey: .userIcon) |
| 91 | + self.userLanguage = try container.decodeIfPresent(String.self, forKey: .userLanguage) |
| 92 | + self.userLanguageCode = try container.decodeIfPresent(String.self, forKey: .userLanguageCode) |
| 93 | + } |
| 94 | +} |
| 95 | + |
57 | 96 | public struct UpdatedUser: Codable {
|
58 | 97 | public let bio: String?
|
59 | 98 | public let statusDescription: String?
|
|
0 commit comments