|
| 1 | +// |
| 2 | +// UserModel+Encodable.swift |
| 3 | +// VRCKit |
| 4 | +// |
| 5 | +// Created by makinosp on 2024/10/27. |
| 6 | +// |
| 7 | + |
| 8 | +import Foundation |
| 9 | + |
| 10 | +extension User: Encodable { |
| 11 | + public func encode(to encoder: any Encoder) throws { |
| 12 | + var container = encoder.container(keyedBy: UserCodingKeys.self) |
| 13 | + try container.encode(activeFriends, forKey: .activeFriends) |
| 14 | + try container.encode(allowAvatarCopying, forKey: .allowAvatarCopying) |
| 15 | + try container.encodeIfPresent(bio, forKey: .bio) |
| 16 | + try container.encode(bioLinks.wrappedValue, forKey: .bioLinks) |
| 17 | + try container.encode(currentAvatar, forKey: .currentAvatar) |
| 18 | + try container.encodeIfPresent(avatarImageUrl, forKey: .currentAvatarImageUrl) |
| 19 | + try container.encodeIfPresent(avatarThumbnailUrl, forKey: .currentAvatarThumbnailImageUrl) |
| 20 | + if let dateJoined = dateJoined { |
| 21 | + let dateJoinedString = DateFormatter.dateStringFormat.string(from: dateJoined) |
| 22 | + try container.encode(dateJoinedString, forKey: .dateJoined) |
| 23 | + } |
| 24 | + try container.encode(displayName, forKey: .displayName) |
| 25 | + try container.encode(friendKey, forKey: .friendKey) |
| 26 | + try container.encode(friends, forKey: .friends) |
| 27 | + try container.encode(homeLocation, forKey: .homeLocation) |
| 28 | + try container.encode(id, forKey: .id) |
| 29 | + try container.encode(isFriend, forKey: .isFriend) |
| 30 | + try container.encode(lastActivity, forKey: .lastActivity) |
| 31 | + try container.encode(lastLogin, forKey: .lastLogin) |
| 32 | + try container.encode(lastPlatform, forKey: .lastPlatform) |
| 33 | + try container.encode(offlineFriends, forKey: .offlineFriends) |
| 34 | + try container.encode(onlineFriends, forKey: .onlineFriends) |
| 35 | + try container.encode(pastDisplayNames, forKey: .pastDisplayNames) |
| 36 | + try container.encodeIfPresent(profilePicOverride, forKey: .profilePicOverride) |
| 37 | + try container.encode(state, forKey: .state) |
| 38 | + try container.encode(status, forKey: .status) |
| 39 | + try container.encode(statusDescription, forKey: .statusDescription) |
| 40 | + try container.encode(tags, forKey: .tags) |
| 41 | + try container.encode(twoFactorAuthEnabled, forKey: .twoFactorAuthEnabled) |
| 42 | + try container.encodeIfPresent(userIcon, forKey: .userIcon) |
| 43 | + try container.encodeIfPresent(userLanguage, forKey: .userLanguage) |
| 44 | + try container.encodeIfPresent(userLanguageCode, forKey: .userLanguageCode) |
| 45 | + try container.encode(presence, forKey: .presence) |
| 46 | + } |
| 47 | +} |
0 commit comments