From a9cfcc79d8f2993a4e032c8a4237044027fcc4a5 Mon Sep 17 00:00:00 2001 From: Peter Date: Tue, 5 Jun 2018 20:08:19 +0300 Subject: [PATCH] no message --- TelegramCore.xcodeproj/project.pbxproj | 8 + TelegramCore/AccessSecureId.swift | 71 +- TelegramCore/Account.swift | 30 +- TelegramCore/Api0.swift | 246 ++- TelegramCore/Api1.swift | 1967 +++++++++++++++-- TelegramCore/Api2.swift | 759 +++---- TelegramCore/Api3.swift | 509 ++++- TelegramCore/ContactManagement.swift | 14 +- TelegramCore/Crypto.h | 22 + TelegramCore/Crypto.m | 78 + .../DeserializeFunctionResponse.swift | 4 + TelegramCore/MD5.swift | 11 +- TelegramCore/MultipartUpload.swift | 14 +- .../PendingMessageUploadedContent.swift | 14 +- TelegramCore/Serialization.swift | 82 +- TelegramCore/TelegramCoreIncludes.h | 2 +- 16 files changed, 3076 insertions(+), 755 deletions(-) create mode 100644 TelegramCore/Crypto.h create mode 100644 TelegramCore/Crypto.m diff --git a/TelegramCore.xcodeproj/project.pbxproj b/TelegramCore.xcodeproj/project.pbxproj index 1177f2f143..93b37cffd9 100644 --- a/TelegramCore.xcodeproj/project.pbxproj +++ b/TelegramCore.xcodeproj/project.pbxproj @@ -147,6 +147,8 @@ D02395D71F8D09A50070F5C2 /* ChannelHistoryAvailabilitySettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = D02395D51F8D09A50070F5C2 /* ChannelHistoryAvailabilitySettings.swift */; }; D026099E20C695AF006C34AC /* Wallpapers.swift in Sources */ = {isa = PBXBuildFile; fileRef = D026099D20C695AF006C34AC /* Wallpapers.swift */; }; D026099F20C695AF006C34AC /* Wallpapers.swift in Sources */ = {isa = PBXBuildFile; fileRef = D026099D20C695AF006C34AC /* Wallpapers.swift */; }; + D02609BF20C6EC08006C34AC /* Crypto.m in Sources */ = {isa = PBXBuildFile; fileRef = D02609BE20C6EC08006C34AC /* Crypto.m */; }; + D02609C020C6EC08006C34AC /* Crypto.m in Sources */ = {isa = PBXBuildFile; fileRef = D02609BE20C6EC08006C34AC /* Crypto.m */; }; D02ABC7B1E30058F00CAE539 /* DeleteMessagesInteractively.swift in Sources */ = {isa = PBXBuildFile; fileRef = D02ABC7A1E30058F00CAE539 /* DeleteMessagesInteractively.swift */; }; D02ABC7C1E30058F00CAE539 /* DeleteMessagesInteractively.swift in Sources */ = {isa = PBXBuildFile; fileRef = D02ABC7A1E30058F00CAE539 /* DeleteMessagesInteractively.swift */; }; D02ABC7E1E3109F000CAE539 /* CloudChatRemoveMessagesOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D02ABC7D1E3109F000CAE539 /* CloudChatRemoveMessagesOperation.swift */; }; @@ -788,6 +790,8 @@ D0223A9A1EA5654D00211D94 /* TelegramMediaResource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TelegramMediaResource.swift; sourceTree = ""; }; D02395D51F8D09A50070F5C2 /* ChannelHistoryAvailabilitySettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelHistoryAvailabilitySettings.swift; sourceTree = ""; }; D026099D20C695AF006C34AC /* Wallpapers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Wallpapers.swift; sourceTree = ""; }; + D02609BB20C6EB97006C34AC /* Crypto.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Crypto.h; sourceTree = ""; }; + D02609BE20C6EC08006C34AC /* Crypto.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Crypto.m; sourceTree = ""; }; D02ABC7A1E30058F00CAE539 /* DeleteMessagesInteractively.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeleteMessagesInteractively.swift; sourceTree = ""; }; D02ABC7D1E3109F000CAE539 /* CloudChatRemoveMessagesOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CloudChatRemoveMessagesOperation.swift; sourceTree = ""; }; D02ABC801E310E5D00CAE539 /* ManagedCloudChatRemoveMessagesOperations.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ManagedCloudChatRemoveMessagesOperations.swift; sourceTree = ""; }; @@ -1527,6 +1531,8 @@ D03B0E421D631E6600955575 /* NetworkLogging.m */, D053B3F91F1651FA00E2D58A /* MonotonicTime.h */, D053B3FA1F1651FA00E2D58A /* MonotonicTime.m */, + D02609BB20C6EB97006C34AC /* Crypto.h */, + D02609BE20C6EC08006C34AC /* Crypto.m */, ); name = "Supporting Files"; sourceTree = ""; @@ -2287,6 +2293,7 @@ D018EE052045E95000CBB130 /* CheckPeerChatServiceActions.swift in Sources */, D0F3A8A51E82C94C00B4C64C /* SynchronizeableChatInputState.swift in Sources */, D03B0CD71D62245300955575 /* TelegramGroup.swift in Sources */, + D02609BF20C6EC08006C34AC /* Crypto.m in Sources */, D0B8438C1DA7CF50005F29E1 /* BotInfo.swift in Sources */, D033FEB31E61F3C000644997 /* ReportPeer.swift in Sources */, D04D8FF4209A4B0700865719 /* NetworkSettings.swift in Sources */, @@ -2367,6 +2374,7 @@ D01C7ED41EF5DF83008305F1 /* LimitsConfiguration.swift in Sources */, C26A37EF1E5E0C41006977AC /* ChannelParticipants.swift in Sources */, D00D343D1E6EC9770057B307 /* TelegramMediaGame.swift in Sources */, + D02609C020C6EC08006C34AC /* Crypto.m in Sources */, D0C26D6A1FE02402004ABF18 /* ManagedSynchronizeGroupedPeersOperations.swift in Sources */, D01C7F051EFC1C49008305F1 /* DeviceContact.swift in Sources */, D050F26A1E4A5B6D00988324 /* ManagedGlobalNotificationSettings.swift in Sources */, diff --git a/TelegramCore/AccessSecureId.swift b/TelegramCore/AccessSecureId.swift index 0c41d9e523..8312249c25 100644 --- a/TelegramCore/AccessSecureId.swift +++ b/TelegramCore/AccessSecureId.swift @@ -10,9 +10,6 @@ import Foundation #endif import TelegramCorePrivateModule -#if swift(>=4.0) -import CommonCrypto -#endif private enum GenerateSecureSecretError { case generic @@ -23,29 +20,7 @@ func encryptSecureData(key: Data, iv: Data, data: Data, decrypt: Bool) -> Data? return nil } - var processedData = Data(count: data.count) - let processedDataCount = processedData.count - guard processedData.withUnsafeMutableBytes({ (processedDataBytes: UnsafeMutablePointer) -> Bool in - return key.withUnsafeBytes { (keyBytes: UnsafePointer) -> Bool in - return iv.withUnsafeBytes { (ivBytes: UnsafePointer) -> Bool in - return data.withUnsafeBytes { (dataBytes: UnsafePointer) -> Bool in - var processedCount: Int = 0 - let result = CCCrypt(CCOperation(decrypt ? kCCDecrypt : kCCEncrypt), CCAlgorithm(kCCAlgorithmAES128), 0, keyBytes, key.count, ivBytes, dataBytes, data.count, processedDataBytes, processedDataCount, &processedCount) - if result != kCCSuccess { - return false - } - if processedCount != processedDataCount { - return false - } - return true - } - } - } - }) else { - return nil - } - - return processedData + return CryptoAES(!decrypt, key, iv, data) } func verifySecureSecret(_ data: Data) -> Bool { @@ -74,27 +49,8 @@ func decryptedSecureSecret(encryptedSecretData: Data, password: String, salt: Da let secretKey = passwordHash.subdata(in: 0 ..< 32) let iv = passwordHash.subdata(in: 32 ..< (32 + 16)) - var decryptedSecret = Data(count: encryptedSecretData.count) - let decryptedSecretCount = decryptedSecret.count - - guard decryptedSecret.withUnsafeMutableBytes({ (decryptedSecretBytes: UnsafeMutablePointer) -> Bool in - return secretKey.withUnsafeBytes { (secretKeyBytes: UnsafePointer) -> Bool in - return iv.withUnsafeBytes { (ivBytes: UnsafePointer) -> Bool in - return encryptedSecretData.withUnsafeBytes { (encryptedSecretDataBytes: UnsafePointer) -> Bool in - var processedCount: Int = 0 - let result = CCCrypt(CCOperation(kCCDecrypt), CCAlgorithm(kCCAlgorithmAES128), 0, secretKeyBytes, secretKey.count, ivBytes, encryptedSecretDataBytes, encryptedSecretData.count, decryptedSecretBytes, decryptedSecretCount, &processedCount) - if result != kCCSuccess { - return false - } - if processedCount != decryptedSecretCount { - return false - } - return true - } - } - } - }) else { - return nil + guard let decryptedSecret = CryptoAES(false, secretKey, iv, encryptedSecretData) else { + return nil; } if !verifySecureSecret(decryptedSecret) { @@ -140,26 +96,7 @@ func encryptedSecureSecret(secretData: Data, password: String, inputSalt: Data) let secretKey = passwordHash.subdata(in: 0 ..< 32) let iv = passwordHash.subdata(in: 32 ..< (32 + 16)) - var encryptedSecret = Data(count: secretData.count) - let encryptedSecretCount = encryptedSecret.count - - guard encryptedSecret.withUnsafeMutableBytes({ (encryptedSecretBytes: UnsafeMutablePointer) -> Bool in - return secretKey.withUnsafeBytes { (secretKeyBytes: UnsafePointer) -> Bool in - return iv.withUnsafeBytes { (ivBytes: UnsafePointer) -> Bool in - return secretData.withUnsafeBytes { (secretDataBytes: UnsafePointer) -> Bool in - var processedCount: Int = 0 - let result = CCCrypt(CCOperation(kCCEncrypt), CCAlgorithm(kCCAlgorithmAES128), 0, secretKeyBytes, secretKey.count, ivBytes, secretDataBytes, secretData.count, encryptedSecretBytes, encryptedSecretCount, &processedCount) - if result != kCCSuccess { - return false - } - if processedCount != encryptedSecretCount { - return false - } - return true - } - } - } - }) else { + guard let encryptedSecret = CryptoAES(true, secretKey, iv, secretData) else { return nil } diff --git a/TelegramCore/Account.swift b/TelegramCore/Account.swift index b8f78a4e0c..f5f32595ef 100644 --- a/TelegramCore/Account.swift +++ b/TelegramCore/Account.swift @@ -9,9 +9,6 @@ import Foundation import MtProtoKitDynamic #endif import TelegramCorePrivateModule -#if swift(>=4.0) -import CommonCrypto -#endif public protocol AccountState: PostboxCoding { func equalsTo(_ other: AccountState) -> Bool @@ -402,36 +399,21 @@ public func dataWithHexString(_ string: String) -> Data { } func sha1Digest(_ data : Data) -> Data { - var res = Data() - res.count = Int(CC_SHA1_DIGEST_LENGTH) - res.withUnsafeMutableBytes { mutableBytes -> Void in - data.withUnsafeBytes { bytes -> Void in - CC_SHA1(bytes, CC_LONG(data.count), mutableBytes) - } + return data.withUnsafeBytes { bytes -> Data in + return CryptoSHA1(bytes, Int32(data.count)) } - return res } func sha256Digest(_ data : Data) -> Data { - var res = Data() - res.count = Int(CC_SHA256_DIGEST_LENGTH) - res.withUnsafeMutableBytes { mutableBytes -> Void in - data.withUnsafeBytes { bytes -> Void in - CC_SHA256(bytes, CC_LONG(data.count), mutableBytes) - } + return data.withUnsafeBytes { bytes -> Data in + return CryptoSHA256(bytes, Int32(data.count)) } - return res } func sha512Digest(_ data : Data) -> Data { - var res = Data() - res.count = Int(CC_SHA512_DIGEST_LENGTH) - res.withUnsafeMutableBytes { mutableBytes -> Void in - data.withUnsafeBytes { bytes -> Void in - CC_SHA512(bytes, CC_LONG(data.count), mutableBytes) - } + return data.withUnsafeBytes { bytes -> Data in + return CryptoSHA512(bytes, Int32(data.count)) } - return res } func verifyPassword(_ account: UnauthorizedAccount, password: String) -> Signal { diff --git a/TelegramCore/Api0.swift b/TelegramCore/Api0.swift index ca33f925b6..1053d0e801 100644 --- a/TelegramCore/Api0.swift +++ b/TelegramCore/Api0.swift @@ -1103,7 +1103,7 @@ struct Api { } extension Api { struct messages { - enum StickerSet { + enum StickerSet: TypeConstructorDescription { case stickerSet(set: Api.StickerSet, packs: [Api.StickerPack], documents: [Api.Document]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1125,6 +1125,13 @@ struct messages { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .stickerSet(let set, let packs, let documents): + return ("stickerSet", [("set", set), ("packs", packs), ("documents", documents)]) + } } static func parse_stickerSet(_ reader: BufferReader) -> StickerSet? { @@ -1152,7 +1159,7 @@ struct messages { } } - enum ArchivedStickers { + enum ArchivedStickers: TypeConstructorDescription { case archivedStickers(count: Int32, sets: [Api.StickerSetCovered]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1169,6 +1176,13 @@ struct messages { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .archivedStickers(let count, let sets): + return ("archivedStickers", [("count", count), ("sets", sets)]) + } } static func parse_archivedStickers(_ reader: BufferReader) -> ArchivedStickers? { @@ -1189,7 +1203,7 @@ struct messages { } } - enum SentEncryptedMessage { + enum SentEncryptedMessage: TypeConstructorDescription { case sentEncryptedMessage(date: Int32) case sentEncryptedFile(date: Int32, file: Api.EncryptedFile) @@ -1209,6 +1223,15 @@ struct messages { file.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .sentEncryptedMessage(let date): + return ("sentEncryptedMessage", [("date", date)]) + case .sentEncryptedFile(let date, let file): + return ("sentEncryptedFile", [("date", date), ("file", file)]) + } } static func parse_sentEncryptedMessage(_ reader: BufferReader) -> SentEncryptedMessage? { @@ -1240,7 +1263,7 @@ struct messages { } } - enum Stickers { + enum Stickers: TypeConstructorDescription { case stickersNotModified case stickers(hash: Int32, stickers: [Api.Document]) @@ -1264,6 +1287,15 @@ struct messages { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .stickersNotModified: + return ("stickersNotModified", []) + case .stickers(let hash, let stickers): + return ("stickers", [("hash", hash), ("stickers", stickers)]) + } } static func parse_stickersNotModified(_ reader: BufferReader) -> Stickers? { @@ -1287,7 +1319,7 @@ struct messages { } } - enum FoundStickerSets { + enum FoundStickerSets: TypeConstructorDescription { case foundStickerSetsNotModified case foundStickerSets(hash: Int32, sets: [Api.StickerSetCovered]) @@ -1311,6 +1343,15 @@ struct messages { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .foundStickerSetsNotModified: + return ("foundStickerSetsNotModified", []) + case .foundStickerSets(let hash, let sets): + return ("foundStickerSets", [("hash", hash), ("sets", sets)]) + } } static func parse_foundStickerSetsNotModified(_ reader: BufferReader) -> FoundStickerSets? { @@ -1334,7 +1375,7 @@ struct messages { } } - enum FoundGifs { + enum FoundGifs: TypeConstructorDescription { case foundGifs(nextOffset: Int32, results: [Api.FoundGif]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1351,6 +1392,13 @@ struct messages { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .foundGifs(let nextOffset, let results): + return ("foundGifs", [("nextOffset", nextOffset), ("results", results)]) + } } static func parse_foundGifs(_ reader: BufferReader) -> FoundGifs? { @@ -1371,7 +1419,7 @@ struct messages { } } - enum BotResults { + enum BotResults: TypeConstructorDescription { case botResults(flags: Int32, queryId: Int64, nextOffset: String?, switchPm: Api.InlineBotSwitchPM?, results: [Api.BotInlineResult], cacheTime: Int32, users: [Api.User]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1397,6 +1445,13 @@ struct messages { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .botResults(let flags, let queryId, let nextOffset, let switchPm, let results, let cacheTime, let users): + return ("botResults", [("flags", flags), ("queryId", queryId), ("nextOffset", nextOffset), ("switchPm", switchPm), ("results", results), ("cacheTime", cacheTime), ("users", users)]) + } } static func parse_botResults(_ reader: BufferReader) -> BotResults? { @@ -1436,7 +1491,7 @@ struct messages { } } - enum BotCallbackAnswer { + enum BotCallbackAnswer: TypeConstructorDescription { case botCallbackAnswer(flags: Int32, message: String?, url: String?, cacheTime: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1451,6 +1506,13 @@ struct messages { serializeInt32(cacheTime, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .botCallbackAnswer(let flags, let message, let url, let cacheTime): + return ("botCallbackAnswer", [("flags", flags), ("message", message), ("url", url), ("cacheTime", cacheTime)]) + } } static func parse_botCallbackAnswer(_ reader: BufferReader) -> BotCallbackAnswer? { @@ -1475,7 +1537,7 @@ struct messages { } } - enum Chats { + enum Chats: TypeConstructorDescription { case chats(chats: [Api.Chat]) case chatsSlice(count: Int32, chats: [Api.Chat]) @@ -1503,6 +1565,15 @@ struct messages { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .chats(let chats): + return ("chats", [("chats", chats)]) + case .chatsSlice(let count, let chats): + return ("chatsSlice", [("count", count), ("chats", chats)]) + } } static func parse_chats(_ reader: BufferReader) -> Chats? { @@ -1536,7 +1607,7 @@ struct messages { } } - enum DhConfig { + enum DhConfig: TypeConstructorDescription { case dhConfigNotModified(random: Buffer) case dhConfig(g: Int32, p: Buffer, version: Int32, random: Buffer) @@ -1558,6 +1629,15 @@ struct messages { serializeBytes(random, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .dhConfigNotModified(let random): + return ("dhConfigNotModified", [("random", random)]) + case .dhConfig(let g, let p, let version, let random): + return ("dhConfig", [("g", g), ("p", p), ("version", version), ("random", random)]) + } } static func parse_dhConfigNotModified(_ reader: BufferReader) -> DhConfig? { @@ -1593,7 +1673,7 @@ struct messages { } } - enum AffectedHistory { + enum AffectedHistory: TypeConstructorDescription { case affectedHistory(pts: Int32, ptsCount: Int32, offset: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1607,6 +1687,13 @@ struct messages { serializeInt32(offset, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .affectedHistory(let pts, let ptsCount, let offset): + return ("affectedHistory", [("pts", pts), ("ptsCount", ptsCount), ("offset", offset)]) + } } static func parse_affectedHistory(_ reader: BufferReader) -> AffectedHistory? { @@ -1628,7 +1715,7 @@ struct messages { } } - enum MessageEditData { + enum MessageEditData: TypeConstructorDescription { case messageEditData(flags: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1640,6 +1727,13 @@ struct messages { serializeInt32(flags, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .messageEditData(let flags): + return ("messageEditData", [("flags", flags)]) + } } static func parse_messageEditData(_ reader: BufferReader) -> MessageEditData? { @@ -1655,7 +1749,7 @@ struct messages { } } - enum ChatFull { + enum ChatFull: TypeConstructorDescription { case chatFull(fullChat: Api.ChatFull, chats: [Api.Chat], users: [Api.User]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1677,6 +1771,13 @@ struct messages { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .chatFull(let fullChat, let chats, let users): + return ("chatFull", [("fullChat", fullChat), ("chats", chats), ("users", users)]) + } } static func parse_chatFull(_ reader: BufferReader) -> ChatFull? { @@ -1704,7 +1805,7 @@ struct messages { } } - enum StickerSetInstallResult { + enum StickerSetInstallResult: TypeConstructorDescription { case stickerSetInstallResultSuccess case stickerSetInstallResultArchive(sets: [Api.StickerSetCovered]) @@ -1727,6 +1828,15 @@ struct messages { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .stickerSetInstallResultSuccess: + return ("stickerSetInstallResultSuccess", []) + case .stickerSetInstallResultArchive(let sets): + return ("stickerSetInstallResultArchive", [("sets", sets)]) + } } static func parse_stickerSetInstallResultSuccess(_ reader: BufferReader) -> StickerSetInstallResult? { @@ -1747,7 +1857,7 @@ struct messages { } } - enum AffectedMessages { + enum AffectedMessages: TypeConstructorDescription { case affectedMessages(pts: Int32, ptsCount: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1760,6 +1870,13 @@ struct messages { serializeInt32(ptsCount, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .affectedMessages(let pts, let ptsCount): + return ("affectedMessages", [("pts", pts), ("ptsCount", ptsCount)]) + } } static func parse_affectedMessages(_ reader: BufferReader) -> AffectedMessages? { @@ -1778,7 +1895,7 @@ struct messages { } } - enum SavedGifs { + enum SavedGifs: TypeConstructorDescription { case savedGifsNotModified case savedGifs(hash: Int32, gifs: [Api.Document]) @@ -1802,6 +1919,15 @@ struct messages { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .savedGifsNotModified: + return ("savedGifsNotModified", []) + case .savedGifs(let hash, let gifs): + return ("savedGifs", [("hash", hash), ("gifs", gifs)]) + } } static func parse_savedGifsNotModified(_ reader: BufferReader) -> SavedGifs? { @@ -1825,7 +1951,7 @@ struct messages { } } - enum Messages { + enum Messages: TypeConstructorDescription { case messages(messages: [Api.Message], chats: [Api.Chat], users: [Api.User]) case messagesSlice(count: Int32, messages: [Api.Message], chats: [Api.Chat], users: [Api.User]) case channelMessages(flags: Int32, pts: Int32, count: Int32, messages: [Api.Message], chats: [Api.Chat], users: [Api.User]) @@ -1904,6 +2030,19 @@ struct messages { serializeInt32(count, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .messages(let messages, let chats, let users): + return ("messages", [("messages", messages), ("chats", chats), ("users", users)]) + case .messagesSlice(let count, let messages, let chats, let users): + return ("messagesSlice", [("count", count), ("messages", messages), ("chats", chats), ("users", users)]) + case .channelMessages(let flags, let pts, let count, let messages, let chats, let users): + return ("channelMessages", [("flags", flags), ("pts", pts), ("count", count), ("messages", messages), ("chats", chats), ("users", users)]) + case .messagesNotModified(let count): + return ("messagesNotModified", [("count", count)]) + } } static func parse_messages(_ reader: BufferReader) -> Messages? { @@ -2000,7 +2139,7 @@ struct messages { } } - enum PeerDialogs { + enum PeerDialogs: TypeConstructorDescription { case peerDialogs(dialogs: [Api.Dialog], messages: [Api.Message], chats: [Api.Chat], users: [Api.User], state: Api.updates.State) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -2032,6 +2171,13 @@ struct messages { state.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .peerDialogs(let dialogs, let messages, let chats, let users, let state): + return ("peerDialogs", [("dialogs", dialogs), ("messages", messages), ("chats", chats), ("users", users), ("state", state)]) + } } static func parse_peerDialogs(_ reader: BufferReader) -> PeerDialogs? { @@ -2069,7 +2215,7 @@ struct messages { } } - enum RecentStickers { + enum RecentStickers: TypeConstructorDescription { case recentStickersNotModified case recentStickers(hash: Int32, packs: [Api.StickerPack], stickers: [Api.Document], dates: [Int32]) @@ -2103,6 +2249,15 @@ struct messages { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .recentStickersNotModified: + return ("recentStickersNotModified", []) + case .recentStickers(let hash, let packs, let stickers, let dates): + return ("recentStickers", [("hash", hash), ("packs", packs), ("stickers", stickers), ("dates", dates)]) + } } static func parse_recentStickersNotModified(_ reader: BufferReader) -> RecentStickers? { @@ -2136,7 +2291,7 @@ struct messages { } } - enum FeaturedStickers { + enum FeaturedStickers: TypeConstructorDescription { case featuredStickersNotModified case featuredStickers(hash: Int32, sets: [Api.StickerSetCovered], unread: [Int64]) @@ -2165,6 +2320,15 @@ struct messages { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .featuredStickersNotModified: + return ("featuredStickersNotModified", []) + case .featuredStickers(let hash, let sets, let unread): + return ("featuredStickers", [("hash", hash), ("sets", sets), ("unread", unread)]) + } } static func parse_featuredStickersNotModified(_ reader: BufferReader) -> FeaturedStickers? { @@ -2193,7 +2357,7 @@ struct messages { } } - enum Dialogs { + enum Dialogs: TypeConstructorDescription { case dialogs(dialogs: [Api.Dialog], messages: [Api.Message], chats: [Api.Chat], users: [Api.User]) case dialogsSlice(count: Int32, dialogs: [Api.Dialog], messages: [Api.Message], chats: [Api.Chat], users: [Api.User]) @@ -2251,6 +2415,15 @@ struct messages { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .dialogs(let dialogs, let messages, let chats, let users): + return ("dialogs", [("dialogs", dialogs), ("messages", messages), ("chats", chats), ("users", users)]) + case .dialogsSlice(let count, let dialogs, let messages, let chats, let users): + return ("dialogsSlice", [("count", count), ("dialogs", dialogs), ("messages", messages), ("chats", chats), ("users", users)]) + } } static func parse_dialogs(_ reader: BufferReader) -> Dialogs? { @@ -2314,7 +2487,7 @@ struct messages { } } - enum FavedStickers { + enum FavedStickers: TypeConstructorDescription { case favedStickersNotModified case favedStickers(hash: Int32, packs: [Api.StickerPack], stickers: [Api.Document]) @@ -2343,6 +2516,15 @@ struct messages { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .favedStickersNotModified: + return ("favedStickersNotModified", []) + case .favedStickers(let hash, let packs, let stickers): + return ("favedStickers", [("hash", hash), ("packs", packs), ("stickers", stickers)]) + } } static func parse_favedStickersNotModified(_ reader: BufferReader) -> FavedStickers? { @@ -2371,7 +2553,7 @@ struct messages { } } - enum AllStickers { + enum AllStickers: TypeConstructorDescription { case allStickersNotModified case allStickers(hash: Int32, sets: [Api.StickerSet]) @@ -2395,6 +2577,15 @@ struct messages { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .allStickersNotModified: + return ("allStickersNotModified", []) + case .allStickers(let hash, let sets): + return ("allStickers", [("hash", hash), ("sets", sets)]) + } } static func parse_allStickersNotModified(_ reader: BufferReader) -> AllStickers? { @@ -2418,7 +2609,7 @@ struct messages { } } - enum HighScores { + enum HighScores: TypeConstructorDescription { case highScores(scores: [Api.HighScore], users: [Api.User]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -2439,6 +2630,13 @@ struct messages { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .highScores(let scores, let users): + return ("highScores", [("scores", scores), ("users", users)]) + } } static func parse_highScores(_ reader: BufferReader) -> HighScores? { diff --git a/TelegramCore/Api1.swift b/TelegramCore/Api1.swift index 396aa26bdd..78f47bb2ba 100644 --- a/TelegramCore/Api1.swift +++ b/TelegramCore/Api1.swift @@ -1,5 +1,5 @@ extension Api { - enum InputGeoPoint { + enum InputGeoPoint: TypeConstructorDescription { case inputGeoPointEmpty case inputGeoPoint(lat: Double, long: Double) @@ -19,6 +19,15 @@ extension Api { serializeDouble(long, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputGeoPointEmpty: + return ("inputGeoPointEmpty", []) + case .inputGeoPoint(let lat, let long): + return ("inputGeoPoint", [("lat", lat), ("long", long)]) + } } static func parse_inputGeoPointEmpty(_ reader: BufferReader) -> InputGeoPoint? { @@ -40,7 +49,7 @@ extension Api { } } - enum ChatFull { + enum ChatFull: TypeConstructorDescription { case chatFull(id: Int32, participants: Api.ChatParticipants, chatPhoto: Api.Photo, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite, botInfo: [Api.BotInfo]) case channelFull(flags: Int32, id: Int32, about: String, participantsCount: Int32?, adminsCount: Int32?, kickedCount: Int32?, bannedCount: Int32?, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, chatPhoto: Api.Photo, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite, botInfo: [Api.BotInfo], migratedFromChatId: Int32?, migratedFromMaxId: Int32?, pinnedMsgId: Int32?, stickerset: Api.StickerSet?, availableMinId: Int32?) @@ -90,6 +99,15 @@ extension Api { if Int(flags) & Int(1 << 9) != 0 {serializeInt32(availableMinId!, buffer: buffer, boxed: false)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .chatFull(let id, let participants, let chatPhoto, let notifySettings, let exportedInvite, let botInfo): + return ("chatFull", [("id", id), ("participants", participants), ("chatPhoto", chatPhoto), ("notifySettings", notifySettings), ("exportedInvite", exportedInvite), ("botInfo", botInfo)]) + case .channelFull(let flags, let id, let about, let participantsCount, let adminsCount, let kickedCount, let bannedCount, let readInboxMaxId, let readOutboxMaxId, let unreadCount, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let migratedFromChatId, let migratedFromMaxId, let pinnedMsgId, let stickerset, let availableMinId): + return ("channelFull", [("flags", flags), ("id", id), ("about", about), ("participantsCount", participantsCount), ("adminsCount", adminsCount), ("kickedCount", kickedCount), ("bannedCount", bannedCount), ("readInboxMaxId", readInboxMaxId), ("readOutboxMaxId", readOutboxMaxId), ("unreadCount", unreadCount), ("chatPhoto", chatPhoto), ("notifySettings", notifySettings), ("exportedInvite", exportedInvite), ("botInfo", botInfo), ("migratedFromChatId", migratedFromChatId), ("migratedFromMaxId", migratedFromMaxId), ("pinnedMsgId", pinnedMsgId), ("stickerset", stickerset), ("availableMinId", availableMinId)]) + } } static func parse_chatFull(_ reader: BufferReader) -> ChatFull? { @@ -205,7 +223,7 @@ extension Api { } } - enum ChatParticipant { + enum ChatParticipant: TypeConstructorDescription { case chatParticipant(userId: Int32, inviterId: Int32, date: Int32) case chatParticipantCreator(userId: Int32) case chatParticipantAdmin(userId: Int32, inviterId: Int32, date: Int32) @@ -235,6 +253,17 @@ extension Api { serializeInt32(date, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .chatParticipant(let userId, let inviterId, let date): + return ("chatParticipant", [("userId", userId), ("inviterId", inviterId), ("date", date)]) + case .chatParticipantCreator(let userId): + return ("chatParticipantCreator", [("userId", userId)]) + case .chatParticipantAdmin(let userId, let inviterId, let date): + return ("chatParticipantAdmin", [("userId", userId), ("inviterId", inviterId), ("date", date)]) + } } static func parse_chatParticipant(_ reader: BufferReader) -> ChatParticipant? { @@ -284,7 +313,7 @@ extension Api { } } - enum CdnConfig { + enum CdnConfig: TypeConstructorDescription { case cdnConfig(publicKeys: [Api.CdnPublicKey]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -300,6 +329,13 @@ extension Api { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .cdnConfig(let publicKeys): + return ("cdnConfig", [("publicKeys", publicKeys)]) + } } static func parse_cdnConfig(_ reader: BufferReader) -> CdnConfig? { @@ -317,7 +353,7 @@ extension Api { } } - indirect enum PageBlock { + indirect enum PageBlock: TypeConstructorDescription { case pageBlockUnsupported case pageBlockTitle(text: Api.RichText) case pageBlockSubtitle(text: Api.RichText) @@ -522,6 +558,57 @@ extension Api { caption.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .pageBlockUnsupported: + return ("pageBlockUnsupported", []) + case .pageBlockTitle(let text): + return ("pageBlockTitle", [("text", text)]) + case .pageBlockSubtitle(let text): + return ("pageBlockSubtitle", [("text", text)]) + case .pageBlockAuthorDate(let author, let publishedDate): + return ("pageBlockAuthorDate", [("author", author), ("publishedDate", publishedDate)]) + case .pageBlockHeader(let text): + return ("pageBlockHeader", [("text", text)]) + case .pageBlockSubheader(let text): + return ("pageBlockSubheader", [("text", text)]) + case .pageBlockParagraph(let text): + return ("pageBlockParagraph", [("text", text)]) + case .pageBlockPreformatted(let text, let language): + return ("pageBlockPreformatted", [("text", text), ("language", language)]) + case .pageBlockFooter(let text): + return ("pageBlockFooter", [("text", text)]) + case .pageBlockDivider: + return ("pageBlockDivider", []) + case .pageBlockAnchor(let name): + return ("pageBlockAnchor", [("name", name)]) + case .pageBlockList(let ordered, let items): + return ("pageBlockList", [("ordered", ordered), ("items", items)]) + case .pageBlockBlockquote(let text, let caption): + return ("pageBlockBlockquote", [("text", text), ("caption", caption)]) + case .pageBlockPullquote(let text, let caption): + return ("pageBlockPullquote", [("text", text), ("caption", caption)]) + case .pageBlockPhoto(let photoId, let caption): + return ("pageBlockPhoto", [("photoId", photoId), ("caption", caption)]) + case .pageBlockVideo(let flags, let videoId, let caption): + return ("pageBlockVideo", [("flags", flags), ("videoId", videoId), ("caption", caption)]) + case .pageBlockCover(let cover): + return ("pageBlockCover", [("cover", cover)]) + case .pageBlockEmbed(let flags, let url, let html, let posterPhotoId, let w, let h, let caption): + return ("pageBlockEmbed", [("flags", flags), ("url", url), ("html", html), ("posterPhotoId", posterPhotoId), ("w", w), ("h", h), ("caption", caption)]) + case .pageBlockEmbedPost(let url, let webpageId, let authorPhotoId, let author, let date, let blocks, let caption): + return ("pageBlockEmbedPost", [("url", url), ("webpageId", webpageId), ("authorPhotoId", authorPhotoId), ("author", author), ("date", date), ("blocks", blocks), ("caption", caption)]) + case .pageBlockCollage(let items, let caption): + return ("pageBlockCollage", [("items", items), ("caption", caption)]) + case .pageBlockSlideshow(let items, let caption): + return ("pageBlockSlideshow", [("items", items), ("caption", caption)]) + case .pageBlockChannel(let channel): + return ("pageBlockChannel", [("channel", channel)]) + case .pageBlockAudio(let audioId, let caption): + return ("pageBlockAudio", [("audioId", audioId), ("caption", caption)]) + } } static func parse_pageBlockUnsupported(_ reader: BufferReader) -> PageBlock? { @@ -884,7 +971,7 @@ extension Api { } } - enum Photo { + enum Photo: TypeConstructorDescription { case photoEmpty(id: Int64) case photo(flags: Int32, id: Int64, accessHash: Int64, date: Int32, sizes: [Api.PhotoSize]) @@ -911,6 +998,15 @@ extension Api { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .photoEmpty(let id): + return ("photoEmpty", [("id", id)]) + case .photo(let flags, let id, let accessHash, let date, let sizes): + return ("photo", [("flags", flags), ("id", id), ("accessHash", accessHash), ("date", date), ("sizes", sizes)]) + } } static func parse_photoEmpty(_ reader: BufferReader) -> Photo? { @@ -951,7 +1047,7 @@ extension Api { } } - enum Chat { + enum Chat: TypeConstructorDescription { case chatEmpty(id: Int32) case chat(flags: Int32, id: Int32, title: String, photo: Api.ChatPhoto, participantsCount: Int32, date: Int32, version: Int32, migratedTo: Api.InputChannel?) case chatForbidden(id: Int32, title: String) @@ -1014,6 +1110,21 @@ extension Api { if Int(flags) & Int(1 << 17) != 0 {serializeInt32(participantsCount!, buffer: buffer, boxed: false)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .chatEmpty(let id): + return ("chatEmpty", [("id", id)]) + case .chat(let flags, let id, let title, let photo, let participantsCount, let date, let version, let migratedTo): + return ("chat", [("flags", flags), ("id", id), ("title", title), ("photo", photo), ("participantsCount", participantsCount), ("date", date), ("version", version), ("migratedTo", migratedTo)]) + case .chatForbidden(let id, let title): + return ("chatForbidden", [("id", id), ("title", title)]) + case .channelForbidden(let flags, let id, let accessHash, let title, let untilDate): + return ("channelForbidden", [("flags", flags), ("id", id), ("accessHash", accessHash), ("title", title), ("untilDate", untilDate)]) + case .channel(let flags, let id, let accessHash, let title, let username, let photo, let date, let version, let restrictionReason, let adminRights, let bannedRights, let participantsCount): + return ("channel", [("flags", flags), ("id", id), ("accessHash", accessHash), ("title", title), ("username", username), ("photo", photo), ("date", date), ("version", version), ("restrictionReason", restrictionReason), ("adminRights", adminRights), ("bannedRights", bannedRights), ("participantsCount", participantsCount)]) + } } static func parse_chatEmpty(_ reader: BufferReader) -> Chat? { @@ -1152,7 +1263,7 @@ extension Api { } } - enum ChatInvite { + enum ChatInvite: TypeConstructorDescription { case chatInviteAlready(chat: Api.Chat) case chatInvite(flags: Int32, title: String, photo: Api.ChatPhoto, participantsCount: Int32, participants: [Api.User]?) @@ -1179,6 +1290,15 @@ extension Api { }} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .chatInviteAlready(let chat): + return ("chatInviteAlready", [("chat", chat)]) + case .chatInvite(let flags, let title, let photo, let participantsCount, let participants): + return ("chatInvite", [("flags", flags), ("title", title), ("photo", photo), ("participantsCount", participantsCount), ("participants", participants)]) + } } static func parse_chatInviteAlready(_ reader: BufferReader) -> ChatInvite? { @@ -1223,7 +1343,7 @@ extension Api { } } - enum StickerSetCovered { + enum StickerSetCovered: TypeConstructorDescription { case stickerSetCovered(set: Api.StickerSet, cover: Api.Document) case stickerSetMultiCovered(set: Api.StickerSet, covers: [Api.Document]) @@ -1248,6 +1368,15 @@ extension Api { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .stickerSetCovered(let set, let cover): + return ("stickerSetCovered", [("set", set), ("cover", cover)]) + case .stickerSetMultiCovered(let set, let covers): + return ("stickerSetMultiCovered", [("set", set), ("covers", covers)]) + } } static func parse_stickerSetCovered(_ reader: BufferReader) -> StickerSetCovered? { @@ -1288,7 +1417,7 @@ extension Api { } } - enum RecentMeUrl { + enum RecentMeUrl: TypeConstructorDescription { case recentMeUrlUnknown(url: String) case recentMeUrlUser(url: String, userId: Int32) case recentMeUrlChat(url: String, chatId: Int32) @@ -1332,6 +1461,21 @@ extension Api { set.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .recentMeUrlUnknown(let url): + return ("recentMeUrlUnknown", [("url", url)]) + case .recentMeUrlUser(let url, let userId): + return ("recentMeUrlUser", [("url", url), ("userId", userId)]) + case .recentMeUrlChat(let url, let chatId): + return ("recentMeUrlChat", [("url", url), ("chatId", chatId)]) + case .recentMeUrlChatInvite(let url, let chatInvite): + return ("recentMeUrlChatInvite", [("url", url), ("chatInvite", chatInvite)]) + case .recentMeUrlStickerSet(let url, let set): + return ("recentMeUrlStickerSet", [("url", url), ("set", set)]) + } } static func parse_recentMeUrlUnknown(_ reader: BufferReader) -> RecentMeUrl? { @@ -1407,7 +1551,7 @@ extension Api { } } - indirect enum RichText { + indirect enum RichText: TypeConstructorDescription { case textEmpty case textPlain(text: String) case textBold(text: Api.RichText) @@ -1489,6 +1633,31 @@ extension Api { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .textEmpty: + return ("textEmpty", []) + case .textPlain(let text): + return ("textPlain", [("text", text)]) + case .textBold(let text): + return ("textBold", [("text", text)]) + case .textItalic(let text): + return ("textItalic", [("text", text)]) + case .textUnderline(let text): + return ("textUnderline", [("text", text)]) + case .textStrike(let text): + return ("textStrike", [("text", text)]) + case .textFixed(let text): + return ("textFixed", [("text", text)]) + case .textUrl(let text, let url, let webpageId): + return ("textUrl", [("text", text), ("url", url), ("webpageId", webpageId)]) + case .textEmail(let text, let email): + return ("textEmail", [("text", text), ("email", email)]) + case .textConcat(let texts): + return ("textConcat", [("texts", texts)]) + } } static func parse_textEmpty(_ reader: BufferReader) -> RichText? { @@ -1620,7 +1789,7 @@ extension Api { } } - enum UserFull { + enum UserFull: TypeConstructorDescription { case userFull(flags: Int32, user: Api.User, about: String?, link: Api.contacts.Link, profilePhoto: Api.Photo?, notifySettings: Api.PeerNotifySettings, botInfo: Api.BotInfo?, commonChatsCount: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1639,6 +1808,13 @@ extension Api { serializeInt32(commonChatsCount, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .userFull(let flags, let user, let about, let link, let profilePhoto, let notifySettings, let botInfo, let commonChatsCount): + return ("userFull", [("flags", flags), ("user", user), ("about", about), ("link", link), ("profilePhoto", profilePhoto), ("notifySettings", notifySettings), ("botInfo", botInfo), ("commonChatsCount", commonChatsCount)]) + } } static func parse_userFull(_ reader: BufferReader) -> UserFull? { @@ -1685,7 +1861,7 @@ extension Api { } } - enum InputChannel { + enum InputChannel: TypeConstructorDescription { case inputChannelEmpty case inputChannel(channelId: Int32, accessHash: Int64) @@ -1705,6 +1881,15 @@ extension Api { serializeInt64(accessHash, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputChannelEmpty: + return ("inputChannelEmpty", []) + case .inputChannel(let channelId, let accessHash): + return ("inputChannel", [("channelId", channelId), ("accessHash", accessHash)]) + } } static func parse_inputChannelEmpty(_ reader: BufferReader) -> InputChannel? { @@ -1726,7 +1911,7 @@ extension Api { } } - enum DcOption { + enum DcOption: TypeConstructorDescription { case dcOption(flags: Int32, id: Int32, ipAddress: String, port: Int32, secret: Buffer?) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1742,6 +1927,13 @@ extension Api { if Int(flags) & Int(1 << 10) != 0 {serializeBytes(secret!, buffer: buffer, boxed: false)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .dcOption(let flags, let id, let ipAddress, let port, let secret): + return ("dcOption", [("flags", flags), ("id", id), ("ipAddress", ipAddress), ("port", port), ("secret", secret)]) + } } static func parse_dcOption(_ reader: BufferReader) -> DcOption? { @@ -1769,7 +1961,7 @@ extension Api { } } - enum LangPackLanguage { + enum LangPackLanguage: TypeConstructorDescription { case langPackLanguage(name: String, nativeName: String, langCode: String) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1783,6 +1975,13 @@ extension Api { serializeString(langCode, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .langPackLanguage(let name, let nativeName, let langCode): + return ("langPackLanguage", [("name", name), ("nativeName", nativeName), ("langCode", langCode)]) + } } static func parse_langPackLanguage(_ reader: BufferReader) -> LangPackLanguage? { @@ -1804,7 +2003,7 @@ extension Api { } } - enum LangPackDifference { + enum LangPackDifference: TypeConstructorDescription { case langPackDifference(langCode: String, fromVersion: Int32, version: Int32, strings: [Api.LangPackString]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1823,6 +2022,13 @@ extension Api { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .langPackDifference(let langCode, let fromVersion, let version, let strings): + return ("langPackDifference", [("langCode", langCode), ("fromVersion", fromVersion), ("version", version), ("strings", strings)]) + } } static func parse_langPackDifference(_ reader: BufferReader) -> LangPackDifference? { @@ -1849,7 +2055,7 @@ extension Api { } } - enum InputEncryptedFile { + enum InputEncryptedFile: TypeConstructorDescription { case inputEncryptedFileEmpty case inputEncryptedFileUploaded(id: Int64, parts: Int32, md5Checksum: String, keyFingerprint: Int32) case inputEncryptedFile(id: Int64, accessHash: Int64) @@ -1888,6 +2094,19 @@ extension Api { serializeInt32(keyFingerprint, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputEncryptedFileEmpty: + return ("inputEncryptedFileEmpty", []) + case .inputEncryptedFileUploaded(let id, let parts, let md5Checksum, let keyFingerprint): + return ("inputEncryptedFileUploaded", [("id", id), ("parts", parts), ("md5Checksum", md5Checksum), ("keyFingerprint", keyFingerprint)]) + case .inputEncryptedFile(let id, let accessHash): + return ("inputEncryptedFile", [("id", id), ("accessHash", accessHash)]) + case .inputEncryptedFileBigUploaded(let id, let parts, let keyFingerprint): + return ("inputEncryptedFileBigUploaded", [("id", id), ("parts", parts), ("keyFingerprint", keyFingerprint)]) + } } static func parse_inputEncryptedFileEmpty(_ reader: BufferReader) -> InputEncryptedFile? { @@ -1946,7 +2165,7 @@ extension Api { } } - enum ExportedMessageLink { + enum ExportedMessageLink: TypeConstructorDescription { case exportedMessageLink(link: String, html: String) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1959,6 +2178,13 @@ extension Api { serializeString(html, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .exportedMessageLink(let link, let html): + return ("exportedMessageLink", [("link", link), ("html", html)]) + } } static func parse_exportedMessageLink(_ reader: BufferReader) -> ExportedMessageLink? { @@ -1977,7 +2203,7 @@ extension Api { } } - enum InputFile { + enum InputFile: TypeConstructorDescription { case inputFile(id: Int64, parts: Int32, name: String, md5Checksum: String) case inputFileBig(id: Int64, parts: Int32, name: String) @@ -2001,6 +2227,15 @@ extension Api { serializeString(name, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputFile(let id, let parts, let name, let md5Checksum): + return ("inputFile", [("id", id), ("parts", parts), ("name", name), ("md5Checksum", md5Checksum)]) + case .inputFileBig(let id, let parts, let name): + return ("inputFileBig", [("id", id), ("parts", parts), ("name", name)]) + } } static func parse_inputFile(_ reader: BufferReader) -> InputFile? { @@ -2042,7 +2277,7 @@ extension Api { } } - enum Peer { + enum Peer: TypeConstructorDescription { case peerUser(userId: Int32) case peerChat(chatId: Int32) case peerChannel(channelId: Int32) @@ -2068,6 +2303,17 @@ extension Api { serializeInt32(channelId, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .peerUser(let userId): + return ("peerUser", [("userId", userId)]) + case .peerChat(let chatId): + return ("peerChat", [("chatId", chatId)]) + case .peerChannel(let channelId): + return ("peerChannel", [("channelId", channelId)]) + } } static func parse_peerUser(_ reader: BufferReader) -> Peer? { @@ -2105,7 +2351,7 @@ extension Api { } } - enum PaymentRequestedInfo { + enum PaymentRequestedInfo: TypeConstructorDescription { case paymentRequestedInfo(flags: Int32, name: String?, phone: String?, email: String?, shippingAddress: Api.PostAddress?) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -2121,6 +2367,13 @@ extension Api { if Int(flags) & Int(1 << 3) != 0 {shippingAddress!.serialize(buffer, true)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .paymentRequestedInfo(let flags, let name, let phone, let email, let shippingAddress): + return ("paymentRequestedInfo", [("flags", flags), ("name", name), ("phone", phone), ("email", email), ("shippingAddress", shippingAddress)]) + } } static func parse_paymentRequestedInfo(_ reader: BufferReader) -> PaymentRequestedInfo? { @@ -2150,7 +2403,7 @@ extension Api { } } - enum UserStatus { + enum UserStatus: TypeConstructorDescription { case userStatusEmpty case userStatusOnline(expires: Int32) case userStatusOffline(wasOnline: Int32) @@ -2197,6 +2450,23 @@ extension Api { break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .userStatusEmpty: + return ("userStatusEmpty", []) + case .userStatusOnline(let expires): + return ("userStatusOnline", [("expires", expires)]) + case .userStatusOffline(let wasOnline): + return ("userStatusOffline", [("wasOnline", wasOnline)]) + case .userStatusRecently: + return ("userStatusRecently", []) + case .userStatusLastWeek: + return ("userStatusLastWeek", []) + case .userStatusLastMonth: + return ("userStatusLastMonth", []) + } } static func parse_userStatusEmpty(_ reader: BufferReader) -> UserStatus? { @@ -2235,7 +2505,7 @@ extension Api { } } - enum Dialog { + enum Dialog: TypeConstructorDescription { case dialog(flags: Int32, peer: Api.Peer, topMessage: Int32, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, unreadMentionsCount: Int32, notifySettings: Api.PeerNotifySettings, pts: Int32?, draft: Api.DraftMessage?) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -2256,6 +2526,13 @@ extension Api { if Int(flags) & Int(1 << 1) != 0 {draft!.serialize(buffer, true)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .dialog(let flags, let peer, let topMessage, let readInboxMaxId, let readOutboxMaxId, let unreadCount, let unreadMentionsCount, let notifySettings, let pts, let draft): + return ("dialog", [("flags", flags), ("peer", peer), ("topMessage", topMessage), ("readInboxMaxId", readInboxMaxId), ("readOutboxMaxId", readOutboxMaxId), ("unreadCount", unreadCount), ("unreadMentionsCount", unreadMentionsCount), ("notifySettings", notifySettings), ("pts", pts), ("draft", draft)]) + } } static func parse_dialog(_ reader: BufferReader) -> Dialog? { @@ -2304,7 +2581,7 @@ extension Api { } } - enum SendMessageAction { + enum SendMessageAction: TypeConstructorDescription { case sendMessageTypingAction case sendMessageCancelAction case sendMessageRecordVideoAction @@ -2400,6 +2677,37 @@ extension Api { break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .sendMessageTypingAction: + return ("sendMessageTypingAction", []) + case .sendMessageCancelAction: + return ("sendMessageCancelAction", []) + case .sendMessageRecordVideoAction: + return ("sendMessageRecordVideoAction", []) + case .sendMessageUploadVideoAction(let progress): + return ("sendMessageUploadVideoAction", [("progress", progress)]) + case .sendMessageRecordAudioAction: + return ("sendMessageRecordAudioAction", []) + case .sendMessageUploadAudioAction(let progress): + return ("sendMessageUploadAudioAction", [("progress", progress)]) + case .sendMessageUploadPhotoAction(let progress): + return ("sendMessageUploadPhotoAction", [("progress", progress)]) + case .sendMessageUploadDocumentAction(let progress): + return ("sendMessageUploadDocumentAction", [("progress", progress)]) + case .sendMessageGeoLocationAction: + return ("sendMessageGeoLocationAction", []) + case .sendMessageChooseContactAction: + return ("sendMessageChooseContactAction", []) + case .sendMessageGamePlayAction: + return ("sendMessageGamePlayAction", []) + case .sendMessageRecordRoundAction: + return ("sendMessageRecordRoundAction", []) + case .sendMessageUploadRoundAction: + return ("sendMessageUploadRoundAction", []) + } } static func parse_sendMessageTypingAction(_ reader: BufferReader) -> SendMessageAction? { @@ -2475,7 +2783,7 @@ extension Api { } } - enum PrivacyKey { + enum PrivacyKey: TypeConstructorDescription { case privacyKeyStatusTimestamp case privacyKeyChatInvite case privacyKeyPhoneCall @@ -2501,6 +2809,17 @@ extension Api { break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .privacyKeyStatusTimestamp: + return ("privacyKeyStatusTimestamp", []) + case .privacyKeyChatInvite: + return ("privacyKeyChatInvite", []) + case .privacyKeyPhoneCall: + return ("privacyKeyPhoneCall", []) + } } static func parse_privacyKeyStatusTimestamp(_ reader: BufferReader) -> PrivacyKey? { @@ -2514,7 +2833,7 @@ extension Api { } } - enum Update { + enum Update: TypeConstructorDescription { case updateNewMessage(message: Api.Message, pts: Int32, ptsCount: Int32) case updateMessageID(id: Int32, randomId: Int64) case updateDeleteMessages(messages: [Int32], pts: Int32, ptsCount: Int32) @@ -3129,6 +3448,143 @@ extension Api { }} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .updateNewMessage(let message, let pts, let ptsCount): + return ("updateNewMessage", [("message", message), ("pts", pts), ("ptsCount", ptsCount)]) + case .updateMessageID(let id, let randomId): + return ("updateMessageID", [("id", id), ("randomId", randomId)]) + case .updateDeleteMessages(let messages, let pts, let ptsCount): + return ("updateDeleteMessages", [("messages", messages), ("pts", pts), ("ptsCount", ptsCount)]) + case .updateUserTyping(let userId, let action): + return ("updateUserTyping", [("userId", userId), ("action", action)]) + case .updateChatUserTyping(let chatId, let userId, let action): + return ("updateChatUserTyping", [("chatId", chatId), ("userId", userId), ("action", action)]) + case .updateChatParticipants(let participants): + return ("updateChatParticipants", [("participants", participants)]) + case .updateUserStatus(let userId, let status): + return ("updateUserStatus", [("userId", userId), ("status", status)]) + case .updateUserName(let userId, let firstName, let lastName, let username): + return ("updateUserName", [("userId", userId), ("firstName", firstName), ("lastName", lastName), ("username", username)]) + case .updateUserPhoto(let userId, let date, let photo, let previous): + return ("updateUserPhoto", [("userId", userId), ("date", date), ("photo", photo), ("previous", previous)]) + case .updateContactRegistered(let userId, let date): + return ("updateContactRegistered", [("userId", userId), ("date", date)]) + case .updateContactLink(let userId, let myLink, let foreignLink): + return ("updateContactLink", [("userId", userId), ("myLink", myLink), ("foreignLink", foreignLink)]) + case .updateNewEncryptedMessage(let message, let qts): + return ("updateNewEncryptedMessage", [("message", message), ("qts", qts)]) + case .updateEncryptedChatTyping(let chatId): + return ("updateEncryptedChatTyping", [("chatId", chatId)]) + case .updateEncryption(let chat, let date): + return ("updateEncryption", [("chat", chat), ("date", date)]) + case .updateEncryptedMessagesRead(let chatId, let maxDate, let date): + return ("updateEncryptedMessagesRead", [("chatId", chatId), ("maxDate", maxDate), ("date", date)]) + case .updateChatParticipantAdd(let chatId, let userId, let inviterId, let date, let version): + return ("updateChatParticipantAdd", [("chatId", chatId), ("userId", userId), ("inviterId", inviterId), ("date", date), ("version", version)]) + case .updateChatParticipantDelete(let chatId, let userId, let version): + return ("updateChatParticipantDelete", [("chatId", chatId), ("userId", userId), ("version", version)]) + case .updateDcOptions(let dcOptions): + return ("updateDcOptions", [("dcOptions", dcOptions)]) + case .updateUserBlocked(let userId, let blocked): + return ("updateUserBlocked", [("userId", userId), ("blocked", blocked)]) + case .updateNotifySettings(let peer, let notifySettings): + return ("updateNotifySettings", [("peer", peer), ("notifySettings", notifySettings)]) + case .updateServiceNotification(let flags, let inboxDate, let type, let message, let media, let entities): + return ("updateServiceNotification", [("flags", flags), ("inboxDate", inboxDate), ("type", type), ("message", message), ("media", media), ("entities", entities)]) + case .updatePrivacy(let key, let rules): + return ("updatePrivacy", [("key", key), ("rules", rules)]) + case .updateUserPhone(let userId, let phone): + return ("updateUserPhone", [("userId", userId), ("phone", phone)]) + case .updateReadHistoryInbox(let peer, let maxId, let pts, let ptsCount): + return ("updateReadHistoryInbox", [("peer", peer), ("maxId", maxId), ("pts", pts), ("ptsCount", ptsCount)]) + case .updateReadHistoryOutbox(let peer, let maxId, let pts, let ptsCount): + return ("updateReadHistoryOutbox", [("peer", peer), ("maxId", maxId), ("pts", pts), ("ptsCount", ptsCount)]) + case .updateWebPage(let webpage, let pts, let ptsCount): + return ("updateWebPage", [("webpage", webpage), ("pts", pts), ("ptsCount", ptsCount)]) + case .updateReadMessagesContents(let messages, let pts, let ptsCount): + return ("updateReadMessagesContents", [("messages", messages), ("pts", pts), ("ptsCount", ptsCount)]) + case .updateChannelTooLong(let flags, let channelId, let pts): + return ("updateChannelTooLong", [("flags", flags), ("channelId", channelId), ("pts", pts)]) + case .updateChannel(let channelId): + return ("updateChannel", [("channelId", channelId)]) + case .updateNewChannelMessage(let message, let pts, let ptsCount): + return ("updateNewChannelMessage", [("message", message), ("pts", pts), ("ptsCount", ptsCount)]) + case .updateReadChannelInbox(let channelId, let maxId): + return ("updateReadChannelInbox", [("channelId", channelId), ("maxId", maxId)]) + case .updateDeleteChannelMessages(let channelId, let messages, let pts, let ptsCount): + return ("updateDeleteChannelMessages", [("channelId", channelId), ("messages", messages), ("pts", pts), ("ptsCount", ptsCount)]) + case .updateChannelMessageViews(let channelId, let id, let views): + return ("updateChannelMessageViews", [("channelId", channelId), ("id", id), ("views", views)]) + case .updateChatAdmins(let chatId, let enabled, let version): + return ("updateChatAdmins", [("chatId", chatId), ("enabled", enabled), ("version", version)]) + case .updateChatParticipantAdmin(let chatId, let userId, let isAdmin, let version): + return ("updateChatParticipantAdmin", [("chatId", chatId), ("userId", userId), ("isAdmin", isAdmin), ("version", version)]) + case .updateNewStickerSet(let stickerset): + return ("updateNewStickerSet", [("stickerset", stickerset)]) + case .updateStickerSetsOrder(let flags, let order): + return ("updateStickerSetsOrder", [("flags", flags), ("order", order)]) + case .updateStickerSets: + return ("updateStickerSets", []) + case .updateSavedGifs: + return ("updateSavedGifs", []) + case .updateBotInlineQuery(let flags, let queryId, let userId, let query, let geo, let offset): + return ("updateBotInlineQuery", [("flags", flags), ("queryId", queryId), ("userId", userId), ("query", query), ("geo", geo), ("offset", offset)]) + case .updateBotInlineSend(let flags, let userId, let query, let geo, let id, let msgId): + return ("updateBotInlineSend", [("flags", flags), ("userId", userId), ("query", query), ("geo", geo), ("id", id), ("msgId", msgId)]) + case .updateEditChannelMessage(let message, let pts, let ptsCount): + return ("updateEditChannelMessage", [("message", message), ("pts", pts), ("ptsCount", ptsCount)]) + case .updateChannelPinnedMessage(let channelId, let id): + return ("updateChannelPinnedMessage", [("channelId", channelId), ("id", id)]) + case .updateBotCallbackQuery(let flags, let queryId, let userId, let peer, let msgId, let chatInstance, let data, let gameShortName): + return ("updateBotCallbackQuery", [("flags", flags), ("queryId", queryId), ("userId", userId), ("peer", peer), ("msgId", msgId), ("chatInstance", chatInstance), ("data", data), ("gameShortName", gameShortName)]) + case .updateEditMessage(let message, let pts, let ptsCount): + return ("updateEditMessage", [("message", message), ("pts", pts), ("ptsCount", ptsCount)]) + case .updateInlineBotCallbackQuery(let flags, let queryId, let userId, let msgId, let chatInstance, let data, let gameShortName): + return ("updateInlineBotCallbackQuery", [("flags", flags), ("queryId", queryId), ("userId", userId), ("msgId", msgId), ("chatInstance", chatInstance), ("data", data), ("gameShortName", gameShortName)]) + case .updateReadChannelOutbox(let channelId, let maxId): + return ("updateReadChannelOutbox", [("channelId", channelId), ("maxId", maxId)]) + case .updateDraftMessage(let peer, let draft): + return ("updateDraftMessage", [("peer", peer), ("draft", draft)]) + case .updateReadFeaturedStickers: + return ("updateReadFeaturedStickers", []) + case .updateRecentStickers: + return ("updateRecentStickers", []) + case .updateConfig: + return ("updateConfig", []) + case .updatePtsChanged: + return ("updatePtsChanged", []) + case .updateChannelWebPage(let channelId, let webpage, let pts, let ptsCount): + return ("updateChannelWebPage", [("channelId", channelId), ("webpage", webpage), ("pts", pts), ("ptsCount", ptsCount)]) + case .updateBotWebhookJSON(let data): + return ("updateBotWebhookJSON", [("data", data)]) + case .updateBotWebhookJSONQuery(let queryId, let data, let timeout): + return ("updateBotWebhookJSONQuery", [("queryId", queryId), ("data", data), ("timeout", timeout)]) + case .updateBotShippingQuery(let queryId, let userId, let payload, let shippingAddress): + return ("updateBotShippingQuery", [("queryId", queryId), ("userId", userId), ("payload", payload), ("shippingAddress", shippingAddress)]) + case .updateBotPrecheckoutQuery(let flags, let queryId, let userId, let payload, let info, let shippingOptionId, let currency, let totalAmount): + return ("updateBotPrecheckoutQuery", [("flags", flags), ("queryId", queryId), ("userId", userId), ("payload", payload), ("info", info), ("shippingOptionId", shippingOptionId), ("currency", currency), ("totalAmount", totalAmount)]) + case .updatePhoneCall(let phoneCall): + return ("updatePhoneCall", [("phoneCall", phoneCall)]) + case .updateLangPackTooLong: + return ("updateLangPackTooLong", []) + case .updateLangPack(let difference): + return ("updateLangPack", [("difference", difference)]) + case .updateFavedStickers: + return ("updateFavedStickers", []) + case .updateChannelReadMessagesContents(let channelId, let messages): + return ("updateChannelReadMessagesContents", [("channelId", channelId), ("messages", messages)]) + case .updateContactsReset: + return ("updateContactsReset", []) + case .updateChannelAvailableMessages(let channelId, let availableMinId): + return ("updateChannelAvailableMessages", [("channelId", channelId), ("availableMinId", availableMinId)]) + case .updateDialogPinned(let flags, let peer): + return ("updateDialogPinned", [("flags", flags), ("peer", peer)]) + case .updatePinnedDialogs(let flags, let order): + return ("updatePinnedDialogs", [("flags", flags), ("order", order)]) + } } static func parse_updateNewMessage(_ reader: BufferReader) -> Update? { @@ -4221,7 +4677,7 @@ extension Api { } } - enum PopularContact { + enum PopularContact: TypeConstructorDescription { case popularContact(clientId: Int64, importers: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -4234,6 +4690,13 @@ extension Api { serializeInt32(importers, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .popularContact(let clientId, let importers): + return ("popularContact", [("clientId", clientId), ("importers", importers)]) + } } static func parse_popularContact(_ reader: BufferReader) -> PopularContact? { @@ -4252,7 +4715,7 @@ extension Api { } } - enum ChannelParticipant { + enum ChannelParticipant: TypeConstructorDescription { case channelParticipant(userId: Int32, date: Int32) case channelParticipantSelf(userId: Int32, inviterId: Int32, date: Int32) case channelParticipantCreator(userId: Int32) @@ -4304,6 +4767,21 @@ extension Api { bannedRights.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .channelParticipant(let userId, let date): + return ("channelParticipant", [("userId", userId), ("date", date)]) + case .channelParticipantSelf(let userId, let inviterId, let date): + return ("channelParticipantSelf", [("userId", userId), ("inviterId", inviterId), ("date", date)]) + case .channelParticipantCreator(let userId): + return ("channelParticipantCreator", [("userId", userId)]) + case .channelParticipantAdmin(let flags, let userId, let inviterId, let promotedBy, let date, let adminRights): + return ("channelParticipantAdmin", [("flags", flags), ("userId", userId), ("inviterId", inviterId), ("promotedBy", promotedBy), ("date", date), ("adminRights", adminRights)]) + case .channelParticipantBanned(let flags, let userId, let kickedBy, let date, let bannedRights): + return ("channelParticipantBanned", [("flags", flags), ("userId", userId), ("kickedBy", kickedBy), ("date", date), ("bannedRights", bannedRights)]) + } } static func parse_channelParticipant(_ reader: BufferReader) -> ChannelParticipant? { @@ -4403,7 +4881,7 @@ extension Api { } } - enum InputDialogPeer { + enum InputDialogPeer: TypeConstructorDescription { case inputDialogPeer(peer: Api.InputPeer) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -4415,6 +4893,13 @@ extension Api { peer.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputDialogPeer(let peer): + return ("inputDialogPeer", [("peer", peer)]) + } } static func parse_inputDialogPeer(_ reader: BufferReader) -> InputDialogPeer? { @@ -4432,7 +4917,7 @@ extension Api { } } - enum Error { + enum Error: TypeConstructorDescription { case error(code: Int32, text: String) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -4445,6 +4930,13 @@ extension Api { serializeString(text, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .error(let code, let text): + return ("error", [("code", code), ("text", text)]) + } } static func parse_error(_ reader: BufferReader) -> Error? { @@ -4463,7 +4955,7 @@ extension Api { } } - enum KeyboardButton { + enum KeyboardButton: TypeConstructorDescription { case keyboardButton(text: String) case keyboardButtonUrl(text: String, url: String) case keyboardButtonCallback(text: String, data: Buffer) @@ -4528,6 +5020,27 @@ extension Api { serializeString(text, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .keyboardButton(let text): + return ("keyboardButton", [("text", text)]) + case .keyboardButtonUrl(let text, let url): + return ("keyboardButtonUrl", [("text", text), ("url", url)]) + case .keyboardButtonCallback(let text, let data): + return ("keyboardButtonCallback", [("text", text), ("data", data)]) + case .keyboardButtonRequestPhone(let text): + return ("keyboardButtonRequestPhone", [("text", text)]) + case .keyboardButtonRequestGeoLocation(let text): + return ("keyboardButtonRequestGeoLocation", [("text", text)]) + case .keyboardButtonSwitchInline(let flags, let text, let query): + return ("keyboardButtonSwitchInline", [("flags", flags), ("text", text), ("query", query)]) + case .keyboardButtonGame(let text): + return ("keyboardButtonGame", [("text", text)]) + case .keyboardButtonBuy(let text): + return ("keyboardButtonBuy", [("text", text)]) + } } static func parse_keyboardButton(_ reader: BufferReader) -> KeyboardButton? { @@ -4632,7 +5145,7 @@ extension Api { } } - enum ContactStatus { + enum ContactStatus: TypeConstructorDescription { case contactStatus(userId: Int32, status: Api.UserStatus) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -4645,6 +5158,13 @@ extension Api { status.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .contactStatus(let userId, let status): + return ("contactStatus", [("userId", userId), ("status", status)]) + } } static func parse_contactStatus(_ reader: BufferReader) -> ContactStatus? { @@ -4665,7 +5185,7 @@ extension Api { } } - enum PhotoSize { + enum PhotoSize: TypeConstructorDescription { case photoSizeEmpty(type: String) case photoSize(type: String, location: Api.FileLocation, w: Int32, h: Int32, size: Int32) case photoCachedSize(type: String, location: Api.FileLocation, w: Int32, h: Int32, bytes: Buffer) @@ -4699,6 +5219,17 @@ extension Api { serializeBytes(bytes, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .photoSizeEmpty(let type): + return ("photoSizeEmpty", [("type", type)]) + case .photoSize(let type, let location, let w, let h, let size): + return ("photoSize", [("type", type), ("location", location), ("w", w), ("h", h), ("size", size)]) + case .photoCachedSize(let type, let location, let w, let h, let bytes): + return ("photoCachedSize", [("type", type), ("location", location), ("w", w), ("h", h), ("bytes", bytes)]) + } } static func parse_photoSizeEmpty(_ reader: BufferReader) -> PhotoSize? { @@ -4764,7 +5295,7 @@ extension Api { } } - enum InlineBotSwitchPM { + enum InlineBotSwitchPM: TypeConstructorDescription { case inlineBotSwitchPM(text: String, startParam: String) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -4777,6 +5308,13 @@ extension Api { serializeString(startParam, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inlineBotSwitchPM(let text, let startParam): + return ("inlineBotSwitchPM", [("text", text), ("startParam", startParam)]) + } } static func parse_inlineBotSwitchPM(_ reader: BufferReader) -> InlineBotSwitchPM? { @@ -4795,7 +5333,7 @@ extension Api { } } - enum FileLocation { + enum FileLocation: TypeConstructorDescription { case fileLocationUnavailable(volumeId: Int64, localId: Int32, secret: Int64) case fileLocation(dcId: Int32, volumeId: Int64, localId: Int32, secret: Int64) @@ -4819,6 +5357,15 @@ extension Api { serializeInt64(secret, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .fileLocationUnavailable(let volumeId, let localId, let secret): + return ("fileLocationUnavailable", [("volumeId", volumeId), ("localId", localId), ("secret", secret)]) + case .fileLocation(let dcId, let volumeId, let localId, let secret): + return ("fileLocation", [("dcId", dcId), ("volumeId", volumeId), ("localId", localId), ("secret", secret)]) + } } static func parse_fileLocationUnavailable(_ reader: BufferReader) -> FileLocation? { @@ -4860,7 +5407,7 @@ extension Api { } } - enum InputNotifyPeer { + enum InputNotifyPeer: TypeConstructorDescription { case inputNotifyPeer(peer: Api.InputPeer) case inputNotifyUsers case inputNotifyChats @@ -4886,6 +5433,17 @@ extension Api { break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputNotifyPeer(let peer): + return ("inputNotifyPeer", [("peer", peer)]) + case .inputNotifyUsers: + return ("inputNotifyUsers", []) + case .inputNotifyChats: + return ("inputNotifyChats", []) + } } static func parse_inputNotifyPeer(_ reader: BufferReader) -> InputNotifyPeer? { @@ -4909,7 +5467,7 @@ extension Api { } } - enum EncryptedMessage { + enum EncryptedMessage: TypeConstructorDescription { case encryptedMessage(randomId: Int64, chatId: Int32, date: Int32, bytes: Buffer, file: Api.EncryptedFile) case encryptedMessageService(randomId: Int64, chatId: Int32, date: Int32, bytes: Buffer) @@ -4935,6 +5493,15 @@ extension Api { serializeBytes(bytes, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .encryptedMessage(let randomId, let chatId, let date, let bytes, let file): + return ("encryptedMessage", [("randomId", randomId), ("chatId", chatId), ("date", date), ("bytes", bytes), ("file", file)]) + case .encryptedMessageService(let randomId, let chatId, let date, let bytes): + return ("encryptedMessageService", [("randomId", randomId), ("chatId", chatId), ("date", date), ("bytes", bytes)]) + } } static func parse_encryptedMessage(_ reader: BufferReader) -> EncryptedMessage? { @@ -4984,7 +5551,7 @@ extension Api { } } - enum ChannelParticipantsFilter { + enum ChannelParticipantsFilter: TypeConstructorDescription { case channelParticipantsRecent case channelParticipantsAdmins case channelParticipantsBots @@ -5031,6 +5598,23 @@ extension Api { serializeString(q, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .channelParticipantsRecent: + return ("channelParticipantsRecent", []) + case .channelParticipantsAdmins: + return ("channelParticipantsAdmins", []) + case .channelParticipantsBots: + return ("channelParticipantsBots", []) + case .channelParticipantsBanned(let q): + return ("channelParticipantsBanned", [("q", q)]) + case .channelParticipantsSearch(let q): + return ("channelParticipantsSearch", [("q", q)]) + case .channelParticipantsKicked(let q): + return ("channelParticipantsKicked", [("q", q)]) + } } static func parse_channelParticipantsRecent(_ reader: BufferReader) -> ChannelParticipantsFilter? { @@ -5077,7 +5661,7 @@ extension Api { } } - enum WebPage { + enum WebPage: TypeConstructorDescription { case webPageEmpty(id: Int64) case webPagePending(id: Int64, date: Int32) case webPage(flags: Int32, id: Int64, url: String, displayUrl: String, hash: Int32, type: String?, siteName: String?, title: String?, description: String?, photo: Api.Photo?, embedUrl: String?, embedType: String?, embedWidth: Int32?, embedHeight: Int32?, duration: Int32?, author: String?, document: Api.Document?, cachedPage: Api.Page?) @@ -5128,6 +5712,19 @@ extension Api { break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .webPageEmpty(let id): + return ("webPageEmpty", [("id", id)]) + case .webPagePending(let id, let date): + return ("webPagePending", [("id", id), ("date", date)]) + case .webPage(let flags, let id, let url, let displayUrl, let hash, let type, let siteName, let title, let description, let photo, let embedUrl, let embedType, let embedWidth, let embedHeight, let duration, let author, let document, let cachedPage): + return ("webPage", [("flags", flags), ("id", id), ("url", url), ("displayUrl", displayUrl), ("hash", hash), ("type", type), ("siteName", siteName), ("title", title), ("description", description), ("photo", photo), ("embedUrl", embedUrl), ("embedType", embedType), ("embedWidth", embedWidth), ("embedHeight", embedHeight), ("duration", duration), ("author", author), ("document", document), ("cachedPage", cachedPage)]) + case .webPageNotModified: + return ("webPageNotModified", []) + } } static func parse_webPageEmpty(_ reader: BufferReader) -> WebPage? { @@ -5228,7 +5825,7 @@ extension Api { } } - enum InputBotInlineMessage { + enum InputBotInlineMessage: TypeConstructorDescription { case inputBotInlineMessageText(flags: Int32, message: String, entities: [Api.MessageEntity]?, replyMarkup: Api.ReplyMarkup?) case inputBotInlineMessageMediaGeo(flags: Int32, geoPoint: Api.InputGeoPoint, replyMarkup: Api.ReplyMarkup?) case inputBotInlineMessageMediaContact(flags: Int32, phoneNumber: String, firstName: String, lastName: String, replyMarkup: Api.ReplyMarkup?) @@ -5303,6 +5900,23 @@ extension Api { if Int(flags) & Int(1 << 2) != 0 {replyMarkup!.serialize(buffer, true)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputBotInlineMessageText(let flags, let message, let entities, let replyMarkup): + return ("inputBotInlineMessageText", [("flags", flags), ("message", message), ("entities", entities), ("replyMarkup", replyMarkup)]) + case .inputBotInlineMessageMediaGeo(let flags, let geoPoint, let replyMarkup): + return ("inputBotInlineMessageMediaGeo", [("flags", flags), ("geoPoint", geoPoint), ("replyMarkup", replyMarkup)]) + case .inputBotInlineMessageMediaContact(let flags, let phoneNumber, let firstName, let lastName, let replyMarkup): + return ("inputBotInlineMessageMediaContact", [("flags", flags), ("phoneNumber", phoneNumber), ("firstName", firstName), ("lastName", lastName), ("replyMarkup", replyMarkup)]) + case .inputBotInlineMessageGame(let flags, let replyMarkup): + return ("inputBotInlineMessageGame", [("flags", flags), ("replyMarkup", replyMarkup)]) + case .inputBotInlineMessageMediaAuto(let flags, let message, let entities, let replyMarkup): + return ("inputBotInlineMessageMediaAuto", [("flags", flags), ("message", message), ("entities", entities), ("replyMarkup", replyMarkup)]) + case .inputBotInlineMessageMediaVenue(let flags, let geoPoint, let title, let address, let provider, let venueId, let venueType, let replyMarkup): + return ("inputBotInlineMessageMediaVenue", [("flags", flags), ("geoPoint", geoPoint), ("title", title), ("address", address), ("provider", provider), ("venueId", venueId), ("venueType", venueType), ("replyMarkup", replyMarkup)]) + } } static func parse_inputBotInlineMessageText(_ reader: BufferReader) -> InputBotInlineMessage? { @@ -5453,7 +6067,7 @@ extension Api { } } - enum KeyboardButtonRow { + enum KeyboardButtonRow: TypeConstructorDescription { case keyboardButtonRow(buttons: [Api.KeyboardButton]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -5469,6 +6083,13 @@ extension Api { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .keyboardButtonRow(let buttons): + return ("keyboardButtonRow", [("buttons", buttons)]) + } } static func parse_keyboardButtonRow(_ reader: BufferReader) -> KeyboardButtonRow? { @@ -5486,7 +6107,7 @@ extension Api { } } - enum StickerSet { + enum StickerSet: TypeConstructorDescription { case stickerSet(flags: Int32, installedDate: Int32?, id: Int64, accessHash: Int64, title: String, shortName: String, count: Int32, hash: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -5505,6 +6126,13 @@ extension Api { serializeInt32(hash, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .stickerSet(let flags, let installedDate, let id, let accessHash, let title, let shortName, let count, let hash): + return ("stickerSet", [("flags", flags), ("installedDate", installedDate), ("id", id), ("accessHash", accessHash), ("title", title), ("shortName", shortName), ("count", count), ("hash", hash)]) + } } static func parse_stickerSet(_ reader: BufferReader) -> StickerSet? { @@ -5541,7 +6169,7 @@ extension Api { } } - enum InputContact { + enum InputContact: TypeConstructorDescription { case inputPhoneContact(clientId: Int64, phone: String, firstName: String, lastName: String) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -5556,6 +6184,13 @@ extension Api { serializeString(lastName, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputPhoneContact(let clientId, let phone, let firstName, let lastName): + return ("inputPhoneContact", [("clientId", clientId), ("phone", phone), ("firstName", firstName), ("lastName", lastName)]) + } } static func parse_inputPhoneContact(_ reader: BufferReader) -> InputContact? { @@ -5580,7 +6215,7 @@ extension Api { } } - enum TopPeerCategory { + enum TopPeerCategory: TypeConstructorDescription { case topPeerCategoryBotsPM case topPeerCategoryBotsInline case topPeerCategoryCorrespondents @@ -5627,6 +6262,23 @@ extension Api { break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .topPeerCategoryBotsPM: + return ("topPeerCategoryBotsPM", []) + case .topPeerCategoryBotsInline: + return ("topPeerCategoryBotsInline", []) + case .topPeerCategoryCorrespondents: + return ("topPeerCategoryCorrespondents", []) + case .topPeerCategoryGroups: + return ("topPeerCategoryGroups", []) + case .topPeerCategoryChannels: + return ("topPeerCategoryChannels", []) + case .topPeerCategoryPhoneCalls: + return ("topPeerCategoryPhoneCalls", []) + } } static func parse_topPeerCategoryBotsPM(_ reader: BufferReader) -> TopPeerCategory? { @@ -5649,7 +6301,7 @@ extension Api { } } - enum ChannelMessagesFilter { + enum ChannelMessagesFilter: TypeConstructorDescription { case channelMessagesFilterEmpty case channelMessagesFilter(flags: Int32, ranges: [Api.MessageRange]) @@ -5673,6 +6325,15 @@ extension Api { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .channelMessagesFilterEmpty: + return ("channelMessagesFilterEmpty", []) + case .channelMessagesFilter(let flags, let ranges): + return ("channelMessagesFilter", [("flags", flags), ("ranges", ranges)]) + } } static func parse_channelMessagesFilterEmpty(_ reader: BufferReader) -> ChannelMessagesFilter? { @@ -5696,7 +6357,7 @@ extension Api { } } - enum InputDocument { + enum InputDocument: TypeConstructorDescription { case inputDocumentEmpty case inputDocument(id: Int64, accessHash: Int64) @@ -5716,6 +6377,15 @@ extension Api { serializeInt64(accessHash, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputDocumentEmpty: + return ("inputDocumentEmpty", []) + case .inputDocument(let id, let accessHash): + return ("inputDocument", [("id", id), ("accessHash", accessHash)]) + } } static func parse_inputDocumentEmpty(_ reader: BufferReader) -> InputDocument? { @@ -5737,7 +6407,7 @@ extension Api { } } - enum InputMedia { + enum InputMedia: TypeConstructorDescription { case inputMediaEmpty case inputMediaGeoPoint(geoPoint: Api.InputGeoPoint) case inputMediaContact(phoneNumber: String, firstName: String, lastName: String) @@ -5886,6 +6556,39 @@ extension Api { if Int(flags) & Int(1 << 0) != 0 {serializeInt32(ttlSeconds!, buffer: buffer, boxed: false)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputMediaEmpty: + return ("inputMediaEmpty", []) + case .inputMediaGeoPoint(let geoPoint): + return ("inputMediaGeoPoint", [("geoPoint", geoPoint)]) + case .inputMediaContact(let phoneNumber, let firstName, let lastName): + return ("inputMediaContact", [("phoneNumber", phoneNumber), ("firstName", firstName), ("lastName", lastName)]) + case .inputMediaGifExternal(let url, let q): + return ("inputMediaGifExternal", [("url", url), ("q", q)]) + case .inputMediaGame(let id): + return ("inputMediaGame", [("id", id)]) + case .inputMediaGeoLive(let geoPoint, let period): + return ("inputMediaGeoLive", [("geoPoint", geoPoint), ("period", period)]) + case .inputMediaVenue(let geoPoint, let title, let address, let provider, let venueId, let venueType): + return ("inputMediaVenue", [("geoPoint", geoPoint), ("title", title), ("address", address), ("provider", provider), ("venueId", venueId), ("venueType", venueType)]) + case .inputMediaInvoice(let flags, let title, let description, let photo, let invoice, let payload, let provider, let providerData, let startParam): + return ("inputMediaInvoice", [("flags", flags), ("title", title), ("description", description), ("photo", photo), ("invoice", invoice), ("payload", payload), ("provider", provider), ("providerData", providerData), ("startParam", startParam)]) + case .inputMediaUploadedPhoto(let flags, let file, let stickers, let ttlSeconds): + return ("inputMediaUploadedPhoto", [("flags", flags), ("file", file), ("stickers", stickers), ("ttlSeconds", ttlSeconds)]) + case .inputMediaUploadedDocument(let flags, let file, let thumb, let mimeType, let attributes, let stickers, let ttlSeconds): + return ("inputMediaUploadedDocument", [("flags", flags), ("file", file), ("thumb", thumb), ("mimeType", mimeType), ("attributes", attributes), ("stickers", stickers), ("ttlSeconds", ttlSeconds)]) + case .inputMediaPhoto(let flags, let id, let ttlSeconds): + return ("inputMediaPhoto", [("flags", flags), ("id", id), ("ttlSeconds", ttlSeconds)]) + case .inputMediaDocument(let flags, let id, let ttlSeconds): + return ("inputMediaDocument", [("flags", flags), ("id", id), ("ttlSeconds", ttlSeconds)]) + case .inputMediaPhotoExternal(let flags, let url, let ttlSeconds): + return ("inputMediaPhotoExternal", [("flags", flags), ("url", url), ("ttlSeconds", ttlSeconds)]) + case .inputMediaDocumentExternal(let flags, let url, let ttlSeconds): + return ("inputMediaDocumentExternal", [("flags", flags), ("url", url), ("ttlSeconds", ttlSeconds)]) + } } static func parse_inputMediaEmpty(_ reader: BufferReader) -> InputMedia? { @@ -6168,7 +6871,7 @@ extension Api { } } - enum InputPeer { + enum InputPeer: TypeConstructorDescription { case inputPeerEmpty case inputPeerSelf case inputPeerChat(chatId: Int32) @@ -6210,6 +6913,21 @@ extension Api { serializeInt64(accessHash, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputPeerEmpty: + return ("inputPeerEmpty", []) + case .inputPeerSelf: + return ("inputPeerSelf", []) + case .inputPeerChat(let chatId): + return ("inputPeerChat", [("chatId", chatId)]) + case .inputPeerUser(let userId, let accessHash): + return ("inputPeerUser", [("userId", userId), ("accessHash", accessHash)]) + case .inputPeerChannel(let channelId, let accessHash): + return ("inputPeerChannel", [("channelId", channelId), ("accessHash", accessHash)]) + } } static func parse_inputPeerEmpty(_ reader: BufferReader) -> InputPeer? { @@ -6259,7 +6977,7 @@ extension Api { } } - enum Contact { + enum Contact: TypeConstructorDescription { case contact(userId: Int32, mutual: Api.Bool) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -6272,6 +6990,13 @@ extension Api { mutual.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .contact(let userId, let mutual): + return ("contact", [("userId", userId), ("mutual", mutual)]) + } } static func parse_contact(_ reader: BufferReader) -> Contact? { @@ -6292,7 +7017,7 @@ extension Api { } } - enum FileHash { + enum FileHash: TypeConstructorDescription { case fileHash(offset: Int32, limit: Int32, hash: Buffer) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -6306,6 +7031,13 @@ extension Api { serializeBytes(hash, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .fileHash(let offset, let limit, let hash): + return ("fileHash", [("offset", offset), ("limit", limit), ("hash", hash)]) + } } static func parse_fileHash(_ reader: BufferReader) -> FileHash? { @@ -6327,7 +7059,7 @@ extension Api { } } - enum BotInlineResult { + enum BotInlineResult: TypeConstructorDescription { case botInlineMediaResult(flags: Int32, id: String, type: String, photo: Api.Photo?, document: Api.Document?, title: String?, description: String?, sendMessage: Api.BotInlineMessage) case botInlineResult(flags: Int32, id: String, type: String, title: String?, description: String?, url: String?, thumb: Api.WebDocument?, content: Api.WebDocument?, sendMessage: Api.BotInlineMessage) @@ -6361,6 +7093,15 @@ extension Api { sendMessage.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .botInlineMediaResult(let flags, let id, let type, let photo, let document, let title, let description, let sendMessage): + return ("botInlineMediaResult", [("flags", flags), ("id", id), ("type", type), ("photo", photo), ("document", document), ("title", title), ("description", description), ("sendMessage", sendMessage)]) + case .botInlineResult(let flags, let id, let type, let title, let description, let url, let thumb, let content, let sendMessage): + return ("botInlineResult", [("flags", flags), ("id", id), ("type", type), ("title", title), ("description", description), ("url", url), ("thumb", thumb), ("content", content), ("sendMessage", sendMessage)]) + } } static func parse_botInlineMediaResult(_ reader: BufferReader) -> BotInlineResult? { @@ -6444,7 +7185,7 @@ extension Api { } } - enum InputSingleMedia { + enum InputSingleMedia: TypeConstructorDescription { case inputSingleMedia(flags: Int32, media: Api.InputMedia, randomId: Int64, message: String, entities: [Api.MessageEntity]?) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -6464,6 +7205,13 @@ extension Api { }} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputSingleMedia(let flags, let media, let randomId, let message, let entities): + return ("inputSingleMedia", [("flags", flags), ("media", media), ("randomId", randomId), ("message", message), ("entities", entities)]) + } } static func parse_inputSingleMedia(_ reader: BufferReader) -> InputSingleMedia? { @@ -6495,7 +7243,7 @@ extension Api { } } - enum InputPrivacyRule { + enum InputPrivacyRule: TypeConstructorDescription { case inputPrivacyValueAllowContacts case inputPrivacyValueAllowAll case inputPrivacyValueAllowUsers(users: [Api.InputUser]) @@ -6550,6 +7298,23 @@ extension Api { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputPrivacyValueAllowContacts: + return ("inputPrivacyValueAllowContacts", []) + case .inputPrivacyValueAllowAll: + return ("inputPrivacyValueAllowAll", []) + case .inputPrivacyValueAllowUsers(let users): + return ("inputPrivacyValueAllowUsers", [("users", users)]) + case .inputPrivacyValueDisallowContacts: + return ("inputPrivacyValueDisallowContacts", []) + case .inputPrivacyValueDisallowAll: + return ("inputPrivacyValueDisallowAll", []) + case .inputPrivacyValueDisallowUsers(let users): + return ("inputPrivacyValueDisallowUsers", [("users", users)]) + } } static func parse_inputPrivacyValueAllowContacts(_ reader: BufferReader) -> InputPrivacyRule? { @@ -6592,7 +7357,7 @@ extension Api { } } - enum ChannelAdminLogEventAction { + enum ChannelAdminLogEventAction: TypeConstructorDescription { case channelAdminLogEventActionChangeTitle(prevValue: String, newValue: String) case channelAdminLogEventActionChangeAbout(prevValue: String, newValue: String) case channelAdminLogEventActionChangeUsername(prevValue: String, newValue: String) @@ -6717,6 +7482,43 @@ extension Api { newValue.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .channelAdminLogEventActionChangeTitle(let prevValue, let newValue): + return ("channelAdminLogEventActionChangeTitle", [("prevValue", prevValue), ("newValue", newValue)]) + case .channelAdminLogEventActionChangeAbout(let prevValue, let newValue): + return ("channelAdminLogEventActionChangeAbout", [("prevValue", prevValue), ("newValue", newValue)]) + case .channelAdminLogEventActionChangeUsername(let prevValue, let newValue): + return ("channelAdminLogEventActionChangeUsername", [("prevValue", prevValue), ("newValue", newValue)]) + case .channelAdminLogEventActionChangePhoto(let prevPhoto, let newPhoto): + return ("channelAdminLogEventActionChangePhoto", [("prevPhoto", prevPhoto), ("newPhoto", newPhoto)]) + case .channelAdminLogEventActionToggleInvites(let newValue): + return ("channelAdminLogEventActionToggleInvites", [("newValue", newValue)]) + case .channelAdminLogEventActionToggleSignatures(let newValue): + return ("channelAdminLogEventActionToggleSignatures", [("newValue", newValue)]) + case .channelAdminLogEventActionUpdatePinned(let message): + return ("channelAdminLogEventActionUpdatePinned", [("message", message)]) + case .channelAdminLogEventActionEditMessage(let prevMessage, let newMessage): + return ("channelAdminLogEventActionEditMessage", [("prevMessage", prevMessage), ("newMessage", newMessage)]) + case .channelAdminLogEventActionDeleteMessage(let message): + return ("channelAdminLogEventActionDeleteMessage", [("message", message)]) + case .channelAdminLogEventActionParticipantJoin: + return ("channelAdminLogEventActionParticipantJoin", []) + case .channelAdminLogEventActionParticipantLeave: + return ("channelAdminLogEventActionParticipantLeave", []) + case .channelAdminLogEventActionParticipantInvite(let participant): + return ("channelAdminLogEventActionParticipantInvite", [("participant", participant)]) + case .channelAdminLogEventActionParticipantToggleBan(let prevParticipant, let newParticipant): + return ("channelAdminLogEventActionParticipantToggleBan", [("prevParticipant", prevParticipant), ("newParticipant", newParticipant)]) + case .channelAdminLogEventActionParticipantToggleAdmin(let prevParticipant, let newParticipant): + return ("channelAdminLogEventActionParticipantToggleAdmin", [("prevParticipant", prevParticipant), ("newParticipant", newParticipant)]) + case .channelAdminLogEventActionChangeStickerSet(let prevStickerset, let newStickerset): + return ("channelAdminLogEventActionChangeStickerSet", [("prevStickerset", prevStickerset), ("newStickerset", newStickerset)]) + case .channelAdminLogEventActionTogglePreHistoryHidden(let newValue): + return ("channelAdminLogEventActionTogglePreHistoryHidden", [("newValue", newValue)]) + } } static func parse_channelAdminLogEventActionChangeTitle(_ reader: BufferReader) -> ChannelAdminLogEventAction? { @@ -6937,7 +7739,7 @@ extension Api { } } - enum LabeledPrice { + enum LabeledPrice: TypeConstructorDescription { case labeledPrice(label: String, amount: Int64) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -6950,6 +7752,13 @@ extension Api { serializeInt64(amount, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .labeledPrice(let label, let amount): + return ("labeledPrice", [("label", label), ("amount", amount)]) + } } static func parse_labeledPrice(_ reader: BufferReader) -> LabeledPrice? { @@ -6968,7 +7777,7 @@ extension Api { } } - enum ReportReason { + enum ReportReason: TypeConstructorDescription { case inputReportReasonSpam case inputReportReasonViolence case inputReportReasonPornography @@ -7001,6 +7810,19 @@ extension Api { serializeString(text, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputReportReasonSpam: + return ("inputReportReasonSpam", []) + case .inputReportReasonViolence: + return ("inputReportReasonViolence", []) + case .inputReportReasonPornography: + return ("inputReportReasonPornography", []) + case .inputReportReasonOther(let text): + return ("inputReportReasonOther", [("text", text)]) + } } static func parse_inputReportReasonSpam(_ reader: BufferReader) -> ReportReason? { @@ -7025,7 +7847,7 @@ extension Api { } } - enum InputEncryptedChat { + enum InputEncryptedChat: TypeConstructorDescription { case inputEncryptedChat(chatId: Int32, accessHash: Int64) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -7038,6 +7860,13 @@ extension Api { serializeInt64(accessHash, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputEncryptedChat(let chatId, let accessHash): + return ("inputEncryptedChat", [("chatId", chatId), ("accessHash", accessHash)]) + } } static func parse_inputEncryptedChat(_ reader: BufferReader) -> InputEncryptedChat? { @@ -7056,7 +7885,7 @@ extension Api { } } - enum DraftMessage { + enum DraftMessage: TypeConstructorDescription { case draftMessageEmpty case draftMessage(flags: Int32, replyToMsgId: Int32?, message: String, entities: [Api.MessageEntity]?, date: Int32) @@ -7083,6 +7912,15 @@ extension Api { serializeInt32(date, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .draftMessageEmpty: + return ("draftMessageEmpty", []) + case .draftMessage(let flags, let replyToMsgId, let message, let entities, let date): + return ("draftMessage", [("flags", flags), ("replyToMsgId", replyToMsgId), ("message", message), ("entities", entities), ("date", date)]) + } } static func parse_draftMessageEmpty(_ reader: BufferReader) -> DraftMessage? { @@ -7115,7 +7953,7 @@ extension Api { } } - enum ChannelAdminRights { + enum ChannelAdminRights: TypeConstructorDescription { case channelAdminRights(flags: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -7127,6 +7965,13 @@ extension Api { serializeInt32(flags, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .channelAdminRights(let flags): + return ("channelAdminRights", [("flags", flags)]) + } } static func parse_channelAdminRights(_ reader: BufferReader) -> ChannelAdminRights? { @@ -7142,7 +7987,7 @@ extension Api { } } - enum EncryptedFile { + enum EncryptedFile: TypeConstructorDescription { case encryptedFileEmpty case encryptedFile(id: Int64, accessHash: Int64, size: Int32, dcId: Int32, keyFingerprint: Int32) @@ -7165,6 +8010,15 @@ extension Api { serializeInt32(keyFingerprint, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .encryptedFileEmpty: + return ("encryptedFileEmpty", []) + case .encryptedFile(let id, let accessHash, let size, let dcId, let keyFingerprint): + return ("encryptedFile", [("id", id), ("accessHash", accessHash), ("size", size), ("dcId", dcId), ("keyFingerprint", keyFingerprint)]) + } } static func parse_encryptedFileEmpty(_ reader: BufferReader) -> EncryptedFile? { @@ -7195,7 +8049,7 @@ extension Api { } } - enum ChannelBannedRights { + enum ChannelBannedRights: TypeConstructorDescription { case channelBannedRights(flags: Int32, untilDate: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -7208,6 +8062,13 @@ extension Api { serializeInt32(untilDate, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .channelBannedRights(let flags, let untilDate): + return ("channelBannedRights", [("flags", flags), ("untilDate", untilDate)]) + } } static func parse_channelBannedRights(_ reader: BufferReader) -> ChannelBannedRights? { @@ -7226,7 +8087,7 @@ extension Api { } } - enum NotifyPeer { + enum NotifyPeer: TypeConstructorDescription { case notifyPeer(peer: Api.Peer) case notifyUsers case notifyChats @@ -7252,6 +8113,17 @@ extension Api { break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .notifyPeer(let peer): + return ("notifyPeer", [("peer", peer)]) + case .notifyUsers: + return ("notifyUsers", []) + case .notifyChats: + return ("notifyChats", []) + } } static func parse_notifyPeer(_ reader: BufferReader) -> NotifyPeer? { @@ -7275,7 +8147,7 @@ extension Api { } } - enum InputPrivacyKey { + enum InputPrivacyKey: TypeConstructorDescription { case inputPrivacyKeyStatusTimestamp case inputPrivacyKeyChatInvite case inputPrivacyKeyPhoneCall @@ -7301,6 +8173,17 @@ extension Api { break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputPrivacyKeyStatusTimestamp: + return ("inputPrivacyKeyStatusTimestamp", []) + case .inputPrivacyKeyChatInvite: + return ("inputPrivacyKeyChatInvite", []) + case .inputPrivacyKeyPhoneCall: + return ("inputPrivacyKeyPhoneCall", []) + } } static func parse_inputPrivacyKeyStatusTimestamp(_ reader: BufferReader) -> InputPrivacyKey? { @@ -7314,7 +8197,7 @@ extension Api { } } - enum ReplyMarkup { + enum ReplyMarkup: TypeConstructorDescription { case replyKeyboardHide(flags: Int32) case replyKeyboardForceReply(flags: Int32) case replyKeyboardMarkup(flags: Int32, rows: [Api.KeyboardButtonRow]) @@ -7356,6 +8239,19 @@ extension Api { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .replyKeyboardHide(let flags): + return ("replyKeyboardHide", [("flags", flags)]) + case .replyKeyboardForceReply(let flags): + return ("replyKeyboardForceReply", [("flags", flags)]) + case .replyKeyboardMarkup(let flags, let rows): + return ("replyKeyboardMarkup", [("flags", flags), ("rows", rows)]) + case .replyInlineMarkup(let rows): + return ("replyInlineMarkup", [("rows", rows)]) + } } static func parse_replyKeyboardHide(_ reader: BufferReader) -> ReplyMarkup? { @@ -7411,7 +8307,7 @@ extension Api { } } - enum HighScore { + enum HighScore: TypeConstructorDescription { case highScore(pos: Int32, userId: Int32, score: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -7425,6 +8321,13 @@ extension Api { serializeInt32(score, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .highScore(let pos, let userId, let score): + return ("highScore", [("pos", pos), ("userId", userId), ("score", score)]) + } } static func parse_highScore(_ reader: BufferReader) -> HighScore? { @@ -7446,7 +8349,7 @@ extension Api { } } - enum TopPeer { + enum TopPeer: TypeConstructorDescription { case topPeer(peer: Api.Peer, rating: Double) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -7459,6 +8362,13 @@ extension Api { serializeDouble(rating, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .topPeer(let peer, let rating): + return ("topPeer", [("peer", peer), ("rating", rating)]) + } } static func parse_topPeer(_ reader: BufferReader) -> TopPeer? { @@ -7479,7 +8389,7 @@ extension Api { } } - enum ContactBlocked { + enum ContactBlocked: TypeConstructorDescription { case contactBlocked(userId: Int32, date: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -7492,6 +8402,13 @@ extension Api { serializeInt32(date, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .contactBlocked(let userId, let date): + return ("contactBlocked", [("userId", userId), ("date", date)]) + } } static func parse_contactBlocked(_ reader: BufferReader) -> ContactBlocked? { @@ -7510,7 +8427,7 @@ extension Api { } } - enum InputUser { + enum InputUser: TypeConstructorDescription { case inputUserEmpty case inputUserSelf case inputUser(userId: Int32, accessHash: Int64) @@ -7537,6 +8454,17 @@ extension Api { serializeInt64(accessHash, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputUserEmpty: + return ("inputUserEmpty", []) + case .inputUserSelf: + return ("inputUserSelf", []) + case .inputUser(let userId, let accessHash): + return ("inputUser", [("userId", userId), ("accessHash", accessHash)]) + } } static func parse_inputUserEmpty(_ reader: BufferReader) -> InputUser? { @@ -7561,7 +8489,7 @@ extension Api { } } - enum Page { + enum Page: TypeConstructorDescription { case pagePart(blocks: [Api.PageBlock], photos: [Api.Photo], documents: [Api.Document]) case pageFull(blocks: [Api.PageBlock], photos: [Api.Photo], documents: [Api.Document]) @@ -7608,6 +8536,15 @@ extension Api { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .pagePart(let blocks, let photos, let documents): + return ("pagePart", [("blocks", blocks), ("photos", photos), ("documents", documents)]) + case .pageFull(let blocks, let photos, let documents): + return ("pageFull", [("blocks", blocks), ("photos", photos), ("documents", documents)]) + } } static func parse_pagePart(_ reader: BufferReader) -> Page? { @@ -7658,7 +8595,7 @@ extension Api { } } - enum MessageRange { + enum MessageRange: TypeConstructorDescription { case messageRange(minId: Int32, maxId: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -7671,6 +8608,13 @@ extension Api { serializeInt32(maxId, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .messageRange(let minId, let maxId): + return ("messageRange", [("minId", minId), ("maxId", maxId)]) + } } static func parse_messageRange(_ reader: BufferReader) -> MessageRange? { @@ -7689,7 +8633,7 @@ extension Api { } } - enum Config { + enum Config: TypeConstructorDescription { case config(flags: Int32, date: Int32, expires: Int32, testMode: Api.Bool, thisDc: Int32, dcOptions: [Api.DcOption], chatSizeMax: Int32, megagroupSizeMax: Int32, forwardedCountMax: Int32, onlineUpdatePeriodMs: Int32, offlineBlurTimeoutMs: Int32, offlineIdleTimeoutMs: Int32, onlineCloudTimeoutMs: Int32, notifyCloudDelayMs: Int32, notifyDefaultDelayMs: Int32, pushChatPeriodMs: Int32, pushChatLimit: Int32, savedGifsLimit: Int32, editTimeLimit: Int32, revokeTimeLimit: Int32, revokePmTimeLimit: Int32, ratingEDecay: Int32, stickersRecentLimit: Int32, stickersFavedLimit: Int32, channelsReadMediaPeriod: Int32, tmpSessions: Int32?, pinnedDialogsCountMax: Int32, callReceiveTimeoutMs: Int32, callRingTimeoutMs: Int32, callConnectTimeoutMs: Int32, callPacketTimeoutMs: Int32, meUrlPrefix: String, autoupdateUrlPrefix: String?, suggestedLangCode: String?, langPackVersion: Int32?) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -7739,6 +8683,13 @@ extension Api { if Int(flags) & Int(1 << 2) != 0 {serializeInt32(langPackVersion!, buffer: buffer, boxed: false)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .config(let flags, let date, let expires, let testMode, let thisDc, let dcOptions, let chatSizeMax, let megagroupSizeMax, let forwardedCountMax, let onlineUpdatePeriodMs, let offlineBlurTimeoutMs, let offlineIdleTimeoutMs, let onlineCloudTimeoutMs, let notifyCloudDelayMs, let notifyDefaultDelayMs, let pushChatPeriodMs, let pushChatLimit, let savedGifsLimit, let editTimeLimit, let revokeTimeLimit, let revokePmTimeLimit, let ratingEDecay, let stickersRecentLimit, let stickersFavedLimit, let channelsReadMediaPeriod, let tmpSessions, let pinnedDialogsCountMax, let callReceiveTimeoutMs, let callRingTimeoutMs, let callConnectTimeoutMs, let callPacketTimeoutMs, let meUrlPrefix, let autoupdateUrlPrefix, let suggestedLangCode, let langPackVersion): + return ("config", [("flags", flags), ("date", date), ("expires", expires), ("testMode", testMode), ("thisDc", thisDc), ("dcOptions", dcOptions), ("chatSizeMax", chatSizeMax), ("megagroupSizeMax", megagroupSizeMax), ("forwardedCountMax", forwardedCountMax), ("onlineUpdatePeriodMs", onlineUpdatePeriodMs), ("offlineBlurTimeoutMs", offlineBlurTimeoutMs), ("offlineIdleTimeoutMs", offlineIdleTimeoutMs), ("onlineCloudTimeoutMs", onlineCloudTimeoutMs), ("notifyCloudDelayMs", notifyCloudDelayMs), ("notifyDefaultDelayMs", notifyDefaultDelayMs), ("pushChatPeriodMs", pushChatPeriodMs), ("pushChatLimit", pushChatLimit), ("savedGifsLimit", savedGifsLimit), ("editTimeLimit", editTimeLimit), ("revokeTimeLimit", revokeTimeLimit), ("revokePmTimeLimit", revokePmTimeLimit), ("ratingEDecay", ratingEDecay), ("stickersRecentLimit", stickersRecentLimit), ("stickersFavedLimit", stickersFavedLimit), ("channelsReadMediaPeriod", channelsReadMediaPeriod), ("tmpSessions", tmpSessions), ("pinnedDialogsCountMax", pinnedDialogsCountMax), ("callReceiveTimeoutMs", callReceiveTimeoutMs), ("callRingTimeoutMs", callRingTimeoutMs), ("callConnectTimeoutMs", callConnectTimeoutMs), ("callPacketTimeoutMs", callPacketTimeoutMs), ("meUrlPrefix", meUrlPrefix), ("autoupdateUrlPrefix", autoupdateUrlPrefix), ("suggestedLangCode", suggestedLangCode), ("langPackVersion", langPackVersion)]) + } } static func parse_config(_ reader: BufferReader) -> Config? { @@ -7860,7 +8811,7 @@ extension Api { } } - enum TopPeerCategoryPeers { + enum TopPeerCategoryPeers: TypeConstructorDescription { case topPeerCategoryPeers(category: Api.TopPeerCategory, count: Int32, peers: [Api.TopPeer]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -7878,6 +8829,13 @@ extension Api { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .topPeerCategoryPeers(let category, let count, let peers): + return ("topPeerCategoryPeers", [("category", category), ("count", count), ("peers", peers)]) + } } static func parse_topPeerCategoryPeers(_ reader: BufferReader) -> TopPeerCategoryPeers? { @@ -7903,7 +8861,7 @@ extension Api { } } - enum Game { + enum Game: TypeConstructorDescription { case game(flags: Int32, id: Int64, accessHash: Int64, shortName: String, title: String, description: String, photo: Api.Photo, document: Api.Document?) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -7922,6 +8880,13 @@ extension Api { if Int(flags) & Int(1 << 0) != 0 {document!.serialize(buffer, true)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .game(let flags, let id, let accessHash, let shortName, let title, let description, let photo, let document): + return ("game", [("flags", flags), ("id", id), ("accessHash", accessHash), ("shortName", shortName), ("title", title), ("description", description), ("photo", photo), ("document", document)]) + } } static func parse_game(_ reader: BufferReader) -> Game? { @@ -7962,7 +8927,7 @@ extension Api { } } - enum BotCommand { + enum BotCommand: TypeConstructorDescription { case botCommand(command: String, description: String) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -7975,6 +8940,13 @@ extension Api { serializeString(description, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .botCommand(let command, let description): + return ("botCommand", [("command", command), ("description", description)]) + } } static func parse_botCommand(_ reader: BufferReader) -> BotCommand? { @@ -7993,7 +8965,7 @@ extension Api { } } - enum CdnPublicKey { + enum CdnPublicKey: TypeConstructorDescription { case cdnPublicKey(dcId: Int32, publicKey: String) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -8006,6 +8978,13 @@ extension Api { serializeString(publicKey, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .cdnPublicKey(let dcId, let publicKey): + return ("cdnPublicKey", [("dcId", dcId), ("publicKey", publicKey)]) + } } static func parse_cdnPublicKey(_ reader: BufferReader) -> CdnPublicKey? { @@ -8024,7 +9003,7 @@ extension Api { } } - enum InputGame { + enum InputGame: TypeConstructorDescription { case inputGameID(id: Int64, accessHash: Int64) case inputGameShortName(botId: Api.InputUser, shortName: String) @@ -8045,6 +9024,15 @@ extension Api { serializeString(shortName, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputGameID(let id, let accessHash): + return ("inputGameID", [("id", id), ("accessHash", accessHash)]) + case .inputGameShortName(let botId, let shortName): + return ("inputGameShortName", [("botId", botId), ("shortName", shortName)]) + } } static func parse_inputGameID(_ reader: BufferReader) -> InputGame? { @@ -8079,7 +9067,7 @@ extension Api { } } - enum InputMessage { + enum InputMessage: TypeConstructorDescription { case inputMessageID(id: Int32) case inputMessageReplyTo(id: Int32) case inputMessagePinned @@ -8105,6 +9093,17 @@ extension Api { break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputMessageID(let id): + return ("inputMessageID", [("id", id)]) + case .inputMessageReplyTo(let id): + return ("inputMessageReplyTo", [("id", id)]) + case .inputMessagePinned: + return ("inputMessagePinned", []) + } } static func parse_inputMessageID(_ reader: BufferReader) -> InputMessage? { @@ -8134,7 +9133,7 @@ extension Api { } } - enum PhoneCallProtocol { + enum PhoneCallProtocol: TypeConstructorDescription { case phoneCallProtocol(flags: Int32, minLayer: Int32, maxLayer: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -8148,6 +9147,13 @@ extension Api { serializeInt32(maxLayer, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .phoneCallProtocol(let flags, let minLayer, let maxLayer): + return ("phoneCallProtocol", [("flags", flags), ("minLayer", minLayer), ("maxLayer", maxLayer)]) + } } static func parse_phoneCallProtocol(_ reader: BufferReader) -> PhoneCallProtocol? { @@ -8169,7 +9175,7 @@ extension Api { } } - enum WallPaper { + enum WallPaper: TypeConstructorDescription { case wallPaper(id: Int32, title: String, sizes: [Api.PhotoSize], color: Int32) case wallPaperSolid(id: Int32, title: String, bgColor: Int32, color: Int32) @@ -8198,6 +9204,15 @@ extension Api { serializeInt32(color, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .wallPaper(let id, let title, let sizes, let color): + return ("wallPaper", [("id", id), ("title", title), ("sizes", sizes), ("color", color)]) + case .wallPaperSolid(let id, let title, let bgColor, let color): + return ("wallPaperSolid", [("id", id), ("title", title), ("bgColor", bgColor), ("color", color)]) + } } static func parse_wallPaper(_ reader: BufferReader) -> WallPaper? { @@ -8244,7 +9259,7 @@ extension Api { } } - enum Invoice { + enum Invoice: TypeConstructorDescription { case invoice(flags: Int32, currency: String, prices: [Api.LabeledPrice]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -8262,6 +9277,13 @@ extension Api { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .invoice(let flags, let currency, let prices): + return ("invoice", [("flags", flags), ("currency", currency), ("prices", prices)]) + } } static func parse_invoice(_ reader: BufferReader) -> Invoice? { @@ -8285,7 +9307,7 @@ extension Api { } } - enum PeerSettings { + enum PeerSettings: TypeConstructorDescription { case peerSettings(flags: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -8297,6 +9319,13 @@ extension Api { serializeInt32(flags, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .peerSettings(let flags): + return ("peerSettings", [("flags", flags)]) + } } static func parse_peerSettings(_ reader: BufferReader) -> PeerSettings? { @@ -8312,7 +9341,7 @@ extension Api { } } - enum InputChatPhoto { + enum InputChatPhoto: TypeConstructorDescription { case inputChatPhotoEmpty case inputChatUploadedPhoto(file: Api.InputFile) case inputChatPhoto(id: Api.InputPhoto) @@ -8338,6 +9367,17 @@ extension Api { id.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputChatPhotoEmpty: + return ("inputChatPhotoEmpty", []) + case .inputChatUploadedPhoto(let file): + return ("inputChatUploadedPhoto", [("file", file)]) + case .inputChatPhoto(let id): + return ("inputChatPhoto", [("id", id)]) + } } static func parse_inputChatPhotoEmpty(_ reader: BufferReader) -> InputChatPhoto? { @@ -8371,7 +9411,7 @@ extension Api { } } - enum PaymentCharge { + enum PaymentCharge: TypeConstructorDescription { case paymentCharge(id: String, providerChargeId: String) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -8384,6 +9424,13 @@ extension Api { serializeString(providerChargeId, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .paymentCharge(let id, let providerChargeId): + return ("paymentCharge", [("id", id), ("providerChargeId", providerChargeId)]) + } } static func parse_paymentCharge(_ reader: BufferReader) -> PaymentCharge? { @@ -8402,7 +9449,7 @@ extension Api { } } - enum Updates { + enum Updates: TypeConstructorDescription { case updatesTooLong case updateShortMessage(flags: Int32, id: Int32, userId: Int32, message: String, pts: Int32, ptsCount: Int32, date: Int32, fwdFrom: Api.MessageFwdHeader?, viaBotId: Int32?, replyToMsgId: Int32?, entities: [Api.MessageEntity]?) case updateShortChatMessage(flags: Int32, id: Int32, fromId: Int32, chatId: Int32, message: String, pts: Int32, ptsCount: Int32, date: Int32, fwdFrom: Api.MessageFwdHeader?, viaBotId: Int32?, replyToMsgId: Int32?, entities: [Api.MessageEntity]?) @@ -8529,6 +9576,25 @@ extension Api { }} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .updatesTooLong: + return ("updatesTooLong", []) + case .updateShortMessage(let flags, let id, let userId, let message, let pts, let ptsCount, let date, let fwdFrom, let viaBotId, let replyToMsgId, let entities): + return ("updateShortMessage", [("flags", flags), ("id", id), ("userId", userId), ("message", message), ("pts", pts), ("ptsCount", ptsCount), ("date", date), ("fwdFrom", fwdFrom), ("viaBotId", viaBotId), ("replyToMsgId", replyToMsgId), ("entities", entities)]) + case .updateShortChatMessage(let flags, let id, let fromId, let chatId, let message, let pts, let ptsCount, let date, let fwdFrom, let viaBotId, let replyToMsgId, let entities): + return ("updateShortChatMessage", [("flags", flags), ("id", id), ("fromId", fromId), ("chatId", chatId), ("message", message), ("pts", pts), ("ptsCount", ptsCount), ("date", date), ("fwdFrom", fwdFrom), ("viaBotId", viaBotId), ("replyToMsgId", replyToMsgId), ("entities", entities)]) + case .updateShort(let update, let date): + return ("updateShort", [("update", update), ("date", date)]) + case .updatesCombined(let updates, let users, let chats, let date, let seqStart, let seq): + return ("updatesCombined", [("updates", updates), ("users", users), ("chats", chats), ("date", date), ("seqStart", seqStart), ("seq", seq)]) + case .updates(let updates, let users, let chats, let date, let seq): + return ("updates", [("updates", updates), ("users", users), ("chats", chats), ("date", date), ("seq", seq)]) + case .updateShortSentMessage(let flags, let id, let pts, let ptsCount, let date, let media, let entities): + return ("updateShortSentMessage", [("flags", flags), ("id", id), ("pts", pts), ("ptsCount", ptsCount), ("date", date), ("media", media), ("entities", entities)]) + } } static func parse_updatesTooLong(_ reader: BufferReader) -> Updates? { @@ -8739,7 +9805,7 @@ extension Api { } } - enum MessageMedia { + enum MessageMedia: TypeConstructorDescription { case messageMediaEmpty case messageMediaGeo(geo: Api.GeoPoint) case messageMediaContact(phoneNumber: String, firstName: String, lastName: String, userId: Int32) @@ -8841,6 +9907,33 @@ extension Api { if Int(flags) & Int(1 << 2) != 0 {serializeInt32(ttlSeconds!, buffer: buffer, boxed: false)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .messageMediaEmpty: + return ("messageMediaEmpty", []) + case .messageMediaGeo(let geo): + return ("messageMediaGeo", [("geo", geo)]) + case .messageMediaContact(let phoneNumber, let firstName, let lastName, let userId): + return ("messageMediaContact", [("phoneNumber", phoneNumber), ("firstName", firstName), ("lastName", lastName), ("userId", userId)]) + case .messageMediaUnsupported: + return ("messageMediaUnsupported", []) + case .messageMediaWebPage(let webpage): + return ("messageMediaWebPage", [("webpage", webpage)]) + case .messageMediaGame(let game): + return ("messageMediaGame", [("game", game)]) + case .messageMediaInvoice(let flags, let title, let description, let photo, let receiptMsgId, let currency, let totalAmount, let startParam): + return ("messageMediaInvoice", [("flags", flags), ("title", title), ("description", description), ("photo", photo), ("receiptMsgId", receiptMsgId), ("currency", currency), ("totalAmount", totalAmount), ("startParam", startParam)]) + case .messageMediaGeoLive(let geo, let period): + return ("messageMediaGeoLive", [("geo", geo), ("period", period)]) + case .messageMediaVenue(let geo, let title, let address, let provider, let venueId, let venueType): + return ("messageMediaVenue", [("geo", geo), ("title", title), ("address", address), ("provider", provider), ("venueId", venueId), ("venueType", venueType)]) + case .messageMediaPhoto(let flags, let photo, let ttlSeconds): + return ("messageMediaPhoto", [("flags", flags), ("photo", photo), ("ttlSeconds", ttlSeconds)]) + case .messageMediaDocument(let flags, let document, let ttlSeconds): + return ("messageMediaDocument", [("flags", flags), ("document", document), ("ttlSeconds", ttlSeconds)]) + } } static func parse_messageMediaEmpty(_ reader: BufferReader) -> MessageMedia? { @@ -9026,7 +10119,7 @@ extension Api { } } - enum PaymentSavedCredentials { + enum PaymentSavedCredentials: TypeConstructorDescription { case paymentSavedCredentialsCard(id: String, title: String) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -9039,6 +10132,13 @@ extension Api { serializeString(title, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .paymentSavedCredentialsCard(let id, let title): + return ("paymentSavedCredentialsCard", [("id", id), ("title", title)]) + } } static func parse_paymentSavedCredentialsCard(_ reader: BufferReader) -> PaymentSavedCredentials? { @@ -9057,7 +10157,7 @@ extension Api { } } - enum Null { + enum Null: TypeConstructorDescription { case null func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -9069,6 +10169,13 @@ extension Api { break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .null: + return ("null", []) + } } static func parse_null(_ reader: BufferReader) -> Null? { @@ -9076,7 +10183,7 @@ extension Api { } } - enum DocumentAttribute { + enum DocumentAttribute: TypeConstructorDescription { case documentAttributeImageSize(w: Int32, h: Int32) case documentAttributeAnimated case documentAttributeSticker(flags: Int32, alt: String, stickerset: Api.InputStickerSet, maskCoords: Api.MaskCoords?) @@ -9141,6 +10248,25 @@ extension Api { break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .documentAttributeImageSize(let w, let h): + return ("documentAttributeImageSize", [("w", w), ("h", h)]) + case .documentAttributeAnimated: + return ("documentAttributeAnimated", []) + case .documentAttributeSticker(let flags, let alt, let stickerset, let maskCoords): + return ("documentAttributeSticker", [("flags", flags), ("alt", alt), ("stickerset", stickerset), ("maskCoords", maskCoords)]) + case .documentAttributeVideo(let flags, let duration, let w, let h): + return ("documentAttributeVideo", [("flags", flags), ("duration", duration), ("w", w), ("h", h)]) + case .documentAttributeAudio(let flags, let duration, let title, let performer, let waveform): + return ("documentAttributeAudio", [("flags", flags), ("duration", duration), ("title", title), ("performer", performer), ("waveform", waveform)]) + case .documentAttributeFilename(let fileName): + return ("documentAttributeFilename", [("fileName", fileName)]) + case .documentAttributeHasStickers: + return ("documentAttributeHasStickers", []) + } } static func parse_documentAttributeImageSize(_ reader: BufferReader) -> DocumentAttribute? { @@ -9243,7 +10369,7 @@ extension Api { } } - enum ChatPhoto { + enum ChatPhoto: TypeConstructorDescription { case chatPhotoEmpty case chatPhoto(photoSmall: Api.FileLocation, photoBig: Api.FileLocation) @@ -9263,6 +10389,15 @@ extension Api { photoBig.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .chatPhotoEmpty: + return ("chatPhotoEmpty", []) + case .chatPhoto(let photoSmall, let photoBig): + return ("chatPhoto", [("photoSmall", photoSmall), ("photoBig", photoBig)]) + } } static func parse_chatPhotoEmpty(_ reader: BufferReader) -> ChatPhoto? { @@ -9288,7 +10423,7 @@ extension Api { } } - enum InputStickerSet { + enum InputStickerSet: TypeConstructorDescription { case inputStickerSetEmpty case inputStickerSetID(id: Int64, accessHash: Int64) case inputStickerSetShortName(shortName: String) @@ -9315,6 +10450,17 @@ extension Api { serializeString(shortName, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputStickerSetEmpty: + return ("inputStickerSetEmpty", []) + case .inputStickerSetID(let id, let accessHash): + return ("inputStickerSetID", [("id", id), ("accessHash", accessHash)]) + case .inputStickerSetShortName(let shortName): + return ("inputStickerSetShortName", [("shortName", shortName)]) + } } static func parse_inputStickerSetEmpty(_ reader: BufferReader) -> InputStickerSet? { @@ -9347,7 +10493,7 @@ extension Api { } } - enum BotInfo { + enum BotInfo: TypeConstructorDescription { case botInfo(userId: Int32, description: String, commands: [Api.BotCommand]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -9365,6 +10511,13 @@ extension Api { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .botInfo(let userId, let description, let commands): + return ("botInfo", [("userId", userId), ("description", description), ("commands", commands)]) + } } static func parse_botInfo(_ reader: BufferReader) -> BotInfo? { @@ -9388,7 +10541,7 @@ extension Api { } } - enum FoundGif { + enum FoundGif: TypeConstructorDescription { case foundGif(url: String, thumbUrl: String, contentUrl: String, contentType: String, w: Int32, h: Int32) case foundGifCached(url: String, photo: Api.Photo, document: Api.Document) @@ -9414,6 +10567,15 @@ extension Api { document.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .foundGif(let url, let thumbUrl, let contentUrl, let contentType, let w, let h): + return ("foundGif", [("url", url), ("thumbUrl", thumbUrl), ("contentUrl", contentUrl), ("contentType", contentType), ("w", w), ("h", h)]) + case .foundGifCached(let url, let photo, let document): + return ("foundGifCached", [("url", url), ("photo", photo), ("document", document)]) + } } static func parse_foundGif(_ reader: BufferReader) -> FoundGif? { @@ -9465,7 +10627,7 @@ extension Api { } } - enum User { + enum User: TypeConstructorDescription { case userEmpty(id: Int32) case user(flags: Int32, id: Int32, accessHash: Int64?, firstName: String?, lastName: String?, username: String?, phone: String?, photo: Api.UserProfilePhoto?, status: Api.UserStatus?, botInfoVersion: Int32?, restrictionReason: String?, botInlinePlaceholder: String?, langCode: String?) @@ -9496,6 +10658,15 @@ extension Api { if Int(flags) & Int(1 << 22) != 0 {serializeString(langCode!, buffer: buffer, boxed: false)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .userEmpty(let id): + return ("userEmpty", [("id", id)]) + case .user(let flags, let id, let accessHash, let firstName, let lastName, let username, let phone, let photo, let status, let botInfoVersion, let restrictionReason, let botInlinePlaceholder, let langCode): + return ("user", [("flags", flags), ("id", id), ("accessHash", accessHash), ("firstName", firstName), ("lastName", lastName), ("username", username), ("phone", phone), ("photo", photo), ("status", status), ("botInfoVersion", botInfoVersion), ("restrictionReason", restrictionReason), ("botInlinePlaceholder", botInlinePlaceholder), ("langCode", langCode)]) + } } static func parse_userEmpty(_ reader: BufferReader) -> User? { @@ -9562,7 +10733,7 @@ extension Api { } } - enum Message { + enum Message: TypeConstructorDescription { case messageEmpty(id: Int32) case messageService(flags: Int32, id: Int32, fromId: Int32?, toId: Api.Peer, replyToMsgId: Int32?, date: Int32, action: Api.MessageAction) case message(flags: Int32, id: Int32, fromId: Int32?, toId: Api.Peer, fwdFrom: Api.MessageFwdHeader?, viaBotId: Int32?, replyToMsgId: Int32?, date: Int32, message: String, media: Api.MessageMedia?, replyMarkup: Api.ReplyMarkup?, entities: [Api.MessageEntity]?, views: Int32?, editDate: Int32?, postAuthor: String?, groupedId: Int64?) @@ -9613,6 +10784,17 @@ extension Api { if Int(flags) & Int(1 << 17) != 0 {serializeInt64(groupedId!, buffer: buffer, boxed: false)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .messageEmpty(let id): + return ("messageEmpty", [("id", id)]) + case .messageService(let flags, let id, let fromId, let toId, let replyToMsgId, let date, let action): + return ("messageService", [("flags", flags), ("id", id), ("fromId", fromId), ("toId", toId), ("replyToMsgId", replyToMsgId), ("date", date), ("action", action)]) + case .message(let flags, let id, let fromId, let toId, let fwdFrom, let viaBotId, let replyToMsgId, let date, let message, let media, let replyMarkup, let entities, let views, let editDate, let postAuthor, let groupedId): + return ("message", [("flags", flags), ("id", id), ("fromId", fromId), ("toId", toId), ("fwdFrom", fwdFrom), ("viaBotId", viaBotId), ("replyToMsgId", replyToMsgId), ("date", date), ("message", message), ("media", media), ("replyMarkup", replyMarkup), ("entities", entities), ("views", views), ("editDate", editDate), ("postAuthor", postAuthor), ("groupedId", groupedId)]) + } } static func parse_messageEmpty(_ reader: BufferReader) -> Message? { @@ -9727,7 +10909,7 @@ extension Api { } } - enum InputFileLocation { + enum InputFileLocation: TypeConstructorDescription { case inputFileLocation(volumeId: Int64, localId: Int32, secret: Int64) case inputEncryptedFileLocation(id: Int64, accessHash: Int64) case inputDocumentFileLocation(id: Int64, accessHash: Int64, version: Int32) @@ -9758,6 +10940,17 @@ extension Api { serializeInt32(version, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputFileLocation(let volumeId, let localId, let secret): + return ("inputFileLocation", [("volumeId", volumeId), ("localId", localId), ("secret", secret)]) + case .inputEncryptedFileLocation(let id, let accessHash): + return ("inputEncryptedFileLocation", [("id", id), ("accessHash", accessHash)]) + case .inputDocumentFileLocation(let id, let accessHash, let version): + return ("inputDocumentFileLocation", [("id", id), ("accessHash", accessHash), ("version", version)]) + } } static func parse_inputFileLocation(_ reader: BufferReader) -> InputFileLocation? { @@ -9810,7 +11003,7 @@ extension Api { } } - enum GeoPoint { + enum GeoPoint: TypeConstructorDescription { case geoPointEmpty case geoPoint(long: Double, lat: Double) @@ -9830,6 +11023,15 @@ extension Api { serializeDouble(lat, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .geoPointEmpty: + return ("geoPointEmpty", []) + case .geoPoint(let long, let lat): + return ("geoPoint", [("long", long), ("lat", lat)]) + } } static func parse_geoPointEmpty(_ reader: BufferReader) -> GeoPoint? { @@ -9851,7 +11053,7 @@ extension Api { } } - enum InputPhoneCall { + enum InputPhoneCall: TypeConstructorDescription { case inputPhoneCall(id: Int64, accessHash: Int64) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -9864,6 +11066,13 @@ extension Api { serializeInt64(accessHash, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputPhoneCall(let id, let accessHash): + return ("inputPhoneCall", [("id", id), ("accessHash", accessHash)]) + } } static func parse_inputPhoneCall(_ reader: BufferReader) -> InputPhoneCall? { @@ -9882,7 +11091,7 @@ extension Api { } } - enum ReceivedNotifyMessage { + enum ReceivedNotifyMessage: TypeConstructorDescription { case receivedNotifyMessage(id: Int32, flags: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -9895,6 +11104,13 @@ extension Api { serializeInt32(flags, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .receivedNotifyMessage(let id, let flags): + return ("receivedNotifyMessage", [("id", id), ("flags", flags)]) + } } static func parse_receivedNotifyMessage(_ reader: BufferReader) -> ReceivedNotifyMessage? { @@ -9913,7 +11129,7 @@ extension Api { } } - enum ChatParticipants { + enum ChatParticipants: TypeConstructorDescription { case chatParticipantsForbidden(flags: Int32, chatId: Int32, selfParticipant: Api.ChatParticipant?) case chatParticipants(chatId: Int32, participants: [Api.ChatParticipant], version: Int32) @@ -9940,6 +11156,15 @@ extension Api { serializeInt32(version, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .chatParticipantsForbidden(let flags, let chatId, let selfParticipant): + return ("chatParticipantsForbidden", [("flags", flags), ("chatId", chatId), ("selfParticipant", selfParticipant)]) + case .chatParticipants(let chatId, let participants, let version): + return ("chatParticipants", [("chatId", chatId), ("participants", participants), ("version", version)]) + } } static func parse_chatParticipantsForbidden(_ reader: BufferReader) -> ChatParticipants? { @@ -9982,7 +11207,7 @@ extension Api { } } - enum InputPaymentCredentials { + enum InputPaymentCredentials: TypeConstructorDescription { case inputPaymentCredentialsSaved(id: String, tmpPassword: Buffer) case inputPaymentCredentials(flags: Int32, data: Api.DataJSON) case inputPaymentCredentialsApplePay(paymentData: Api.DataJSON) @@ -10018,6 +11243,19 @@ extension Api { serializeString(googleTransactionId, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputPaymentCredentialsSaved(let id, let tmpPassword): + return ("inputPaymentCredentialsSaved", [("id", id), ("tmpPassword", tmpPassword)]) + case .inputPaymentCredentials(let flags, let data): + return ("inputPaymentCredentials", [("flags", flags), ("data", data)]) + case .inputPaymentCredentialsApplePay(let paymentData): + return ("inputPaymentCredentialsApplePay", [("paymentData", paymentData)]) + case .inputPaymentCredentialsAndroidPay(let paymentToken, let googleTransactionId): + return ("inputPaymentCredentialsAndroidPay", [("paymentToken", paymentToken), ("googleTransactionId", googleTransactionId)]) + } } static func parse_inputPaymentCredentialsSaved(_ reader: BufferReader) -> InputPaymentCredentials? { @@ -10081,7 +11319,7 @@ extension Api { } } - enum ShippingOption { + enum ShippingOption: TypeConstructorDescription { case shippingOption(id: String, title: String, prices: [Api.LabeledPrice]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -10099,6 +11337,13 @@ extension Api { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .shippingOption(let id, let title, let prices): + return ("shippingOption", [("id", id), ("title", title), ("prices", prices)]) + } } static func parse_shippingOption(_ reader: BufferReader) -> ShippingOption? { @@ -10122,7 +11367,7 @@ extension Api { } } - enum PostAddress { + enum PostAddress: TypeConstructorDescription { case postAddress(streetLine1: String, streetLine2: String, city: String, state: String, countryIso2: String, postCode: String) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -10139,6 +11384,13 @@ extension Api { serializeString(postCode, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .postAddress(let streetLine1, let streetLine2, let city, let state, let countryIso2, let postCode): + return ("postAddress", [("streetLine1", streetLine1), ("streetLine2", streetLine2), ("city", city), ("state", state), ("countryIso2", countryIso2), ("postCode", postCode)]) + } } static func parse_postAddress(_ reader: BufferReader) -> PostAddress? { @@ -10169,7 +11421,7 @@ extension Api { } } - enum DataJSON { + enum DataJSON: TypeConstructorDescription { case dataJSON(data: String) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -10181,6 +11433,13 @@ extension Api { serializeString(data, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .dataJSON(let data): + return ("dataJSON", [("data", data)]) + } } static func parse_dataJSON(_ reader: BufferReader) -> DataJSON? { @@ -10196,7 +11455,7 @@ extension Api { } } - enum InputStickeredMedia { + enum InputStickeredMedia: TypeConstructorDescription { case inputStickeredMediaPhoto(id: Api.InputPhoto) case inputStickeredMediaDocument(id: Api.InputDocument) @@ -10215,6 +11474,15 @@ extension Api { id.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputStickeredMediaPhoto(let id): + return ("inputStickeredMediaPhoto", [("id", id)]) + case .inputStickeredMediaDocument(let id): + return ("inputStickeredMediaDocument", [("id", id)]) + } } static func parse_inputStickeredMediaPhoto(_ reader: BufferReader) -> InputStickeredMedia? { @@ -10245,7 +11513,7 @@ extension Api { } } - enum PhoneCallDiscardReason { + enum PhoneCallDiscardReason: TypeConstructorDescription { case phoneCallDiscardReasonMissed case phoneCallDiscardReasonDisconnect case phoneCallDiscardReasonHangup @@ -10278,6 +11546,19 @@ extension Api { break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .phoneCallDiscardReasonMissed: + return ("phoneCallDiscardReasonMissed", []) + case .phoneCallDiscardReasonDisconnect: + return ("phoneCallDiscardReasonDisconnect", []) + case .phoneCallDiscardReasonHangup: + return ("phoneCallDiscardReasonHangup", []) + case .phoneCallDiscardReasonBusy: + return ("phoneCallDiscardReasonBusy", []) + } } static func parse_phoneCallDiscardReasonMissed(_ reader: BufferReader) -> PhoneCallDiscardReason? { @@ -10294,7 +11575,7 @@ extension Api { } } - enum NearestDc { + enum NearestDc: TypeConstructorDescription { case nearestDc(country: String, thisDc: Int32, nearestDc: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -10308,6 +11589,13 @@ extension Api { serializeInt32(nearestDc, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .nearestDc(let country, let thisDc, let nearestDc): + return ("nearestDc", [("country", country), ("thisDc", thisDc), ("nearestDc", nearestDc)]) + } } static func parse_nearestDc(_ reader: BufferReader) -> NearestDc? { @@ -10329,7 +11617,7 @@ extension Api { } } - enum InputWebDocument { + enum InputWebDocument: TypeConstructorDescription { case inputWebDocument(url: String, size: Int32, mimeType: String, attributes: [Api.DocumentAttribute]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -10348,6 +11636,13 @@ extension Api { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputWebDocument(let url, let size, let mimeType, let attributes): + return ("inputWebDocument", [("url", url), ("size", size), ("mimeType", mimeType), ("attributes", attributes)]) + } } static func parse_inputWebDocument(_ reader: BufferReader) -> InputWebDocument? { @@ -10374,7 +11669,7 @@ extension Api { } } - enum ChannelAdminLogEvent { + enum ChannelAdminLogEvent: TypeConstructorDescription { case channelAdminLogEvent(id: Int64, date: Int32, userId: Int32, action: Api.ChannelAdminLogEventAction) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -10389,6 +11684,13 @@ extension Api { action.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .channelAdminLogEvent(let id, let date, let userId, let action): + return ("channelAdminLogEvent", [("id", id), ("date", date), ("userId", userId), ("action", action)]) + } } static func parse_channelAdminLogEvent(_ reader: BufferReader) -> ChannelAdminLogEvent? { @@ -10415,7 +11717,7 @@ extension Api { } } - enum Bool { + enum Bool: TypeConstructorDescription { case boolFalse case boolTrue @@ -10434,6 +11736,15 @@ extension Api { break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .boolFalse: + return ("boolFalse", []) + case .boolTrue: + return ("boolTrue", []) + } } static func parse_boolFalse(_ reader: BufferReader) -> Bool? { @@ -10444,7 +11755,7 @@ extension Api { } } - enum LangPackString { + enum LangPackString: TypeConstructorDescription { case langPackString(key: String, value: String) case langPackStringPluralized(flags: Int32, key: String, zeroValue: String?, oneValue: String?, twoValue: String?, fewValue: String?, manyValue: String?, otherValue: String) case langPackStringDeleted(key: String) @@ -10478,6 +11789,17 @@ extension Api { serializeString(key, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .langPackString(let key, let value): + return ("langPackString", [("key", key), ("value", value)]) + case .langPackStringPluralized(let flags, let key, let zeroValue, let oneValue, let twoValue, let fewValue, let manyValue, let otherValue): + return ("langPackStringPluralized", [("flags", flags), ("key", key), ("zeroValue", zeroValue), ("oneValue", oneValue), ("twoValue", twoValue), ("fewValue", fewValue), ("manyValue", manyValue), ("otherValue", otherValue)]) + case .langPackStringDeleted(let key): + return ("langPackStringDeleted", [("key", key)]) + } } static func parse_langPackString(_ reader: BufferReader) -> LangPackString? { @@ -10539,7 +11861,7 @@ extension Api { } } - enum InputWebFileLocation { + enum InputWebFileLocation: TypeConstructorDescription { case inputWebFileLocation(url: String, accessHash: Int64) case inputWebFileGeoPointLocation(geoPoint: Api.InputGeoPoint, w: Int32, h: Int32, zoom: Int32, scale: Int32) case inputWebFileGeoMessageLocation(peer: Api.InputPeer, msgId: Int32, w: Int32, h: Int32, zoom: Int32, scale: Int32) @@ -10575,6 +11897,17 @@ extension Api { serializeInt32(scale, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputWebFileLocation(let url, let accessHash): + return ("inputWebFileLocation", [("url", url), ("accessHash", accessHash)]) + case .inputWebFileGeoPointLocation(let geoPoint, let w, let h, let zoom, let scale): + return ("inputWebFileGeoPointLocation", [("geoPoint", geoPoint), ("w", w), ("h", h), ("zoom", zoom), ("scale", scale)]) + case .inputWebFileGeoMessageLocation(let peer, let msgId, let w, let h, let zoom, let scale): + return ("inputWebFileGeoMessageLocation", [("peer", peer), ("msgId", msgId), ("w", w), ("h", h), ("zoom", zoom), ("scale", scale)]) + } } static func parse_inputWebFileLocation(_ reader: BufferReader) -> InputWebFileLocation? { @@ -10646,7 +11979,7 @@ extension Api { } } - enum MessageFwdHeader { + enum MessageFwdHeader: TypeConstructorDescription { case messageFwdHeader(flags: Int32, fromId: Int32?, date: Int32, channelId: Int32?, channelPost: Int32?, postAuthor: String?, savedFromPeer: Api.Peer?, savedFromMsgId: Int32?) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -10665,6 +11998,13 @@ extension Api { if Int(flags) & Int(1 << 4) != 0 {serializeInt32(savedFromMsgId!, buffer: buffer, boxed: false)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .messageFwdHeader(let flags, let fromId, let date, let channelId, let channelPost, let postAuthor, let savedFromPeer, let savedFromMsgId): + return ("messageFwdHeader", [("flags", flags), ("fromId", fromId), ("date", date), ("channelId", channelId), ("channelPost", channelPost), ("postAuthor", postAuthor), ("savedFromPeer", savedFromPeer), ("savedFromMsgId", savedFromMsgId)]) + } } static func parse_messageFwdHeader(_ reader: BufferReader) -> MessageFwdHeader? { @@ -10703,7 +12043,7 @@ extension Api { } } - enum MessagesFilter { + enum MessagesFilter: TypeConstructorDescription { case inputMessagesFilterEmpty case inputMessagesFilterPhotos case inputMessagesFilterVideo @@ -10834,6 +12174,47 @@ extension Api { break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputMessagesFilterEmpty: + return ("inputMessagesFilterEmpty", []) + case .inputMessagesFilterPhotos: + return ("inputMessagesFilterPhotos", []) + case .inputMessagesFilterVideo: + return ("inputMessagesFilterVideo", []) + case .inputMessagesFilterPhotoVideo: + return ("inputMessagesFilterPhotoVideo", []) + case .inputMessagesFilterPhotoVideoDocuments: + return ("inputMessagesFilterPhotoVideoDocuments", []) + case .inputMessagesFilterDocument: + return ("inputMessagesFilterDocument", []) + case .inputMessagesFilterUrl: + return ("inputMessagesFilterUrl", []) + case .inputMessagesFilterGif: + return ("inputMessagesFilterGif", []) + case .inputMessagesFilterVoice: + return ("inputMessagesFilterVoice", []) + case .inputMessagesFilterMusic: + return ("inputMessagesFilterMusic", []) + case .inputMessagesFilterChatPhotos: + return ("inputMessagesFilterChatPhotos", []) + case .inputMessagesFilterPhoneCalls(let flags): + return ("inputMessagesFilterPhoneCalls", [("flags", flags)]) + case .inputMessagesFilterRoundVoice: + return ("inputMessagesFilterRoundVoice", []) + case .inputMessagesFilterRoundVideo: + return ("inputMessagesFilterRoundVideo", []) + case .inputMessagesFilterMyMentions: + return ("inputMessagesFilterMyMentions", []) + case .inputMessagesFilterMyMentionsUnread: + return ("inputMessagesFilterMyMentionsUnread", []) + case .inputMessagesFilterGeo: + return ("inputMessagesFilterGeo", []) + case .inputMessagesFilterContacts: + return ("inputMessagesFilterContacts", []) + } } static func parse_inputMessagesFilterEmpty(_ reader: BufferReader) -> MessagesFilter? { @@ -10900,7 +12281,7 @@ extension Api { } } - enum BotInlineMessage { + enum BotInlineMessage: TypeConstructorDescription { case botInlineMessageText(flags: Int32, message: String, entities: [Api.MessageEntity]?, replyMarkup: Api.ReplyMarkup?) case botInlineMessageMediaGeo(flags: Int32, geo: Api.GeoPoint, replyMarkup: Api.ReplyMarkup?) case botInlineMessageMediaContact(flags: Int32, phoneNumber: String, firstName: String, lastName: String, replyMarkup: Api.ReplyMarkup?) @@ -10967,6 +12348,21 @@ extension Api { if Int(flags) & Int(1 << 2) != 0 {replyMarkup!.serialize(buffer, true)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .botInlineMessageText(let flags, let message, let entities, let replyMarkup): + return ("botInlineMessageText", [("flags", flags), ("message", message), ("entities", entities), ("replyMarkup", replyMarkup)]) + case .botInlineMessageMediaGeo(let flags, let geo, let replyMarkup): + return ("botInlineMessageMediaGeo", [("flags", flags), ("geo", geo), ("replyMarkup", replyMarkup)]) + case .botInlineMessageMediaContact(let flags, let phoneNumber, let firstName, let lastName, let replyMarkup): + return ("botInlineMessageMediaContact", [("flags", flags), ("phoneNumber", phoneNumber), ("firstName", firstName), ("lastName", lastName), ("replyMarkup", replyMarkup)]) + case .botInlineMessageMediaAuto(let flags, let message, let entities, let replyMarkup): + return ("botInlineMessageMediaAuto", [("flags", flags), ("message", message), ("entities", entities), ("replyMarkup", replyMarkup)]) + case .botInlineMessageMediaVenue(let flags, let geo, let title, let address, let provider, let venueId, let venueType, let replyMarkup): + return ("botInlineMessageMediaVenue", [("flags", flags), ("geo", geo), ("title", title), ("address", address), ("provider", provider), ("venueId", venueId), ("venueType", venueType), ("replyMarkup", replyMarkup)]) + } } static func parse_botInlineMessageText(_ reader: BufferReader) -> BotInlineMessage? { @@ -11101,7 +12497,7 @@ extension Api { } } - enum InputPeerNotifySettings { + enum InputPeerNotifySettings: TypeConstructorDescription { case inputPeerNotifySettings(flags: Int32, showPreviews: Api.Bool?, silent: Api.Bool?, muteUntil: Int32?, sound: String?) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -11117,6 +12513,13 @@ extension Api { if Int(flags) & Int(1 << 3) != 0 {serializeString(sound!, buffer: buffer, boxed: false)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputPeerNotifySettings(let flags, let showPreviews, let silent, let muteUntil, let sound): + return ("inputPeerNotifySettings", [("flags", flags), ("showPreviews", showPreviews), ("silent", silent), ("muteUntil", muteUntil), ("sound", sound)]) + } } static func parse_inputPeerNotifySettings(_ reader: BufferReader) -> InputPeerNotifySettings? { @@ -11148,7 +12551,7 @@ extension Api { } } - enum ExportedChatInvite { + enum ExportedChatInvite: TypeConstructorDescription { case chatInviteEmpty case chatInviteExported(link: String) @@ -11167,6 +12570,15 @@ extension Api { serializeString(link, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .chatInviteEmpty: + return ("chatInviteEmpty", []) + case .chatInviteExported(let link): + return ("chatInviteExported", [("link", link)]) + } } static func parse_chatInviteEmpty(_ reader: BufferReader) -> ExportedChatInvite? { @@ -11185,7 +12597,7 @@ extension Api { } } - enum Authorization { + enum Authorization: TypeConstructorDescription { case authorization(hash: Int64, flags: Int32, deviceModel: String, platform: String, systemVersion: String, apiId: Int32, appName: String, appVersion: String, dateCreated: Int32, dateActive: Int32, ip: String, country: String, region: String) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -11209,6 +12621,13 @@ extension Api { serializeString(region, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .authorization(let hash, let flags, let deviceModel, let platform, let systemVersion, let apiId, let appName, let appVersion, let dateCreated, let dateActive, let ip, let country, let region): + return ("authorization", [("hash", hash), ("flags", flags), ("deviceModel", deviceModel), ("platform", platform), ("systemVersion", systemVersion), ("apiId", apiId), ("appName", appName), ("appVersion", appVersion), ("dateCreated", dateCreated), ("dateActive", dateActive), ("ip", ip), ("country", country), ("region", region)]) + } } static func parse_authorization(_ reader: BufferReader) -> Authorization? { @@ -11260,7 +12679,7 @@ extension Api { } } - enum MaskCoords { + enum MaskCoords: TypeConstructorDescription { case maskCoords(n: Int32, x: Double, y: Double, zoom: Double) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -11275,6 +12694,13 @@ extension Api { serializeDouble(zoom, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .maskCoords(let n, let x, let y, let zoom): + return ("maskCoords", [("n", n), ("x", x), ("y", y), ("zoom", zoom)]) + } } static func parse_maskCoords(_ reader: BufferReader) -> MaskCoords? { @@ -11299,7 +12725,7 @@ extension Api { } } - enum PhoneConnection { + enum PhoneConnection: TypeConstructorDescription { case phoneConnection(id: Int64, ip: String, ipv6: String, port: Int32, peerTag: Buffer) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -11315,6 +12741,13 @@ extension Api { serializeBytes(peerTag, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .phoneConnection(let id, let ip, let ipv6, let port, let peerTag): + return ("phoneConnection", [("id", id), ("ip", ip), ("ipv6", ipv6), ("port", port), ("peerTag", peerTag)]) + } } static func parse_phoneConnection(_ reader: BufferReader) -> PhoneConnection? { @@ -11342,7 +12775,7 @@ extension Api { } } - enum AccountDaysTTL { + enum AccountDaysTTL: TypeConstructorDescription { case accountDaysTTL(days: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -11354,6 +12787,13 @@ extension Api { serializeInt32(days, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .accountDaysTTL(let days): + return ("accountDaysTTL", [("days", days)]) + } } static func parse_accountDaysTTL(_ reader: BufferReader) -> AccountDaysTTL? { @@ -11369,7 +12809,7 @@ extension Api { } } - enum InputBotInlineResult { + enum InputBotInlineResult: TypeConstructorDescription { case inputBotInlineResultPhoto(id: String, type: String, photo: Api.InputPhoto, sendMessage: Api.InputBotInlineMessage) case inputBotInlineResultDocument(flags: Int32, id: String, type: String, title: String?, description: String?, document: Api.InputDocument, sendMessage: Api.InputBotInlineMessage) case inputBotInlineResultGame(id: String, shortName: String, sendMessage: Api.InputBotInlineMessage) @@ -11421,6 +12861,19 @@ extension Api { sendMessage.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputBotInlineResultPhoto(let id, let type, let photo, let sendMessage): + return ("inputBotInlineResultPhoto", [("id", id), ("type", type), ("photo", photo), ("sendMessage", sendMessage)]) + case .inputBotInlineResultDocument(let flags, let id, let type, let title, let description, let document, let sendMessage): + return ("inputBotInlineResultDocument", [("flags", flags), ("id", id), ("type", type), ("title", title), ("description", description), ("document", document), ("sendMessage", sendMessage)]) + case .inputBotInlineResultGame(let id, let shortName, let sendMessage): + return ("inputBotInlineResultGame", [("id", id), ("shortName", shortName), ("sendMessage", sendMessage)]) + case .inputBotInlineResult(let flags, let id, let type, let title, let description, let url, let thumb, let content, let sendMessage): + return ("inputBotInlineResult", [("flags", flags), ("id", id), ("type", type), ("title", title), ("description", description), ("url", url), ("thumb", thumb), ("content", content), ("sendMessage", sendMessage)]) + } } static func parse_inputBotInlineResultPhoto(_ reader: BufferReader) -> InputBotInlineResult? { @@ -11542,7 +12995,7 @@ extension Api { } } - enum PrivacyRule { + enum PrivacyRule: TypeConstructorDescription { case privacyValueAllowContacts case privacyValueAllowAll case privacyValueAllowUsers(users: [Int32]) @@ -11597,6 +13050,23 @@ extension Api { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .privacyValueAllowContacts: + return ("privacyValueAllowContacts", []) + case .privacyValueAllowAll: + return ("privacyValueAllowAll", []) + case .privacyValueAllowUsers(let users): + return ("privacyValueAllowUsers", [("users", users)]) + case .privacyValueDisallowContacts: + return ("privacyValueDisallowContacts", []) + case .privacyValueDisallowAll: + return ("privacyValueDisallowAll", []) + case .privacyValueDisallowUsers(let users): + return ("privacyValueDisallowUsers", [("users", users)]) + } } static func parse_privacyValueAllowContacts(_ reader: BufferReader) -> PrivacyRule? { @@ -11639,7 +13109,7 @@ extension Api { } } - enum MessageAction { + enum MessageAction: TypeConstructorDescription { case messageActionEmpty case messageActionChatCreate(title: String, users: [Int32]) case messageActionChatEditTitle(title: String) @@ -11805,6 +13275,51 @@ extension Api { serializeString(domain, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .messageActionEmpty: + return ("messageActionEmpty", []) + case .messageActionChatCreate(let title, let users): + return ("messageActionChatCreate", [("title", title), ("users", users)]) + case .messageActionChatEditTitle(let title): + return ("messageActionChatEditTitle", [("title", title)]) + case .messageActionChatEditPhoto(let photo): + return ("messageActionChatEditPhoto", [("photo", photo)]) + case .messageActionChatDeletePhoto: + return ("messageActionChatDeletePhoto", []) + case .messageActionChatAddUser(let users): + return ("messageActionChatAddUser", [("users", users)]) + case .messageActionChatDeleteUser(let userId): + return ("messageActionChatDeleteUser", [("userId", userId)]) + case .messageActionChatJoinedByLink(let inviterId): + return ("messageActionChatJoinedByLink", [("inviterId", inviterId)]) + case .messageActionChannelCreate(let title): + return ("messageActionChannelCreate", [("title", title)]) + case .messageActionChatMigrateTo(let channelId): + return ("messageActionChatMigrateTo", [("channelId", channelId)]) + case .messageActionChannelMigrateFrom(let title, let chatId): + return ("messageActionChannelMigrateFrom", [("title", title), ("chatId", chatId)]) + case .messageActionPinMessage: + return ("messageActionPinMessage", []) + case .messageActionHistoryClear: + return ("messageActionHistoryClear", []) + case .messageActionGameScore(let gameId, let score): + return ("messageActionGameScore", [("gameId", gameId), ("score", score)]) + case .messageActionPaymentSentMe(let flags, let currency, let totalAmount, let payload, let info, let shippingOptionId, let charge): + return ("messageActionPaymentSentMe", [("flags", flags), ("currency", currency), ("totalAmount", totalAmount), ("payload", payload), ("info", info), ("shippingOptionId", shippingOptionId), ("charge", charge)]) + case .messageActionPaymentSent(let currency, let totalAmount): + return ("messageActionPaymentSent", [("currency", currency), ("totalAmount", totalAmount)]) + case .messageActionPhoneCall(let flags, let callId, let reason, let duration): + return ("messageActionPhoneCall", [("flags", flags), ("callId", callId), ("reason", reason), ("duration", duration)]) + case .messageActionScreenshotTaken: + return ("messageActionScreenshotTaken", []) + case .messageActionCustomAction(let message): + return ("messageActionCustomAction", [("message", message)]) + case .messageActionBotAllowed(let domain): + return ("messageActionBotAllowed", [("domain", domain)]) + } } static func parse_messageActionEmpty(_ reader: BufferReader) -> MessageAction? { @@ -12040,7 +13555,7 @@ extension Api { } } - enum PhoneCall { + enum PhoneCall: TypeConstructorDescription { case phoneCallEmpty(id: Int64) case phoneCallWaiting(flags: Int32, id: Int64, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32, protocol: Api.PhoneCallProtocol, receiveDate: Int32?) case phoneCallRequested(id: Int64, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32, gAHash: Buffer, protocol: Api.PhoneCallProtocol) @@ -12123,6 +13638,23 @@ extension Api { if Int(flags) & Int(1 << 1) != 0 {serializeInt32(duration!, buffer: buffer, boxed: false)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .phoneCallEmpty(let id): + return ("phoneCallEmpty", [("id", id)]) + case .phoneCallWaiting(let flags, let id, let accessHash, let date, let adminId, let participantId, let `protocol`, let receiveDate): + return ("phoneCallWaiting", [("flags", flags), ("id", id), ("accessHash", accessHash), ("date", date), ("adminId", adminId), ("participantId", participantId), ("`protocol`", `protocol`), ("receiveDate", receiveDate)]) + case .phoneCallRequested(let id, let accessHash, let date, let adminId, let participantId, let gAHash, let `protocol`): + return ("phoneCallRequested", [("id", id), ("accessHash", accessHash), ("date", date), ("adminId", adminId), ("participantId", participantId), ("gAHash", gAHash), ("`protocol`", `protocol`)]) + case .phoneCallAccepted(let id, let accessHash, let date, let adminId, let participantId, let gB, let `protocol`): + return ("phoneCallAccepted", [("id", id), ("accessHash", accessHash), ("date", date), ("adminId", adminId), ("participantId", participantId), ("gB", gB), ("`protocol`", `protocol`)]) + case .phoneCall(let id, let accessHash, let date, let adminId, let participantId, let gAOrB, let keyFingerprint, let `protocol`, let connection, let alternativeConnections, let startDate): + return ("phoneCall", [("id", id), ("accessHash", accessHash), ("date", date), ("adminId", adminId), ("participantId", participantId), ("gAOrB", gAOrB), ("keyFingerprint", keyFingerprint), ("`protocol`", `protocol`), ("connection", connection), ("alternativeConnections", alternativeConnections), ("startDate", startDate)]) + case .phoneCallDiscarded(let flags, let id, let reason, let duration): + return ("phoneCallDiscarded", [("flags", flags), ("id", id), ("reason", reason), ("duration", duration)]) + } } static func parse_phoneCallEmpty(_ reader: BufferReader) -> PhoneCall? { @@ -12303,7 +13835,7 @@ extension Api { } } - enum DialogPeer { + enum DialogPeer: TypeConstructorDescription { case dialogPeer(peer: Api.Peer) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -12315,6 +13847,13 @@ extension Api { peer.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .dialogPeer(let peer): + return ("dialogPeer", [("peer", peer)]) + } } static func parse_dialogPeer(_ reader: BufferReader) -> DialogPeer? { @@ -12332,7 +13871,7 @@ extension Api { } } - enum ContactLink { + enum ContactLink: TypeConstructorDescription { case contactLinkUnknown case contactLinkNone case contactLinkHasPhone @@ -12365,6 +13904,19 @@ extension Api { break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .contactLinkUnknown: + return ("contactLinkUnknown", []) + case .contactLinkNone: + return ("contactLinkNone", []) + case .contactLinkHasPhone: + return ("contactLinkHasPhone", []) + case .contactLinkContact: + return ("contactLinkContact", []) + } } static func parse_contactLinkUnknown(_ reader: BufferReader) -> ContactLink? { @@ -12381,7 +13933,7 @@ extension Api { } } - enum WebDocument { + enum WebDocument: TypeConstructorDescription { case webDocument(url: String, accessHash: Int64, size: Int32, mimeType: String, attributes: [Api.DocumentAttribute], dcId: Int32) case webDocumentNoProxy(url: String, size: Int32, mimeType: String, attributes: [Api.DocumentAttribute]) @@ -12416,6 +13968,15 @@ extension Api { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .webDocument(let url, let accessHash, let size, let mimeType, let attributes, let dcId): + return ("webDocument", [("url", url), ("accessHash", accessHash), ("size", size), ("mimeType", mimeType), ("attributes", attributes), ("dcId", dcId)]) + case .webDocumentNoProxy(let url, let size, let mimeType, let attributes): + return ("webDocumentNoProxy", [("url", url), ("size", size), ("mimeType", mimeType), ("attributes", attributes)]) + } } static func parse_webDocument(_ reader: BufferReader) -> WebDocument? { @@ -12470,7 +14031,7 @@ extension Api { } } - enum ChannelAdminLogEventsFilter { + enum ChannelAdminLogEventsFilter: TypeConstructorDescription { case channelAdminLogEventsFilter(flags: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -12482,6 +14043,13 @@ extension Api { serializeInt32(flags, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .channelAdminLogEventsFilter(let flags): + return ("channelAdminLogEventsFilter", [("flags", flags)]) + } } static func parse_channelAdminLogEventsFilter(_ reader: BufferReader) -> ChannelAdminLogEventsFilter? { @@ -12497,7 +14065,7 @@ extension Api { } } - enum PeerNotifySettings { + enum PeerNotifySettings: TypeConstructorDescription { case peerNotifySettingsEmpty case peerNotifySettings(flags: Int32, showPreviews: Api.Bool?, silent: Api.Bool?, muteUntil: Int32?, sound: String?) @@ -12520,6 +14088,15 @@ extension Api { if Int(flags) & Int(1 << 3) != 0 {serializeString(sound!, buffer: buffer, boxed: false)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .peerNotifySettingsEmpty: + return ("peerNotifySettingsEmpty", []) + case .peerNotifySettings(let flags, let showPreviews, let silent, let muteUntil, let sound): + return ("peerNotifySettings", [("flags", flags), ("showPreviews", showPreviews), ("silent", silent), ("muteUntil", muteUntil), ("sound", sound)]) + } } static func parse_peerNotifySettingsEmpty(_ reader: BufferReader) -> PeerNotifySettings? { @@ -12554,7 +14131,7 @@ extension Api { } } - enum InputBotInlineMessageID { + enum InputBotInlineMessageID: TypeConstructorDescription { case inputBotInlineMessageID(dcId: Int32, id: Int64, accessHash: Int64) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -12568,6 +14145,13 @@ extension Api { serializeInt64(accessHash, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputBotInlineMessageID(let dcId, let id, let accessHash): + return ("inputBotInlineMessageID", [("dcId", dcId), ("id", id), ("accessHash", accessHash)]) + } } static func parse_inputBotInlineMessageID(_ reader: BufferReader) -> InputBotInlineMessageID? { @@ -12589,7 +14173,7 @@ extension Api { } } - enum StickerPack { + enum StickerPack: TypeConstructorDescription { case stickerPack(emoticon: String, documents: [Int64]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -12606,6 +14190,13 @@ extension Api { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .stickerPack(let emoticon, let documents): + return ("stickerPack", [("emoticon", emoticon), ("documents", documents)]) + } } static func parse_stickerPack(_ reader: BufferReader) -> StickerPack? { @@ -12626,7 +14217,7 @@ extension Api { } } - enum UserProfilePhoto { + enum UserProfilePhoto: TypeConstructorDescription { case userProfilePhotoEmpty case userProfilePhoto(photoId: Int64, photoSmall: Api.FileLocation, photoBig: Api.FileLocation) @@ -12647,6 +14238,15 @@ extension Api { photoBig.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .userProfilePhotoEmpty: + return ("userProfilePhotoEmpty", []) + case .userProfilePhoto(let photoId, let photoSmall, let photoBig): + return ("userProfilePhoto", [("photoId", photoId), ("photoSmall", photoSmall), ("photoBig", photoBig)]) + } } static func parse_userProfilePhotoEmpty(_ reader: BufferReader) -> UserProfilePhoto? { @@ -12675,7 +14275,7 @@ extension Api { } } - enum InputAppEvent { + enum InputAppEvent: TypeConstructorDescription { case inputAppEvent(time: Double, type: String, peer: Int64, data: String) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -12690,6 +14290,13 @@ extension Api { serializeString(data, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputAppEvent(let time, let type, let peer, let data): + return ("inputAppEvent", [("time", time), ("type", type), ("peer", peer), ("data", data)]) + } } static func parse_inputAppEvent(_ reader: BufferReader) -> InputAppEvent? { @@ -12714,7 +14321,7 @@ extension Api { } } - enum MessageEntity { + enum MessageEntity: TypeConstructorDescription { case messageEntityUnknown(offset: Int32, length: Int32) case messageEntityMention(offset: Int32, length: Int32) case messageEntityHashtag(offset: Int32, length: Int32) @@ -12843,6 +14450,41 @@ extension Api { serializeInt32(length, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .messageEntityUnknown(let offset, let length): + return ("messageEntityUnknown", [("offset", offset), ("length", length)]) + case .messageEntityMention(let offset, let length): + return ("messageEntityMention", [("offset", offset), ("length", length)]) + case .messageEntityHashtag(let offset, let length): + return ("messageEntityHashtag", [("offset", offset), ("length", length)]) + case .messageEntityBotCommand(let offset, let length): + return ("messageEntityBotCommand", [("offset", offset), ("length", length)]) + case .messageEntityUrl(let offset, let length): + return ("messageEntityUrl", [("offset", offset), ("length", length)]) + case .messageEntityEmail(let offset, let length): + return ("messageEntityEmail", [("offset", offset), ("length", length)]) + case .messageEntityBold(let offset, let length): + return ("messageEntityBold", [("offset", offset), ("length", length)]) + case .messageEntityItalic(let offset, let length): + return ("messageEntityItalic", [("offset", offset), ("length", length)]) + case .messageEntityCode(let offset, let length): + return ("messageEntityCode", [("offset", offset), ("length", length)]) + case .messageEntityPre(let offset, let length, let language): + return ("messageEntityPre", [("offset", offset), ("length", length), ("language", language)]) + case .messageEntityTextUrl(let offset, let length, let url): + return ("messageEntityTextUrl", [("offset", offset), ("length", length), ("url", url)]) + case .messageEntityMentionName(let offset, let length, let userId): + return ("messageEntityMentionName", [("offset", offset), ("length", length), ("userId", userId)]) + case .inputMessageEntityMentionName(let offset, let length, let userId): + return ("inputMessageEntityMentionName", [("offset", offset), ("length", length), ("userId", userId)]) + case .messageEntityPhone(let offset, let length): + return ("messageEntityPhone", [("offset", offset), ("length", length)]) + case .messageEntityCashtag(let offset, let length): + return ("messageEntityCashtag", [("offset", offset), ("length", length)]) + } } static func parse_messageEntityUnknown(_ reader: BufferReader) -> MessageEntity? { @@ -13071,7 +14713,7 @@ extension Api { } } - enum InputPhoto { + enum InputPhoto: TypeConstructorDescription { case inputPhotoEmpty case inputPhoto(id: Int64, accessHash: Int64) @@ -13091,6 +14733,15 @@ extension Api { serializeInt64(accessHash, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inputPhotoEmpty: + return ("inputPhotoEmpty", []) + case .inputPhoto(let id, let accessHash): + return ("inputPhoto", [("id", id), ("accessHash", accessHash)]) + } } static func parse_inputPhotoEmpty(_ reader: BufferReader) -> InputPhoto? { @@ -13112,7 +14763,7 @@ extension Api { } } - enum EncryptedChat { + enum EncryptedChat: TypeConstructorDescription { case encryptedChatEmpty(id: Int32) case encryptedChatWaiting(id: Int32, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32) case encryptedChatRequested(id: Int32, accessHash: Int64, date: Int32, adminId: Int32, participantId: Int32, gA: Buffer) @@ -13167,6 +14818,21 @@ extension Api { serializeInt32(id, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .encryptedChatEmpty(let id): + return ("encryptedChatEmpty", [("id", id)]) + case .encryptedChatWaiting(let id, let accessHash, let date, let adminId, let participantId): + return ("encryptedChatWaiting", [("id", id), ("accessHash", accessHash), ("date", date), ("adminId", adminId), ("participantId", participantId)]) + case .encryptedChatRequested(let id, let accessHash, let date, let adminId, let participantId, let gA): + return ("encryptedChatRequested", [("id", id), ("accessHash", accessHash), ("date", date), ("adminId", adminId), ("participantId", participantId), ("gA", gA)]) + case .encryptedChat(let id, let accessHash, let date, let adminId, let participantId, let gAOrB, let keyFingerprint): + return ("encryptedChat", [("id", id), ("accessHash", accessHash), ("date", date), ("adminId", adminId), ("participantId", participantId), ("gAOrB", gAOrB), ("keyFingerprint", keyFingerprint)]) + case .encryptedChatDiscarded(let id): + return ("encryptedChatDiscarded", [("id", id)]) + } } static func parse_encryptedChatEmpty(_ reader: BufferReader) -> EncryptedChat? { @@ -13271,7 +14937,7 @@ extension Api { } } - enum Document { + enum Document: TypeConstructorDescription { case documentEmpty(id: Int64) case document(id: Int64, accessHash: Int64, date: Int32, mimeType: String, size: Int32, thumb: Api.PhotoSize, dcId: Int32, version: Int32, attributes: [Api.DocumentAttribute]) @@ -13302,6 +14968,15 @@ extension Api { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .documentEmpty(let id): + return ("documentEmpty", [("id", id)]) + case .document(let id, let accessHash, let date, let mimeType, let size, let thumb, let dcId, let version, let attributes): + return ("document", [("id", id), ("accessHash", accessHash), ("date", date), ("mimeType", mimeType), ("size", size), ("thumb", thumb), ("dcId", dcId), ("version", version), ("attributes", attributes)]) + } } static func parse_documentEmpty(_ reader: BufferReader) -> Document? { @@ -13356,7 +15031,7 @@ extension Api { } } - enum WebAuthorization { + enum WebAuthorization: TypeConstructorDescription { case webAuthorization(hash: Int64, botId: Int32, domain: String, browser: String, platform: String, dateCreated: Int32, dateActive: Int32, ip: String, region: String) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -13376,6 +15051,13 @@ extension Api { serializeString(region, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .webAuthorization(let hash, let botId, let domain, let browser, let platform, let dateCreated, let dateActive, let ip, let region): + return ("webAuthorization", [("hash", hash), ("botId", botId), ("domain", domain), ("browser", browser), ("platform", platform), ("dateCreated", dateCreated), ("dateActive", dateActive), ("ip", ip), ("region", region)]) + } } static func parse_webAuthorization(_ reader: BufferReader) -> WebAuthorization? { @@ -13415,7 +15097,7 @@ extension Api { } } - enum ImportedContact { + enum ImportedContact: TypeConstructorDescription { case importedContact(userId: Int32, clientId: Int64) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -13428,6 +15110,13 @@ extension Api { serializeInt64(clientId, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .importedContact(let userId, let clientId): + return ("importedContact", [("userId", userId), ("clientId", clientId)]) + } } static func parse_importedContact(_ reader: BufferReader) -> ImportedContact? { diff --git a/TelegramCore/Api2.swift b/TelegramCore/Api2.swift index f446ac73f5..8bd5fead9e 100644 --- a/TelegramCore/Api2.swift +++ b/TelegramCore/Api2.swift @@ -1,6 +1,6 @@ extension Api { struct channels { - enum ChannelParticipants { + enum ChannelParticipants: TypeConstructorDescription { case channelParticipants(count: Int32, participants: [Api.ChannelParticipant], users: [Api.User]) case channelParticipantsNotModified @@ -29,6 +29,15 @@ struct channels { break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .channelParticipants(let count, let participants, let users): + return ("channelParticipants", [("count", count), ("participants", participants), ("users", users)]) + case .channelParticipantsNotModified: + return ("channelParticipantsNotModified", []) + } } static func parse_channelParticipants(_ reader: BufferReader) -> ChannelParticipants? { @@ -57,7 +66,7 @@ struct channels { } } - enum ChannelParticipant { + enum ChannelParticipant: TypeConstructorDescription { case channelParticipant(participant: Api.ChannelParticipant, users: [Api.User]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -74,6 +83,13 @@ struct channels { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .channelParticipant(let participant, let users): + return ("channelParticipant", [("participant", participant), ("users", users)]) + } } static func parse_channelParticipant(_ reader: BufferReader) -> ChannelParticipant? { @@ -96,7 +112,7 @@ struct channels { } } - enum AdminLogResults { + enum AdminLogResults: TypeConstructorDescription { case adminLogResults(events: [Api.ChannelAdminLogEvent], chats: [Api.Chat], users: [Api.User]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -122,6 +138,13 @@ struct channels { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .adminLogResults(let events, let chats, let users): + return ("adminLogResults", [("events", events), ("chats", chats), ("users", users)]) + } } static func parse_adminLogResults(_ reader: BufferReader) -> AdminLogResults? { @@ -153,7 +176,7 @@ struct channels { } extension Api { struct payments { - enum ValidatedRequestedInfo { + enum ValidatedRequestedInfo: TypeConstructorDescription { case validatedRequestedInfo(flags: Int32, id: String?, shippingOptions: [Api.ShippingOption]?) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -171,6 +194,13 @@ struct payments { }} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .validatedRequestedInfo(let flags, let id, let shippingOptions): + return ("validatedRequestedInfo", [("flags", flags), ("id", id), ("shippingOptions", shippingOptions)]) + } } static func parse_validatedRequestedInfo(_ reader: BufferReader) -> ValidatedRequestedInfo? { @@ -194,7 +224,7 @@ struct payments { } } - enum PaymentResult { + enum PaymentResult: TypeConstructorDescription { case paymentResult(updates: Api.Updates) case paymentVerficationNeeded(url: String) @@ -213,6 +243,15 @@ struct payments { serializeString(url, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .paymentResult(let updates): + return ("paymentResult", [("updates", updates)]) + case .paymentVerficationNeeded(let url): + return ("paymentVerficationNeeded", [("url", url)]) + } } static func parse_paymentResult(_ reader: BufferReader) -> PaymentResult? { @@ -241,7 +280,7 @@ struct payments { } } - enum PaymentForm { + enum PaymentForm: TypeConstructorDescription { case paymentForm(flags: Int32, botId: Int32, invoice: Api.Invoice, providerId: Int32, url: String, nativeProvider: String?, nativeParams: Api.DataJSON?, savedInfo: Api.PaymentRequestedInfo?, savedCredentials: Api.PaymentSavedCredentials?, users: [Api.User]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -266,6 +305,13 @@ struct payments { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .paymentForm(let flags, let botId, let invoice, let providerId, let url, let nativeProvider, let nativeParams, let savedInfo, let savedCredentials, let users): + return ("paymentForm", [("flags", flags), ("botId", botId), ("invoice", invoice), ("providerId", providerId), ("url", url), ("nativeProvider", nativeProvider), ("nativeParams", nativeParams), ("savedInfo", savedInfo), ("savedCredentials", savedCredentials), ("users", users)]) + } } static func parse_paymentForm(_ reader: BufferReader) -> PaymentForm? { @@ -318,7 +364,7 @@ struct payments { } } - enum PaymentReceipt { + enum PaymentReceipt: TypeConstructorDescription { case paymentReceipt(flags: Int32, date: Int32, botId: Int32, invoice: Api.Invoice, providerId: Int32, info: Api.PaymentRequestedInfo?, shipping: Api.ShippingOption?, currency: String, totalAmount: Int64, credentialsTitle: String, users: [Api.User]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -344,6 +390,13 @@ struct payments { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .paymentReceipt(let flags, let date, let botId, let invoice, let providerId, let info, let shipping, let currency, let totalAmount, let credentialsTitle, let users): + return ("paymentReceipt", [("flags", flags), ("date", date), ("botId", botId), ("invoice", invoice), ("providerId", providerId), ("info", info), ("shipping", shipping), ("currency", currency), ("totalAmount", totalAmount), ("credentialsTitle", credentialsTitle), ("users", users)]) + } } static func parse_paymentReceipt(_ reader: BufferReader) -> PaymentReceipt? { @@ -397,7 +450,7 @@ struct payments { } } - enum SavedInfo { + enum SavedInfo: TypeConstructorDescription { case savedInfo(flags: Int32, savedInfo: Api.PaymentRequestedInfo?) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -410,6 +463,13 @@ struct payments { if Int(flags) & Int(1 << 0) != 0 {savedInfo!.serialize(buffer, true)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .savedInfo(let flags, let savedInfo): + return ("savedInfo", [("flags", flags), ("savedInfo", savedInfo)]) + } } static func parse_savedInfo(_ reader: BufferReader) -> SavedInfo? { @@ -434,7 +494,7 @@ struct payments { } extension Api { struct auth { - enum Authorization { + enum Authorization: TypeConstructorDescription { case authorization(flags: Int32, tmpSessions: Int32?, user: Api.User) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -448,6 +508,13 @@ struct auth { user.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .authorization(let flags, let tmpSessions, let user): + return ("authorization", [("flags", flags), ("tmpSessions", tmpSessions), ("user", user)]) + } } static func parse_authorization(_ reader: BufferReader) -> Authorization? { @@ -471,7 +538,7 @@ struct auth { } } - enum PasswordRecovery { + enum PasswordRecovery: TypeConstructorDescription { case passwordRecovery(emailPattern: String) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -483,6 +550,13 @@ struct auth { serializeString(emailPattern, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .passwordRecovery(let emailPattern): + return ("passwordRecovery", [("emailPattern", emailPattern)]) + } } static func parse_passwordRecovery(_ reader: BufferReader) -> PasswordRecovery? { @@ -498,7 +572,7 @@ struct auth { } } - enum ExportedAuthorization { + enum ExportedAuthorization: TypeConstructorDescription { case exportedAuthorization(id: Int32, bytes: Buffer) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -511,6 +585,13 @@ struct auth { serializeBytes(bytes, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .exportedAuthorization(let id, let bytes): + return ("exportedAuthorization", [("id", id), ("bytes", bytes)]) + } } static func parse_exportedAuthorization(_ reader: BufferReader) -> ExportedAuthorization? { @@ -529,7 +610,7 @@ struct auth { } } - enum CheckedPhone { + enum CheckedPhone: TypeConstructorDescription { case checkedPhone(phoneRegistered: Api.Bool) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -541,6 +622,13 @@ struct auth { phoneRegistered.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .checkedPhone(let phoneRegistered): + return ("checkedPhone", [("phoneRegistered", phoneRegistered)]) + } } static func parse_checkedPhone(_ reader: BufferReader) -> CheckedPhone? { @@ -558,7 +646,7 @@ struct auth { } } - enum SentCode { + enum SentCode: TypeConstructorDescription { case sentCode(flags: Int32, type: Api.auth.SentCodeType, phoneCodeHash: String, nextType: Api.auth.CodeType?, timeout: Int32?, termsOfService: Api.help.TermsOfService?) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -575,6 +663,13 @@ struct auth { if Int(flags) & Int(1 << 3) != 0 {termsOfService!.serialize(buffer, true)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .sentCode(let flags, let type, let phoneCodeHash, let nextType, let timeout, let termsOfService): + return ("sentCode", [("flags", flags), ("type", type), ("phoneCodeHash", phoneCodeHash), ("nextType", nextType), ("timeout", timeout), ("termsOfService", termsOfService)]) + } } static func parse_sentCode(_ reader: BufferReader) -> SentCode? { @@ -611,7 +706,7 @@ struct auth { } } - enum CodeType { + enum CodeType: TypeConstructorDescription { case codeTypeSms case codeTypeCall case codeTypeFlashCall @@ -637,6 +732,17 @@ struct auth { break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .codeTypeSms: + return ("codeTypeSms", []) + case .codeTypeCall: + return ("codeTypeCall", []) + case .codeTypeFlashCall: + return ("codeTypeFlashCall", []) + } } static func parse_codeTypeSms(_ reader: BufferReader) -> CodeType? { @@ -650,7 +756,7 @@ struct auth { } } - enum SentCodeType { + enum SentCodeType: TypeConstructorDescription { case sentCodeTypeApp(length: Int32) case sentCodeTypeSms(length: Int32) case sentCodeTypeCall(length: Int32) @@ -683,6 +789,19 @@ struct auth { serializeString(pattern, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .sentCodeTypeApp(let length): + return ("sentCodeTypeApp", [("length", length)]) + case .sentCodeTypeSms(let length): + return ("sentCodeTypeSms", [("length", length)]) + case .sentCodeTypeCall(let length): + return ("sentCodeTypeCall", [("length", length)]) + case .sentCodeTypeFlashCall(let pattern): + return ("sentCodeTypeFlashCall", [("pattern", pattern)]) + } } static func parse_sentCodeTypeApp(_ reader: BufferReader) -> SentCodeType? { @@ -735,7 +854,7 @@ struct auth { } extension Api { struct contacts { - enum Blocked { + enum Blocked: TypeConstructorDescription { case blocked(blocked: [Api.ContactBlocked], users: [Api.User]) case blockedSlice(count: Int32, blocked: [Api.ContactBlocked], users: [Api.User]) @@ -773,6 +892,15 @@ struct contacts { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .blocked(let blocked, let users): + return ("blocked", [("blocked", blocked), ("users", users)]) + case .blockedSlice(let count, let blocked, let users): + return ("blockedSlice", [("count", count), ("blocked", blocked), ("users", users)]) + } } static func parse_blocked(_ reader: BufferReader) -> Blocked? { @@ -816,7 +944,7 @@ struct contacts { } } - enum Contacts { + enum Contacts: TypeConstructorDescription { case contactsNotModified case contacts(contacts: [Api.Contact], savedCount: Int32, users: [Api.User]) @@ -845,6 +973,15 @@ struct contacts { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .contactsNotModified: + return ("contactsNotModified", []) + case .contacts(let contacts, let savedCount, let users): + return ("contacts", [("contacts", contacts), ("savedCount", savedCount), ("users", users)]) + } } static func parse_contactsNotModified(_ reader: BufferReader) -> Contacts? { @@ -873,7 +1010,7 @@ struct contacts { } } - enum ResolvedPeer { + enum ResolvedPeer: TypeConstructorDescription { case resolvedPeer(peer: Api.Peer, chats: [Api.Chat], users: [Api.User]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -895,6 +1032,13 @@ struct contacts { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .resolvedPeer(let peer, let chats, let users): + return ("resolvedPeer", [("peer", peer), ("chats", chats), ("users", users)]) + } } static func parse_resolvedPeer(_ reader: BufferReader) -> ResolvedPeer? { @@ -922,7 +1066,7 @@ struct contacts { } } - enum Link { + enum Link: TypeConstructorDescription { case link(myLink: Api.ContactLink, foreignLink: Api.ContactLink, user: Api.User) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -936,6 +1080,13 @@ struct contacts { user.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .link(let myLink, let foreignLink, let user): + return ("link", [("myLink", myLink), ("foreignLink", foreignLink), ("user", user)]) + } } static func parse_link(_ reader: BufferReader) -> Link? { @@ -963,7 +1114,7 @@ struct contacts { } } - enum ImportedContacts { + enum ImportedContacts: TypeConstructorDescription { case importedContacts(imported: [Api.ImportedContact], popularInvites: [Api.PopularContact], retryContacts: [Int64], users: [Api.User]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -994,6 +1145,13 @@ struct contacts { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .importedContacts(let imported, let popularInvites, let retryContacts, let users): + return ("importedContacts", [("imported", imported), ("popularInvites", popularInvites), ("retryContacts", retryContacts), ("users", users)]) + } } static func parse_importedContacts(_ reader: BufferReader) -> ImportedContacts? { @@ -1026,7 +1184,7 @@ struct contacts { } } - enum Found { + enum Found: TypeConstructorDescription { case found(myResults: [Api.Peer], results: [Api.Peer], chats: [Api.Chat], users: [Api.User]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1057,6 +1215,13 @@ struct contacts { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .found(let myResults, let results, let chats, let users): + return ("found", [("myResults", myResults), ("results", results), ("chats", chats), ("users", users)]) + } } static func parse_found(_ reader: BufferReader) -> Found? { @@ -1089,7 +1254,7 @@ struct contacts { } } - enum TopPeers { + enum TopPeers: TypeConstructorDescription { case topPeersNotModified case topPeers(categories: [Api.TopPeerCategoryPeers], chats: [Api.Chat], users: [Api.User]) @@ -1122,6 +1287,15 @@ struct contacts { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .topPeersNotModified: + return ("topPeersNotModified", []) + case .topPeers(let categories, let chats, let users): + return ("topPeers", [("categories", categories), ("chats", chats), ("users", users)]) + } } static func parse_topPeersNotModified(_ reader: BufferReader) -> TopPeers? { @@ -1156,7 +1330,7 @@ struct contacts { } extension Api { struct help { - enum AppUpdate { + enum AppUpdate: TypeConstructorDescription { case appUpdate(id: Int32, critical: Api.Bool, url: String, text: String) case noAppUpdate @@ -1178,6 +1352,15 @@ struct help { break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .appUpdate(let id, let critical, let url, let text): + return ("appUpdate", [("id", id), ("critical", critical), ("url", url), ("text", text)]) + case .noAppUpdate: + return ("noAppUpdate", []) + } } static func parse_appUpdate(_ reader: BufferReader) -> AppUpdate? { @@ -1207,7 +1390,7 @@ struct help { } } - enum ProxyData { + enum ProxyData: TypeConstructorDescription { case proxyDataEmpty(expires: Int32) case proxyDataPromo(expires: Int32, peer: Api.Peer, chats: [Api.Chat], users: [Api.User]) @@ -1237,6 +1420,15 @@ struct help { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .proxyDataEmpty(let expires): + return ("proxyDataEmpty", [("expires", expires)]) + case .proxyDataPromo(let expires, let peer, let chats, let users): + return ("proxyDataPromo", [("expires", expires), ("peer", peer), ("chats", chats), ("users", users)]) + } } static func parse_proxyDataEmpty(_ reader: BufferReader) -> ProxyData? { @@ -1278,7 +1470,7 @@ struct help { } } - enum TermsOfService { + enum TermsOfService: TypeConstructorDescription { case termsOfService(flags: Int32, id: Api.DataJSON, text: String, entities: [Api.MessageEntity], minAgeConfirm: Int32?) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1298,6 +1490,13 @@ struct help { if Int(flags) & Int(1 << 1) != 0 {serializeInt32(minAgeConfirm!, buffer: buffer, boxed: false)} break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .termsOfService(let flags, let id, let text, let entities, let minAgeConfirm): + return ("termsOfService", [("flags", flags), ("id", id), ("text", text), ("entities", entities), ("minAgeConfirm", minAgeConfirm)]) + } } static func parse_termsOfService(_ reader: BufferReader) -> TermsOfService? { @@ -1329,7 +1528,7 @@ struct help { } } - enum RecentMeUrls { + enum RecentMeUrls: TypeConstructorDescription { case recentMeUrls(urls: [Api.RecentMeUrl], chats: [Api.Chat], users: [Api.User]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1355,6 +1554,13 @@ struct help { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .recentMeUrls(let urls, let chats, let users): + return ("recentMeUrls", [("urls", urls), ("chats", chats), ("users", users)]) + } } static func parse_recentMeUrls(_ reader: BufferReader) -> RecentMeUrls? { @@ -1382,7 +1588,7 @@ struct help { } } - enum Support { + enum Support: TypeConstructorDescription { case support(phoneNumber: String, user: Api.User) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1395,6 +1601,13 @@ struct help { user.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .support(let phoneNumber, let user): + return ("support", [("phoneNumber", phoneNumber), ("user", user)]) + } } static func parse_support(_ reader: BufferReader) -> Support? { @@ -1415,7 +1628,7 @@ struct help { } } - enum InviteText { + enum InviteText: TypeConstructorDescription { case inviteText(message: String) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1427,6 +1640,13 @@ struct help { serializeString(message, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .inviteText(let message): + return ("inviteText", [("message", message)]) + } } static func parse_inviteText(_ reader: BufferReader) -> InviteText? { @@ -1442,7 +1662,7 @@ struct help { } } - enum TermsOfServiceUpdate { + enum TermsOfServiceUpdate: TypeConstructorDescription { case termsOfServiceUpdateEmpty(expires: Int32) case termsOfServiceUpdate(expires: Int32, termsOfService: Api.help.TermsOfService) @@ -1462,6 +1682,15 @@ struct help { termsOfService.serialize(buffer, true) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .termsOfServiceUpdateEmpty(let expires): + return ("termsOfServiceUpdateEmpty", [("expires", expires)]) + case .termsOfServiceUpdate(let expires, let termsOfService): + return ("termsOfServiceUpdate", [("expires", expires), ("termsOfService", termsOfService)]) + } } static func parse_termsOfServiceUpdateEmpty(_ reader: BufferReader) -> TermsOfServiceUpdate? { @@ -1497,7 +1726,7 @@ struct help { } extension Api { struct updates { - enum Difference { + enum Difference: TypeConstructorDescription { case differenceEmpty(date: Int32, seq: Int32) case difference(newMessages: [Api.Message], newEncryptedMessages: [Api.EncryptedMessage], otherUpdates: [Api.Update], chats: [Api.Chat], users: [Api.User], state: Api.updates.State) case differenceSlice(newMessages: [Api.Message], newEncryptedMessages: [Api.EncryptedMessage], otherUpdates: [Api.Update], chats: [Api.Chat], users: [Api.User], intermediateState: Api.updates.State) @@ -1581,6 +1810,19 @@ struct updates { serializeInt32(pts, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .differenceEmpty(let date, let seq): + return ("differenceEmpty", [("date", date), ("seq", seq)]) + case .difference(let newMessages, let newEncryptedMessages, let otherUpdates, let chats, let users, let state): + return ("difference", [("newMessages", newMessages), ("newEncryptedMessages", newEncryptedMessages), ("otherUpdates", otherUpdates), ("chats", chats), ("users", users), ("state", state)]) + case .differenceSlice(let newMessages, let newEncryptedMessages, let otherUpdates, let chats, let users, let intermediateState): + return ("differenceSlice", [("newMessages", newMessages), ("newEncryptedMessages", newEncryptedMessages), ("otherUpdates", otherUpdates), ("chats", chats), ("users", users), ("intermediateState", intermediateState)]) + case .differenceTooLong(let pts): + return ("differenceTooLong", [("pts", pts)]) + } } static func parse_differenceEmpty(_ reader: BufferReader) -> Difference? { @@ -1686,7 +1928,7 @@ struct updates { } } - enum State { + enum State: TypeConstructorDescription { case state(pts: Int32, qts: Int32, date: Int32, seq: Int32, unreadCount: Int32) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1702,6 +1944,13 @@ struct updates { serializeInt32(unreadCount, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .state(let pts, let qts, let date, let seq, let unreadCount): + return ("state", [("pts", pts), ("qts", qts), ("date", date), ("seq", seq), ("unreadCount", unreadCount)]) + } } static func parse_state(_ reader: BufferReader) -> State? { @@ -1729,7 +1978,7 @@ struct updates { } } - enum ChannelDifference { + enum ChannelDifference: TypeConstructorDescription { case channelDifferenceEmpty(flags: Int32, pts: Int32, timeout: Int32?) case channelDifferenceTooLong(flags: Int32, pts: Int32, timeout: Int32?, topMessage: Int32, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, unreadMentionsCount: Int32, messages: [Api.Message], chats: [Api.Chat], users: [Api.User]) case channelDifference(flags: Int32, pts: Int32, timeout: Int32?, newMessages: [Api.Message], otherUpdates: [Api.Update], chats: [Api.Chat], users: [Api.User]) @@ -1801,6 +2050,17 @@ struct updates { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .channelDifferenceEmpty(let flags, let pts, let timeout): + return ("channelDifferenceEmpty", [("flags", flags), ("pts", pts), ("timeout", timeout)]) + case .channelDifferenceTooLong(let flags, let pts, let timeout, let topMessage, let readInboxMaxId, let readOutboxMaxId, let unreadCount, let unreadMentionsCount, let messages, let chats, let users): + return ("channelDifferenceTooLong", [("flags", flags), ("pts", pts), ("timeout", timeout), ("topMessage", topMessage), ("readInboxMaxId", readInboxMaxId), ("readOutboxMaxId", readOutboxMaxId), ("unreadCount", unreadCount), ("unreadMentionsCount", unreadMentionsCount), ("messages", messages), ("chats", chats), ("users", users)]) + case .channelDifference(let flags, let pts, let timeout, let newMessages, let otherUpdates, let chats, let users): + return ("channelDifference", [("flags", flags), ("pts", pts), ("timeout", timeout), ("newMessages", newMessages), ("otherUpdates", otherUpdates), ("chats", chats), ("users", users)]) + } } static func parse_channelDifferenceEmpty(_ reader: BufferReader) -> ChannelDifference? { @@ -1910,7 +2170,7 @@ struct updates { } extension Api { struct upload { - enum WebFile { + enum WebFile: TypeConstructorDescription { case webFile(size: Int32, mimeType: String, fileType: Api.storage.FileType, mtime: Int32, bytes: Buffer) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -1926,6 +2186,13 @@ struct upload { serializeBytes(bytes, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .webFile(let size, let mimeType, let fileType, let mtime, let bytes): + return ("webFile", [("size", size), ("mimeType", mimeType), ("fileType", fileType), ("mtime", mtime), ("bytes", bytes)]) + } } static func parse_webFile(_ reader: BufferReader) -> WebFile? { @@ -1955,7 +2222,7 @@ struct upload { } } - enum File { + enum File: TypeConstructorDescription { case file(type: Api.storage.FileType, mtime: Int32, bytes: Buffer) case fileCdnRedirect(dcId: Int32, fileToken: Buffer, encryptionKey: Buffer, encryptionIv: Buffer, fileHashes: [Api.FileHash]) @@ -1984,6 +2251,15 @@ struct upload { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .file(let type, let mtime, let bytes): + return ("file", [("type", type), ("mtime", mtime), ("bytes", bytes)]) + case .fileCdnRedirect(let dcId, let fileToken, let encryptionKey, let encryptionIv, let fileHashes): + return ("fileCdnRedirect", [("dcId", dcId), ("fileToken", fileToken), ("encryptionKey", encryptionKey), ("encryptionIv", encryptionIv), ("fileHashes", fileHashes)]) + } } static func parse_file(_ reader: BufferReader) -> File? { @@ -2032,7 +2308,7 @@ struct upload { } } - enum CdnFile { + enum CdnFile: TypeConstructorDescription { case cdnFileReuploadNeeded(requestToken: Buffer) case cdnFile(bytes: Buffer) @@ -2051,6 +2327,15 @@ struct upload { serializeBytes(bytes, buffer: buffer, boxed: false) break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .cdnFileReuploadNeeded(let requestToken): + return ("cdnFileReuploadNeeded", [("requestToken", requestToken)]) + case .cdnFile(let bytes): + return ("cdnFile", [("bytes", bytes)]) + } } static func parse_cdnFileReuploadNeeded(_ reader: BufferReader) -> CdnFile? { @@ -2079,407 +2364,3 @@ struct upload { } } } -extension Api { -struct storage { - enum FileType { - case fileUnknown - case filePartial - case fileJpeg - case fileGif - case filePng - case filePdf - case fileMp3 - case fileMov - case fileMp4 - case fileWebp - - func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .fileUnknown: - if boxed { - buffer.appendInt32(-1432995067) - } - - break - case .filePartial: - if boxed { - buffer.appendInt32(1086091090) - } - - break - case .fileJpeg: - if boxed { - buffer.appendInt32(8322574) - } - - break - case .fileGif: - if boxed { - buffer.appendInt32(-891180321) - } - - break - case .filePng: - if boxed { - buffer.appendInt32(172975040) - } - - break - case .filePdf: - if boxed { - buffer.appendInt32(-1373745011) - } - - break - case .fileMp3: - if boxed { - buffer.appendInt32(1384777335) - } - - break - case .fileMov: - if boxed { - buffer.appendInt32(1258941372) - } - - break - case .fileMp4: - if boxed { - buffer.appendInt32(-1278304028) - } - - break - case .fileWebp: - if boxed { - buffer.appendInt32(276907596) - } - - break - } - } - - static func parse_fileUnknown(_ reader: BufferReader) -> FileType? { - return Api.storage.FileType.fileUnknown - } - static func parse_filePartial(_ reader: BufferReader) -> FileType? { - return Api.storage.FileType.filePartial - } - static func parse_fileJpeg(_ reader: BufferReader) -> FileType? { - return Api.storage.FileType.fileJpeg - } - static func parse_fileGif(_ reader: BufferReader) -> FileType? { - return Api.storage.FileType.fileGif - } - static func parse_filePng(_ reader: BufferReader) -> FileType? { - return Api.storage.FileType.filePng - } - static func parse_filePdf(_ reader: BufferReader) -> FileType? { - return Api.storage.FileType.filePdf - } - static func parse_fileMp3(_ reader: BufferReader) -> FileType? { - return Api.storage.FileType.fileMp3 - } - static func parse_fileMov(_ reader: BufferReader) -> FileType? { - return Api.storage.FileType.fileMov - } - static func parse_fileMp4(_ reader: BufferReader) -> FileType? { - return Api.storage.FileType.fileMp4 - } - static func parse_fileWebp(_ reader: BufferReader) -> FileType? { - return Api.storage.FileType.fileWebp - } - - } -} -} -extension Api { -struct account { - enum TmpPassword { - case tmpPassword(tmpPassword: Buffer, validUntil: Int32) - - func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .tmpPassword(let tmpPassword, let validUntil): - if boxed { - buffer.appendInt32(-614138572) - } - serializeBytes(tmpPassword, buffer: buffer, boxed: false) - serializeInt32(validUntil, buffer: buffer, boxed: false) - break - } - } - - static func parse_tmpPassword(_ reader: BufferReader) -> TmpPassword? { - var _1: Buffer? - _1 = parseBytes(reader) - var _2: Int32? - _2 = reader.readInt32() - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.account.TmpPassword.tmpPassword(tmpPassword: _1!, validUntil: _2!) - } - else { - return nil - } - } - - } - enum PasswordSettings { - case passwordSettings(email: String) - - func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .passwordSettings(let email): - if boxed { - buffer.appendInt32(-1212732749) - } - serializeString(email, buffer: buffer, boxed: false) - break - } - } - - static func parse_passwordSettings(_ reader: BufferReader) -> PasswordSettings? { - var _1: String? - _1 = parseString(reader) - let _c1 = _1 != nil - if _c1 { - return Api.account.PasswordSettings.passwordSettings(email: _1!) - } - else { - return nil - } - } - - } - enum PasswordInputSettings { - case passwordInputSettings(flags: Int32, newSalt: Buffer?, newPasswordHash: Buffer?, hint: String?, email: String?) - - func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .passwordInputSettings(let flags, let newSalt, let newPasswordHash, let hint, let email): - if boxed { - buffer.appendInt32(-2037289493) - } - serializeInt32(flags, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 0) != 0 {serializeBytes(newSalt!, buffer: buffer, boxed: false)} - if Int(flags) & Int(1 << 0) != 0 {serializeBytes(newPasswordHash!, buffer: buffer, boxed: false)} - if Int(flags) & Int(1 << 0) != 0 {serializeString(hint!, buffer: buffer, boxed: false)} - if Int(flags) & Int(1 << 1) != 0 {serializeString(email!, buffer: buffer, boxed: false)} - break - } - } - - static func parse_passwordInputSettings(_ reader: BufferReader) -> PasswordInputSettings? { - var _1: Int32? - _1 = reader.readInt32() - var _2: Buffer? - if Int(_1!) & Int(1 << 0) != 0 {_2 = parseBytes(reader) } - var _3: Buffer? - if Int(_1!) & Int(1 << 0) != 0 {_3 = parseBytes(reader) } - var _4: String? - if Int(_1!) & Int(1 << 0) != 0 {_4 = parseString(reader) } - var _5: String? - if Int(_1!) & Int(1 << 1) != 0 {_5 = parseString(reader) } - let _c1 = _1 != nil - let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil - let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil - let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil - let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 { - return Api.account.PasswordInputSettings.passwordInputSettings(flags: _1!, newSalt: _2, newPasswordHash: _3, hint: _4, email: _5) - } - else { - return nil - } - } - - } - enum WebAuthorizations { - case webAuthorizations(authorizations: [Api.WebAuthorization], users: [Api.User]) - - func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .webAuthorizations(let authorizations, let users): - if boxed { - buffer.appendInt32(-313079300) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(authorizations.count)) - for item in authorizations { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(users.count)) - for item in users { - item.serialize(buffer, true) - } - break - } - } - - static func parse_webAuthorizations(_ reader: BufferReader) -> WebAuthorizations? { - var _1: [Api.WebAuthorization]? - if let _ = reader.readInt32() { - _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.WebAuthorization.self) - } - var _2: [Api.User]? - if let _ = reader.readInt32() { - _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) - } - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.account.WebAuthorizations.webAuthorizations(authorizations: _1!, users: _2!) - } - else { - return nil - } - } - - } - enum Authorizations { - case authorizations(authorizations: [Api.Authorization]) - - func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .authorizations(let authorizations): - if boxed { - buffer.appendInt32(307276766) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(authorizations.count)) - for item in authorizations { - item.serialize(buffer, true) - } - break - } - } - - static func parse_authorizations(_ reader: BufferReader) -> Authorizations? { - var _1: [Api.Authorization]? - if let _ = reader.readInt32() { - _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Authorization.self) - } - let _c1 = _1 != nil - if _c1 { - return Api.account.Authorizations.authorizations(authorizations: _1!) - } - else { - return nil - } - } - - } - enum Password { - case noPassword(newSalt: Buffer, emailUnconfirmedPattern: String) - case password(currentSalt: Buffer, newSalt: Buffer, hint: String, hasRecovery: Api.Bool, emailUnconfirmedPattern: String) - - func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .noPassword(let newSalt, let emailUnconfirmedPattern): - if boxed { - buffer.appendInt32(-1764049896) - } - serializeBytes(newSalt, buffer: buffer, boxed: false) - serializeString(emailUnconfirmedPattern, buffer: buffer, boxed: false) - break - case .password(let currentSalt, let newSalt, let hint, let hasRecovery, let emailUnconfirmedPattern): - if boxed { - buffer.appendInt32(2081952796) - } - serializeBytes(currentSalt, buffer: buffer, boxed: false) - serializeBytes(newSalt, buffer: buffer, boxed: false) - serializeString(hint, buffer: buffer, boxed: false) - hasRecovery.serialize(buffer, true) - serializeString(emailUnconfirmedPattern, buffer: buffer, boxed: false) - break - } - } - - static func parse_noPassword(_ reader: BufferReader) -> Password? { - var _1: Buffer? - _1 = parseBytes(reader) - var _2: String? - _2 = parseString(reader) - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.account.Password.noPassword(newSalt: _1!, emailUnconfirmedPattern: _2!) - } - else { - return nil - } - } - static func parse_password(_ reader: BufferReader) -> Password? { - var _1: Buffer? - _1 = parseBytes(reader) - var _2: Buffer? - _2 = parseBytes(reader) - var _3: String? - _3 = parseString(reader) - var _4: Api.Bool? - if let signature = reader.readInt32() { - _4 = Api.parse(reader, signature: signature) as? Api.Bool - } - var _5: String? - _5 = parseString(reader) - let _c1 = _1 != nil - let _c2 = _2 != nil - let _c3 = _3 != nil - let _c4 = _4 != nil - let _c5 = _5 != nil - if _c1 && _c2 && _c3 && _c4 && _c5 { - return Api.account.Password.password(currentSalt: _1!, newSalt: _2!, hint: _3!, hasRecovery: _4!, emailUnconfirmedPattern: _5!) - } - else { - return nil - } - } - - } - enum PrivacyRules { - case privacyRules(rules: [Api.PrivacyRule], users: [Api.User]) - - func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { - switch self { - case .privacyRules(let rules, let users): - if boxed { - buffer.appendInt32(1430961007) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(rules.count)) - for item in rules { - item.serialize(buffer, true) - } - buffer.appendInt32(481674261) - buffer.appendInt32(Int32(users.count)) - for item in users { - item.serialize(buffer, true) - } - break - } - } - - static func parse_privacyRules(_ reader: BufferReader) -> PrivacyRules? { - var _1: [Api.PrivacyRule]? - if let _ = reader.readInt32() { - _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PrivacyRule.self) - } - var _2: [Api.User]? - if let _ = reader.readInt32() { - _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) - } - let _c1 = _1 != nil - let _c2 = _2 != nil - if _c1 && _c2 { - return Api.account.PrivacyRules.privacyRules(rules: _1!, users: _2!) - } - else { - return nil - } - } - - } -} -} diff --git a/TelegramCore/Api3.swift b/TelegramCore/Api3.swift index 336b2a69da..75ed718a40 100644 --- a/TelegramCore/Api3.swift +++ b/TelegramCore/Api3.swift @@ -1,6 +1,486 @@ extension Api { +struct storage { + enum FileType: TypeConstructorDescription { + case fileUnknown + case filePartial + case fileJpeg + case fileGif + case filePng + case filePdf + case fileMp3 + case fileMov + case fileMp4 + case fileWebp + + func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .fileUnknown: + if boxed { + buffer.appendInt32(-1432995067) + } + + break + case .filePartial: + if boxed { + buffer.appendInt32(1086091090) + } + + break + case .fileJpeg: + if boxed { + buffer.appendInt32(8322574) + } + + break + case .fileGif: + if boxed { + buffer.appendInt32(-891180321) + } + + break + case .filePng: + if boxed { + buffer.appendInt32(172975040) + } + + break + case .filePdf: + if boxed { + buffer.appendInt32(-1373745011) + } + + break + case .fileMp3: + if boxed { + buffer.appendInt32(1384777335) + } + + break + case .fileMov: + if boxed { + buffer.appendInt32(1258941372) + } + + break + case .fileMp4: + if boxed { + buffer.appendInt32(-1278304028) + } + + break + case .fileWebp: + if boxed { + buffer.appendInt32(276907596) + } + + break + } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .fileUnknown: + return ("fileUnknown", []) + case .filePartial: + return ("filePartial", []) + case .fileJpeg: + return ("fileJpeg", []) + case .fileGif: + return ("fileGif", []) + case .filePng: + return ("filePng", []) + case .filePdf: + return ("filePdf", []) + case .fileMp3: + return ("fileMp3", []) + case .fileMov: + return ("fileMov", []) + case .fileMp4: + return ("fileMp4", []) + case .fileWebp: + return ("fileWebp", []) + } + } + + static func parse_fileUnknown(_ reader: BufferReader) -> FileType? { + return Api.storage.FileType.fileUnknown + } + static func parse_filePartial(_ reader: BufferReader) -> FileType? { + return Api.storage.FileType.filePartial + } + static func parse_fileJpeg(_ reader: BufferReader) -> FileType? { + return Api.storage.FileType.fileJpeg + } + static func parse_fileGif(_ reader: BufferReader) -> FileType? { + return Api.storage.FileType.fileGif + } + static func parse_filePng(_ reader: BufferReader) -> FileType? { + return Api.storage.FileType.filePng + } + static func parse_filePdf(_ reader: BufferReader) -> FileType? { + return Api.storage.FileType.filePdf + } + static func parse_fileMp3(_ reader: BufferReader) -> FileType? { + return Api.storage.FileType.fileMp3 + } + static func parse_fileMov(_ reader: BufferReader) -> FileType? { + return Api.storage.FileType.fileMov + } + static func parse_fileMp4(_ reader: BufferReader) -> FileType? { + return Api.storage.FileType.fileMp4 + } + static func parse_fileWebp(_ reader: BufferReader) -> FileType? { + return Api.storage.FileType.fileWebp + } + + } +} +} +extension Api { +struct account { + enum TmpPassword: TypeConstructorDescription { + case tmpPassword(tmpPassword: Buffer, validUntil: Int32) + + func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .tmpPassword(let tmpPassword, let validUntil): + if boxed { + buffer.appendInt32(-614138572) + } + serializeBytes(tmpPassword, buffer: buffer, boxed: false) + serializeInt32(validUntil, buffer: buffer, boxed: false) + break + } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .tmpPassword(let tmpPassword, let validUntil): + return ("tmpPassword", [("tmpPassword", tmpPassword), ("validUntil", validUntil)]) + } + } + + static func parse_tmpPassword(_ reader: BufferReader) -> TmpPassword? { + var _1: Buffer? + _1 = parseBytes(reader) + var _2: Int32? + _2 = reader.readInt32() + let _c1 = _1 != nil + let _c2 = _2 != nil + if _c1 && _c2 { + return Api.account.TmpPassword.tmpPassword(tmpPassword: _1!, validUntil: _2!) + } + else { + return nil + } + } + + } + enum PasswordSettings: TypeConstructorDescription { + case passwordSettings(email: String) + + func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .passwordSettings(let email): + if boxed { + buffer.appendInt32(-1212732749) + } + serializeString(email, buffer: buffer, boxed: false) + break + } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .passwordSettings(let email): + return ("passwordSettings", [("email", email)]) + } + } + + static func parse_passwordSettings(_ reader: BufferReader) -> PasswordSettings? { + var _1: String? + _1 = parseString(reader) + let _c1 = _1 != nil + if _c1 { + return Api.account.PasswordSettings.passwordSettings(email: _1!) + } + else { + return nil + } + } + + } + enum PasswordInputSettings: TypeConstructorDescription { + case passwordInputSettings(flags: Int32, newSalt: Buffer?, newPasswordHash: Buffer?, hint: String?, email: String?) + + func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .passwordInputSettings(let flags, let newSalt, let newPasswordHash, let hint, let email): + if boxed { + buffer.appendInt32(-2037289493) + } + serializeInt32(flags, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 0) != 0 {serializeBytes(newSalt!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 0) != 0 {serializeBytes(newPasswordHash!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 0) != 0 {serializeString(hint!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 1) != 0 {serializeString(email!, buffer: buffer, boxed: false)} + break + } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .passwordInputSettings(let flags, let newSalt, let newPasswordHash, let hint, let email): + return ("passwordInputSettings", [("flags", flags), ("newSalt", newSalt), ("newPasswordHash", newPasswordHash), ("hint", hint), ("email", email)]) + } + } + + static func parse_passwordInputSettings(_ reader: BufferReader) -> PasswordInputSettings? { + var _1: Int32? + _1 = reader.readInt32() + var _2: Buffer? + if Int(_1!) & Int(1 << 0) != 0 {_2 = parseBytes(reader) } + var _3: Buffer? + if Int(_1!) & Int(1 << 0) != 0 {_3 = parseBytes(reader) } + var _4: String? + if Int(_1!) & Int(1 << 0) != 0 {_4 = parseString(reader) } + var _5: String? + if Int(_1!) & Int(1 << 1) != 0 {_5 = parseString(reader) } + let _c1 = _1 != nil + let _c2 = (Int(_1!) & Int(1 << 0) == 0) || _2 != nil + let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil + let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil + let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 { + return Api.account.PasswordInputSettings.passwordInputSettings(flags: _1!, newSalt: _2, newPasswordHash: _3, hint: _4, email: _5) + } + else { + return nil + } + } + + } + enum WebAuthorizations: TypeConstructorDescription { + case webAuthorizations(authorizations: [Api.WebAuthorization], users: [Api.User]) + + func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .webAuthorizations(let authorizations, let users): + if boxed { + buffer.appendInt32(-313079300) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(authorizations.count)) + for item in authorizations { + item.serialize(buffer, true) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(users.count)) + for item in users { + item.serialize(buffer, true) + } + break + } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .webAuthorizations(let authorizations, let users): + return ("webAuthorizations", [("authorizations", authorizations), ("users", users)]) + } + } + + static func parse_webAuthorizations(_ reader: BufferReader) -> WebAuthorizations? { + var _1: [Api.WebAuthorization]? + if let _ = reader.readInt32() { + _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.WebAuthorization.self) + } + var _2: [Api.User]? + if let _ = reader.readInt32() { + _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) + } + let _c1 = _1 != nil + let _c2 = _2 != nil + if _c1 && _c2 { + return Api.account.WebAuthorizations.webAuthorizations(authorizations: _1!, users: _2!) + } + else { + return nil + } + } + + } + enum Authorizations: TypeConstructorDescription { + case authorizations(authorizations: [Api.Authorization]) + + func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .authorizations(let authorizations): + if boxed { + buffer.appendInt32(307276766) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(authorizations.count)) + for item in authorizations { + item.serialize(buffer, true) + } + break + } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .authorizations(let authorizations): + return ("authorizations", [("authorizations", authorizations)]) + } + } + + static func parse_authorizations(_ reader: BufferReader) -> Authorizations? { + var _1: [Api.Authorization]? + if let _ = reader.readInt32() { + _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Authorization.self) + } + let _c1 = _1 != nil + if _c1 { + return Api.account.Authorizations.authorizations(authorizations: _1!) + } + else { + return nil + } + } + + } + enum Password: TypeConstructorDescription { + case noPassword(newSalt: Buffer, emailUnconfirmedPattern: String) + case password(currentSalt: Buffer, newSalt: Buffer, hint: String, hasRecovery: Api.Bool, emailUnconfirmedPattern: String) + + func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .noPassword(let newSalt, let emailUnconfirmedPattern): + if boxed { + buffer.appendInt32(-1764049896) + } + serializeBytes(newSalt, buffer: buffer, boxed: false) + serializeString(emailUnconfirmedPattern, buffer: buffer, boxed: false) + break + case .password(let currentSalt, let newSalt, let hint, let hasRecovery, let emailUnconfirmedPattern): + if boxed { + buffer.appendInt32(2081952796) + } + serializeBytes(currentSalt, buffer: buffer, boxed: false) + serializeBytes(newSalt, buffer: buffer, boxed: false) + serializeString(hint, buffer: buffer, boxed: false) + hasRecovery.serialize(buffer, true) + serializeString(emailUnconfirmedPattern, buffer: buffer, boxed: false) + break + } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .noPassword(let newSalt, let emailUnconfirmedPattern): + return ("noPassword", [("newSalt", newSalt), ("emailUnconfirmedPattern", emailUnconfirmedPattern)]) + case .password(let currentSalt, let newSalt, let hint, let hasRecovery, let emailUnconfirmedPattern): + return ("password", [("currentSalt", currentSalt), ("newSalt", newSalt), ("hint", hint), ("hasRecovery", hasRecovery), ("emailUnconfirmedPattern", emailUnconfirmedPattern)]) + } + } + + static func parse_noPassword(_ reader: BufferReader) -> Password? { + var _1: Buffer? + _1 = parseBytes(reader) + var _2: String? + _2 = parseString(reader) + let _c1 = _1 != nil + let _c2 = _2 != nil + if _c1 && _c2 { + return Api.account.Password.noPassword(newSalt: _1!, emailUnconfirmedPattern: _2!) + } + else { + return nil + } + } + static func parse_password(_ reader: BufferReader) -> Password? { + var _1: Buffer? + _1 = parseBytes(reader) + var _2: Buffer? + _2 = parseBytes(reader) + var _3: String? + _3 = parseString(reader) + var _4: Api.Bool? + if let signature = reader.readInt32() { + _4 = Api.parse(reader, signature: signature) as? Api.Bool + } + var _5: String? + _5 = parseString(reader) + let _c1 = _1 != nil + let _c2 = _2 != nil + let _c3 = _3 != nil + let _c4 = _4 != nil + let _c5 = _5 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 { + return Api.account.Password.password(currentSalt: _1!, newSalt: _2!, hint: _3!, hasRecovery: _4!, emailUnconfirmedPattern: _5!) + } + else { + return nil + } + } + + } + enum PrivacyRules: TypeConstructorDescription { + case privacyRules(rules: [Api.PrivacyRule], users: [Api.User]) + + func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .privacyRules(let rules, let users): + if boxed { + buffer.appendInt32(1430961007) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(rules.count)) + for item in rules { + item.serialize(buffer, true) + } + buffer.appendInt32(481674261) + buffer.appendInt32(Int32(users.count)) + for item in users { + item.serialize(buffer, true) + } + break + } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .privacyRules(let rules, let users): + return ("privacyRules", [("rules", rules), ("users", users)]) + } + } + + static func parse_privacyRules(_ reader: BufferReader) -> PrivacyRules? { + var _1: [Api.PrivacyRule]? + if let _ = reader.readInt32() { + _1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.PrivacyRule.self) + } + var _2: [Api.User]? + if let _ = reader.readInt32() { + _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self) + } + let _c1 = _1 != nil + let _c2 = _2 != nil + if _c1 && _c2 { + return Api.account.PrivacyRules.privacyRules(rules: _1!, users: _2!) + } + else { + return nil + } + } + + } +} +} +extension Api { struct photos { - enum Photo { + enum Photo: TypeConstructorDescription { case photo(photo: Api.Photo, users: [Api.User]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -17,6 +497,13 @@ struct photos { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .photo(let photo, let users): + return ("photo", [("photo", photo), ("users", users)]) + } } static func parse_photo(_ reader: BufferReader) -> Photo? { @@ -39,7 +526,7 @@ struct photos { } } - enum Photos { + enum Photos: TypeConstructorDescription { case photos(photos: [Api.Photo], users: [Api.User]) case photosSlice(count: Int32, photos: [Api.Photo], users: [Api.User]) @@ -77,6 +564,15 @@ struct photos { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .photos(let photos, let users): + return ("photos", [("photos", photos), ("users", users)]) + case .photosSlice(let count, let photos, let users): + return ("photosSlice", [("count", count), ("photos", photos), ("users", users)]) + } } static func parse_photos(_ reader: BufferReader) -> Photos? { @@ -124,7 +620,7 @@ struct photos { } extension Api { struct phone { - enum PhoneCall { + enum PhoneCall: TypeConstructorDescription { case phoneCall(phoneCall: Api.PhoneCall, users: [Api.User]) func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -141,6 +637,13 @@ struct phone { } break } + } + + func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .phoneCall(let phoneCall, let users): + return ("phoneCall", [("phoneCall", phoneCall), ("users", users)]) + } } static func parse_phoneCall(_ reader: BufferReader) -> PhoneCall? { diff --git a/TelegramCore/ContactManagement.swift b/TelegramCore/ContactManagement.swift index 178a46218b..f18cd27eaf 100644 --- a/TelegramCore/ContactManagement.swift +++ b/TelegramCore/ContactManagement.swift @@ -7,19 +7,11 @@ import Foundation import SwiftSignalKit #endif import TelegramCorePrivateModule -#if swift(>=4.0) -import CommonCrypto -#endif -private func md5(_ data : Data) -> Data { - var res = Data() - res.count = Int(CC_MD5_DIGEST_LENGTH) - res.withUnsafeMutableBytes { mutableBytes -> Void in - data.withUnsafeBytes { bytes -> Void in - CC_MD5(bytes, CC_LONG(data.count), mutableBytes) - } +private func md5(_ data: Data) -> Data { + return data.withUnsafeBytes { bytes -> Data in + return CryptoMD5(bytes, Int32(data.count)) } - return res } private func updatedRemoteContactPeers(network: Network, hash: Int32) -> Signal<([Peer], [PeerId: PeerPresence], Int32)?, NoError> { diff --git a/TelegramCore/Crypto.h b/TelegramCore/Crypto.h new file mode 100644 index 0000000000..d50d4f1e40 --- /dev/null +++ b/TelegramCore/Crypto.h @@ -0,0 +1,22 @@ +#ifndef __CRYPTO_H_ +#define __CRYPTO_H_ + +#import + +NSData * _Nonnull CryptoMD5(const void *bytes, int count); +NSData * _Nonnull CryptoSHA1(const void *bytes, int count); +NSData * _Nonnull CryptoSHA256(const void *bytes, int count); +NSData * _Nonnull CryptoSHA512(const void *bytes, int count); + +@interface IncrementalMD5 : NSObject + +- (instancetype _Nonnull)init; +- (void)update:(NSData * _Nonnull)data; +- (void)update:(const void * _Nonnull)bytes count:(int)count; +- (NSData * _Nonnull)complete; + +@end + +NSData * _Nullable CryptoAES(bool encrypt, NSData * _Nonnull key, NSData * _Nonnull iv, NSData * _Nonnull data); + +#endif diff --git a/TelegramCore/Crypto.m b/TelegramCore/Crypto.m new file mode 100644 index 0000000000..67e727b384 --- /dev/null +++ b/TelegramCore/Crypto.m @@ -0,0 +1,78 @@ +#include "Crypto.h" + +#import + +NSData * _Nonnull CryptoMD5(const void *bytes, int count) { + NSMutableData *result = [[NSMutableData alloc] initWithLength:(NSUInteger)CC_MD5_DIGEST_LENGTH]; + CC_MD5(bytes, (CC_LONG)count, result.mutableBytes); + return result; +} + +NSData * _Nonnull CryptoSHA1(const void *bytes, int count) { + NSMutableData *result = [[NSMutableData alloc] initWithLength:(NSUInteger)CC_SHA1_DIGEST_LENGTH]; + CC_SHA1(bytes, (CC_LONG)count, result.mutableBytes); + return result; +} + +NSData * _Nonnull CryptoSHA256(const void *bytes, int count) { + NSMutableData *result = [[NSMutableData alloc] initWithLength:(NSUInteger)CC_SHA256_DIGEST_LENGTH]; + CC_SHA256(bytes, (CC_LONG)count, result.mutableBytes); + return result; +} + +NSData * _Nonnull CryptoSHA512(const void *bytes, int count) { + NSMutableData *result = [[NSMutableData alloc] initWithLength:(NSUInteger)CC_SHA512_DIGEST_LENGTH]; + CC_SHA512(bytes, (CC_LONG)count, result.mutableBytes); + return result; +} + +@interface IncrementalMD5 () { + CC_MD5_CTX _ctx; +} + +@end + +@implementation IncrementalMD5 + +- (instancetype _Nonnull)init { + self = [super init]; + if (self != nil) { + CC_MD5_Init(&_ctx); + } + return self; +} + +- (void)update:(NSData * _Nonnull)data { + CC_MD5_Update(&_ctx, data.bytes, (CC_LONG)data.length); +} + +- (void)update:(const void *)bytes count:(int)count { + CC_MD5_Update(&_ctx, bytes, (CC_LONG)count); +} + +- (NSData *)complete { + NSMutableData *result = [[NSMutableData alloc] initWithLength:(NSUInteger)CC_MD5_DIGEST_LENGTH]; + CC_MD5_Final(result.mutableBytes, &_ctx); + return result; +} + +@end + +NSData * _Nullable CryptoAES(bool encrypt, NSData * _Nonnull key, NSData * _Nonnull iv, NSData * _Nonnull data) { + if (key.length != 32) { + return nil; + } + if (iv.length != 32) { + return nil; + } + NSMutableData *processedData = [[NSMutableData alloc] initWithLength:data.length]; + size_t processedCount = 0; + CCStatus status = CCCrypt(encrypt ? kCCEncrypt : kCCDecrypt, kCCAlgorithmAES128, 0, key.bytes, key.length, iv.bytes, data.bytes, data.length, processedData.mutableBytes, processedData.length, &processedCount); + if (status != kCCSuccess) { + return nil; + } + if (processedCount != (size_t)processedData.length) { + return nil; + } + return processedData; +} diff --git a/TelegramCore/DeserializeFunctionResponse.swift b/TelegramCore/DeserializeFunctionResponse.swift index 0d126c3323..deec67021c 100644 --- a/TelegramCore/DeserializeFunctionResponse.swift +++ b/TelegramCore/DeserializeFunctionResponse.swift @@ -21,3 +21,7 @@ public final class DeserializeFunctionResponse { return self.f(buffer) } } + +protocol TypeConstructorDescription { + func descriptionFields() -> (String, [(String, Any)]) +} diff --git a/TelegramCore/MD5.swift b/TelegramCore/MD5.swift index a95f105a29..2eca98165a 100644 --- a/TelegramCore/MD5.swift +++ b/TelegramCore/MD5.swift @@ -6,17 +6,8 @@ import TelegramCorePrivateModule import Postbox #endif -#if swift(>=4.0) -import CommonCrypto -#endif - public extension MemoryBuffer { public func md5Digest() -> Data { - var res = Data() - res.count = Int(CC_MD5_DIGEST_LENGTH) - res.withUnsafeMutableBytes { mutableBytes -> Void in - CC_MD5(self.memory, CC_LONG(self.length), mutableBytes) - } - return res + return CryptoMD5(self.memory, Int32(self.length)) } } diff --git a/TelegramCore/MultipartUpload.swift b/TelegramCore/MultipartUpload.swift index 38431a03c3..9ebe87251a 100644 --- a/TelegramCore/MultipartUpload.swift +++ b/TelegramCore/MultipartUpload.swift @@ -9,9 +9,6 @@ import Foundation import MtProtoKitDynamic #endif import TelegramCorePrivateModule -#if swift(>=4.0) -import CommonCrypto -#endif #if os(macOS) private typealias SignalKitTimer = SwiftSignalKitMac.Timer @@ -51,15 +48,10 @@ private struct UploadPart { let bigPart: Bool } -private func md5(_ data : Data) -> Data { - var res = Data() - res.count = Int(CC_MD5_DIGEST_LENGTH) - res.withUnsafeMutableBytes { mutableBytes -> Void in - data.withUnsafeBytes { bytes -> Void in - CC_MD5(bytes, CC_LONG(data.count), mutableBytes) - } +private func md5(_ data: Data) -> Data { + return data.withUnsafeBytes { bytes -> Data in + return CryptoMD5(bytes, Int32(data.count)) } - return res } private final class MultipartUploadState { diff --git a/TelegramCore/PendingMessageUploadedContent.swift b/TelegramCore/PendingMessageUploadedContent.swift index 0d793587ee..a6fcbff2f4 100644 --- a/TelegramCore/PendingMessageUploadedContent.swift +++ b/TelegramCore/PendingMessageUploadedContent.swift @@ -8,9 +8,6 @@ import Foundation #endif import TelegramCorePrivateModule -#if swift(>=4.0) -import CommonCrypto -#endif enum PendingMessageUploadedContent { case text(String) @@ -125,24 +122,19 @@ private func maybePredownloadedImageResource(postbox: Postbox, peerId: PeerId, r let data = postbox.mediaBox.resourceData(resource, option: .complete(waitUntilFetchStatus: false)).start(next: { data in if data.complete { if data.size < 5 * 1024 * 1024, let fileData = try? Data(contentsOf: URL(fileURLWithPath: data.path), options: .mappedRead) { - var ctx = CC_MD5_CTX() - CC_MD5_Init(&ctx) + let md5 = IncrementalMD5() fileData.withUnsafeBytes { (bytes: UnsafePointer) -> Void in var offset = 0 let bufferSize = 32 * 1024 while offset < fileData.count { let partSize = min(fileData.count - offset, bufferSize) - CC_MD5_Update(&ctx, bytes.advanced(by: offset), CC_LONG(partSize)) + md5.update(bytes.advanced(by: offset), count: Int32(partSize)) offset += bufferSize } } - var res = Data() - res.count = Int(CC_MD5_DIGEST_LENGTH) - res.withUnsafeMutableBytes { mutableBytes -> Void in - CC_MD5_Final(mutableBytes, &ctx) - } + let res = md5.complete() let reference: CachedSentMediaReferenceKey = .image(hash: res) diff --git a/TelegramCore/Serialization.swift b/TelegramCore/Serialization.swift index 02ea93b2e2..37849e0858 100644 --- a/TelegramCore/Serialization.swift +++ b/TelegramCore/Serialization.swift @@ -18,18 +18,28 @@ private let redactChildrenOfType: [String: Set] = [ "Updates.updateShortMessage": Set(["message"]), "Updates.updateShortChatMessage": Set(["message"]), "BotInlineMessage.botInlineMessageText": Set(["message"]), - "DraftMessage.draftMessage": Set(["message"]) + "DraftMessage.draftMessage": Set(["message"]), + "InputSingleMedia.inputSingleMedia": Set(["message"]) ] private let redactFunctionParameters: [String: Set] = [ - "messages.sendMessage": Set(["message"]) + "messages.sendMessage": Set(["message"]), + "messages.sendMedia": Set(["message"]), + "messages.saveDraft": Set(["message"]), + "messages.getWebPagePreview": Set(["message"]) ] func apiFunctionDescription(of desc: FunctionDescription) -> String { var result = desc.name if !desc.parameters.isEmpty { result.append("(") + var first = true for param in desc.parameters { + if first { + first = false + } else { + result.append(", ") + } result.append(param.0) result.append(": ") @@ -60,20 +70,61 @@ private func recursiveDescription(redact: Bool, of value: Any) -> String { result.removeSubrange(result.startIndex ..< result.index(result.startIndex, offsetBy: apiPrefixLength)) } - inner: for child in mirror.children { - if let label = child.label { - result.append(".") - result.append(label) - } + if let value = value as? TypeConstructorDescription { + let (consName, fields) = value.descriptionFields() + result.append(".") + result.append(consName) + let redactChildren: Set? if redact { redactChildren = redactChildrenOfType[result] } else { redactChildren = nil } - let valueMirror = Mirror(reflecting: child.value) - if let displayStyle = valueMirror.displayStyle { - switch displayStyle { + + if !fields.isEmpty { + result.append("(") + var first = true + for (fieldName, fieldValue) in fields { + if first { + first = false + } else { + result.append(", ") + } + var redactValue: Bool = false + if let redactChildren = redactChildren, redactChildren.contains("*") { + redactValue = true + } + + result.append(fieldName) + result.append(": ") + if let redactChildren = redactChildren, redactChildren.contains(fieldName) { + redactValue = true + } + + if redactValue { + result.append("[[redacted]]") + } else { + result.append(recursiveDescription(redact: redact, of: fieldValue)) + } + } + result.append(")") + } + } else { + inner: for child in mirror.children { + if let label = child.label { + result.append(".") + result.append(label) + } + let redactChildren: Set? + if redact { + redactChildren = redactChildrenOfType[result] + } else { + redactChildren = nil + } + let valueMirror = Mirror(reflecting: child.value) + if let displayStyle = valueMirror.displayStyle { + switch displayStyle { case .tuple: var hadChildren = false for child in valueMirror.children { @@ -106,13 +157,14 @@ private func recursiveDescription(redact: Bool, of value: Any) -> String { } default: break + } + } else { + result.append("(") + result.append(String(describing: child.value)) + result.append(")") } - } else { - result.append("(") - result.append(String(describing: child.value)) - result.append(")") + break } - break } case .collection: result.append("[") diff --git a/TelegramCore/TelegramCoreIncludes.h b/TelegramCore/TelegramCoreIncludes.h index ac67e60b45..455d129a9b 100644 --- a/TelegramCore/TelegramCoreIncludes.h +++ b/TelegramCore/TelegramCoreIncludes.h @@ -1,6 +1,6 @@ #ifndef TelegramCoreIncludes_h #define TelegramCoreIncludes_h -#import +#import "Crypto.h" #endif