mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Update API
This commit is contained in:
parent
73b8c2d3c4
commit
c3051cbf90
@ -933,7 +933,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[1301522832] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) }
|
dict[1301522832] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) }
|
||||||
dict[1124938064] = { return Api.SponsoredMessageReportOption.parse_sponsoredMessageReportOption($0) }
|
dict[1124938064] = { return Api.SponsoredMessageReportOption.parse_sponsoredMessageReportOption($0) }
|
||||||
dict[-963180333] = { return Api.SponsoredPeer.parse_sponsoredPeer($0) }
|
dict[-963180333] = { return Api.SponsoredPeer.parse_sponsoredPeer($0) }
|
||||||
dict[-1615652352] = { return Api.StarGift.parse_starGift($0) }
|
dict[-970274264] = { return Api.StarGift.parse_starGift($0) }
|
||||||
dict[1678891913] = { return Api.StarGift.parse_starGiftUnique($0) }
|
dict[1678891913] = { return Api.StarGift.parse_starGiftUnique($0) }
|
||||||
dict[-650279524] = { return Api.StarGiftAttribute.parse_starGiftAttributeBackdrop($0) }
|
dict[-650279524] = { return Api.StarGiftAttribute.parse_starGiftAttributeBackdrop($0) }
|
||||||
dict[970559507] = { return Api.StarGiftAttribute.parse_starGiftAttributeModel($0) }
|
dict[970559507] = { return Api.StarGiftAttribute.parse_starGiftAttributeModel($0) }
|
||||||
|
@ -628,14 +628,14 @@ public extension Api {
|
|||||||
}
|
}
|
||||||
public extension Api {
|
public extension Api {
|
||||||
enum StarGift: TypeConstructorDescription {
|
enum StarGift: TypeConstructorDescription {
|
||||||
case starGift(flags: Int32, id: Int64, sticker: Api.Document, stars: Int64, availabilityRemains: Int32?, availabilityTotal: Int32?, availabilityResale: Int64?, convertStars: Int64, firstSaleDate: Int32?, lastSaleDate: Int32?, upgradeStars: Int64?, resellMinStars: Int64?)
|
case starGift(flags: Int32, id: Int64, sticker: Api.Document, stars: Int64, availabilityRemains: Int32?, availabilityTotal: Int32?, availabilityResale: Int64?, convertStars: Int64, firstSaleDate: Int32?, lastSaleDate: Int32?, upgradeStars: Int64?, resellMinStars: Int64?, title: String?)
|
||||||
case starGiftUnique(flags: Int32, id: Int64, title: String, slug: String, num: Int32, ownerId: Api.Peer?, ownerName: String?, ownerAddress: String?, attributes: [Api.StarGiftAttribute], availabilityIssued: Int32, availabilityTotal: Int32, giftAddress: String?, resellStars: Int64?)
|
case starGiftUnique(flags: Int32, id: Int64, title: String, slug: String, num: Int32, ownerId: Api.Peer?, ownerName: String?, ownerAddress: String?, attributes: [Api.StarGiftAttribute], availabilityIssued: Int32, availabilityTotal: Int32, giftAddress: String?, resellStars: Int64?)
|
||||||
|
|
||||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||||
switch self {
|
switch self {
|
||||||
case .starGift(let flags, let id, let sticker, let stars, let availabilityRemains, let availabilityTotal, let availabilityResale, let convertStars, let firstSaleDate, let lastSaleDate, let upgradeStars, let resellMinStars):
|
case .starGift(let flags, let id, let sticker, let stars, let availabilityRemains, let availabilityTotal, let availabilityResale, let convertStars, let firstSaleDate, let lastSaleDate, let upgradeStars, let resellMinStars, let title):
|
||||||
if boxed {
|
if boxed {
|
||||||
buffer.appendInt32(-1615652352)
|
buffer.appendInt32(-970274264)
|
||||||
}
|
}
|
||||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||||
serializeInt64(id, buffer: buffer, boxed: false)
|
serializeInt64(id, buffer: buffer, boxed: false)
|
||||||
@ -649,6 +649,7 @@ public extension Api {
|
|||||||
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(lastSaleDate!, buffer: buffer, boxed: false)}
|
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(lastSaleDate!, buffer: buffer, boxed: false)}
|
||||||
if Int(flags) & Int(1 << 3) != 0 {serializeInt64(upgradeStars!, buffer: buffer, boxed: false)}
|
if Int(flags) & Int(1 << 3) != 0 {serializeInt64(upgradeStars!, buffer: buffer, boxed: false)}
|
||||||
if Int(flags) & Int(1 << 4) != 0 {serializeInt64(resellMinStars!, buffer: buffer, boxed: false)}
|
if Int(flags) & Int(1 << 4) != 0 {serializeInt64(resellMinStars!, buffer: buffer, boxed: false)}
|
||||||
|
if Int(flags) & Int(1 << 5) != 0 {serializeString(title!, buffer: buffer, boxed: false)}
|
||||||
break
|
break
|
||||||
case .starGiftUnique(let flags, let id, let title, let slug, let num, let ownerId, let ownerName, let ownerAddress, let attributes, let availabilityIssued, let availabilityTotal, let giftAddress, let resellStars):
|
case .starGiftUnique(let flags, let id, let title, let slug, let num, let ownerId, let ownerName, let ownerAddress, let attributes, let availabilityIssued, let availabilityTotal, let giftAddress, let resellStars):
|
||||||
if boxed {
|
if boxed {
|
||||||
@ -677,8 +678,8 @@ public extension Api {
|
|||||||
|
|
||||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||||
switch self {
|
switch self {
|
||||||
case .starGift(let flags, let id, let sticker, let stars, let availabilityRemains, let availabilityTotal, let availabilityResale, let convertStars, let firstSaleDate, let lastSaleDate, let upgradeStars, let resellMinStars):
|
case .starGift(let flags, let id, let sticker, let stars, let availabilityRemains, let availabilityTotal, let availabilityResale, let convertStars, let firstSaleDate, let lastSaleDate, let upgradeStars, let resellMinStars, let title):
|
||||||
return ("starGift", [("flags", flags as Any), ("id", id as Any), ("sticker", sticker as Any), ("stars", stars as Any), ("availabilityRemains", availabilityRemains as Any), ("availabilityTotal", availabilityTotal as Any), ("availabilityResale", availabilityResale as Any), ("convertStars", convertStars as Any), ("firstSaleDate", firstSaleDate as Any), ("lastSaleDate", lastSaleDate as Any), ("upgradeStars", upgradeStars as Any), ("resellMinStars", resellMinStars as Any)])
|
return ("starGift", [("flags", flags as Any), ("id", id as Any), ("sticker", sticker as Any), ("stars", stars as Any), ("availabilityRemains", availabilityRemains as Any), ("availabilityTotal", availabilityTotal as Any), ("availabilityResale", availabilityResale as Any), ("convertStars", convertStars as Any), ("firstSaleDate", firstSaleDate as Any), ("lastSaleDate", lastSaleDate as Any), ("upgradeStars", upgradeStars as Any), ("resellMinStars", resellMinStars as Any), ("title", title as Any)])
|
||||||
case .starGiftUnique(let flags, let id, let title, let slug, let num, let ownerId, let ownerName, let ownerAddress, let attributes, let availabilityIssued, let availabilityTotal, let giftAddress, let resellStars):
|
case .starGiftUnique(let flags, let id, let title, let slug, let num, let ownerId, let ownerName, let ownerAddress, let attributes, let availabilityIssued, let availabilityTotal, let giftAddress, let resellStars):
|
||||||
return ("starGiftUnique", [("flags", flags as Any), ("id", id as Any), ("title", title as Any), ("slug", slug as Any), ("num", num as Any), ("ownerId", ownerId as Any), ("ownerName", ownerName as Any), ("ownerAddress", ownerAddress as Any), ("attributes", attributes as Any), ("availabilityIssued", availabilityIssued as Any), ("availabilityTotal", availabilityTotal as Any), ("giftAddress", giftAddress as Any), ("resellStars", resellStars as Any)])
|
return ("starGiftUnique", [("flags", flags as Any), ("id", id as Any), ("title", title as Any), ("slug", slug as Any), ("num", num as Any), ("ownerId", ownerId as Any), ("ownerName", ownerName as Any), ("ownerAddress", ownerAddress as Any), ("attributes", attributes as Any), ("availabilityIssued", availabilityIssued as Any), ("availabilityTotal", availabilityTotal as Any), ("giftAddress", giftAddress as Any), ("resellStars", resellStars as Any)])
|
||||||
}
|
}
|
||||||
@ -711,6 +712,8 @@ public extension Api {
|
|||||||
if Int(_1!) & Int(1 << 3) != 0 {_11 = reader.readInt64() }
|
if Int(_1!) & Int(1 << 3) != 0 {_11 = reader.readInt64() }
|
||||||
var _12: Int64?
|
var _12: Int64?
|
||||||
if Int(_1!) & Int(1 << 4) != 0 {_12 = reader.readInt64() }
|
if Int(_1!) & Int(1 << 4) != 0 {_12 = reader.readInt64() }
|
||||||
|
var _13: String?
|
||||||
|
if Int(_1!) & Int(1 << 5) != 0 {_13 = parseString(reader) }
|
||||||
let _c1 = _1 != nil
|
let _c1 = _1 != nil
|
||||||
let _c2 = _2 != nil
|
let _c2 = _2 != nil
|
||||||
let _c3 = _3 != nil
|
let _c3 = _3 != nil
|
||||||
@ -723,8 +726,9 @@ public extension Api {
|
|||||||
let _c10 = (Int(_1!) & Int(1 << 1) == 0) || _10 != nil
|
let _c10 = (Int(_1!) & Int(1 << 1) == 0) || _10 != nil
|
||||||
let _c11 = (Int(_1!) & Int(1 << 3) == 0) || _11 != nil
|
let _c11 = (Int(_1!) & Int(1 << 3) == 0) || _11 != nil
|
||||||
let _c12 = (Int(_1!) & Int(1 << 4) == 0) || _12 != nil
|
let _c12 = (Int(_1!) & Int(1 << 4) == 0) || _12 != nil
|
||||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 {
|
let _c13 = (Int(_1!) & Int(1 << 5) == 0) || _13 != nil
|
||||||
return Api.StarGift.starGift(flags: _1!, id: _2!, sticker: _3!, stars: _4!, availabilityRemains: _5, availabilityTotal: _6, availabilityResale: _7, convertStars: _8!, firstSaleDate: _9, lastSaleDate: _10, upgradeStars: _11, resellMinStars: _12)
|
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 {
|
||||||
|
return Api.StarGift.starGift(flags: _1!, id: _2!, sticker: _3!, stars: _4!, availabilityRemains: _5, availabilityTotal: _6, availabilityResale: _7, convertStars: _8!, firstSaleDate: _9, lastSaleDate: _10, upgradeStars: _11, resellMinStars: _12, title: _13)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return nil
|
return nil
|
||||||
|
@ -46,6 +46,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
|
|||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case id
|
case id
|
||||||
|
case title
|
||||||
case file
|
case file
|
||||||
case price
|
case price
|
||||||
case convertStars
|
case convertStars
|
||||||
@ -140,6 +141,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public let id: Int64
|
public let id: Int64
|
||||||
|
public let title: String?
|
||||||
public let file: TelegramMediaFile
|
public let file: TelegramMediaFile
|
||||||
public let price: Int64
|
public let price: Int64
|
||||||
public let convertStars: Int64
|
public let convertStars: Int64
|
||||||
@ -148,8 +150,9 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
|
|||||||
public let flags: Flags
|
public let flags: Flags
|
||||||
public let upgradeStars: Int64?
|
public let upgradeStars: Int64?
|
||||||
|
|
||||||
public init(id: Int64, file: TelegramMediaFile, price: Int64, convertStars: Int64, availability: Availability?, soldOut: SoldOut?, flags: Flags, upgradeStars: Int64?) {
|
public init(id: Int64, title: String?, file: TelegramMediaFile, price: Int64, convertStars: Int64, availability: Availability?, soldOut: SoldOut?, flags: Flags, upgradeStars: Int64?) {
|
||||||
self.id = id
|
self.id = id
|
||||||
|
self.title = title
|
||||||
self.file = file
|
self.file = file
|
||||||
self.price = price
|
self.price = price
|
||||||
self.convertStars = convertStars
|
self.convertStars = convertStars
|
||||||
@ -162,6 +165,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
|
|||||||
public init(from decoder: Decoder) throws {
|
public init(from decoder: Decoder) throws {
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
self.id = try container.decode(Int64.self, forKey: .id)
|
self.id = try container.decode(Int64.self, forKey: .id)
|
||||||
|
self.title = try container.decodeIfPresent(String.self, forKey: .title)
|
||||||
|
|
||||||
if let fileData = try container.decodeIfPresent(Data.self, forKey: .file), let file = PostboxDecoder(buffer: MemoryBuffer(data: fileData)).decodeRootObject() as? TelegramMediaFile {
|
if let fileData = try container.decodeIfPresent(Data.self, forKey: .file), let file = PostboxDecoder(buffer: MemoryBuffer(data: fileData)).decodeRootObject() as? TelegramMediaFile {
|
||||||
self.file = file
|
self.file = file
|
||||||
@ -179,6 +183,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
|
|||||||
|
|
||||||
public init(decoder: PostboxDecoder) {
|
public init(decoder: PostboxDecoder) {
|
||||||
self.id = decoder.decodeInt64ForKey(CodingKeys.id.rawValue, orElse: 0)
|
self.id = decoder.decodeInt64ForKey(CodingKeys.id.rawValue, orElse: 0)
|
||||||
|
self.title = decoder.decodeOptionalStringForKey(CodingKeys.title.rawValue)
|
||||||
self.file = decoder.decodeObjectForKey(CodingKeys.file.rawValue) as! TelegramMediaFile
|
self.file = decoder.decodeObjectForKey(CodingKeys.file.rawValue) as! TelegramMediaFile
|
||||||
self.price = decoder.decodeInt64ForKey(CodingKeys.price.rawValue, orElse: 0)
|
self.price = decoder.decodeInt64ForKey(CodingKeys.price.rawValue, orElse: 0)
|
||||||
self.convertStars = decoder.decodeInt64ForKey(CodingKeys.convertStars.rawValue, orElse: 0)
|
self.convertStars = decoder.decodeInt64ForKey(CodingKeys.convertStars.rawValue, orElse: 0)
|
||||||
@ -191,6 +196,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
|
|||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encode(self.id, forKey: .id)
|
try container.encode(self.id, forKey: .id)
|
||||||
|
try container.encodeIfPresent(self.title, forKey: .title)
|
||||||
|
|
||||||
let encoder = PostboxEncoder()
|
let encoder = PostboxEncoder()
|
||||||
encoder.encodeRootObject(self.file)
|
encoder.encodeRootObject(self.file)
|
||||||
@ -207,6 +213,11 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
|
|||||||
|
|
||||||
public func encode(_ encoder: PostboxEncoder) {
|
public func encode(_ encoder: PostboxEncoder) {
|
||||||
encoder.encodeInt64(self.id, forKey: CodingKeys.id.rawValue)
|
encoder.encodeInt64(self.id, forKey: CodingKeys.id.rawValue)
|
||||||
|
if let title = self.title {
|
||||||
|
encoder.encodeString(title, forKey: CodingKeys.title.rawValue)
|
||||||
|
} else {
|
||||||
|
encoder.encodeNil(forKey: CodingKeys.title.rawValue)
|
||||||
|
}
|
||||||
encoder.encodeObject(self.file, forKey: CodingKeys.file.rawValue)
|
encoder.encodeObject(self.file, forKey: CodingKeys.file.rawValue)
|
||||||
encoder.encodeInt64(self.price, forKey: CodingKeys.price.rawValue)
|
encoder.encodeInt64(self.price, forKey: CodingKeys.price.rawValue)
|
||||||
encoder.encodeInt64(self.convertStars, forKey: CodingKeys.convertStars.rawValue)
|
encoder.encodeInt64(self.convertStars, forKey: CodingKeys.convertStars.rawValue)
|
||||||
@ -668,7 +679,7 @@ public enum StarGift: Equatable, Codable, PostboxCoding {
|
|||||||
extension StarGift {
|
extension StarGift {
|
||||||
init?(apiStarGift: Api.StarGift) {
|
init?(apiStarGift: Api.StarGift) {
|
||||||
switch apiStarGift {
|
switch apiStarGift {
|
||||||
case let .starGift(apiFlags, id, sticker, stars, availabilityRemains, availabilityTotal, availabilityResale, convertStars, firstSale, lastSale, upgradeStars, minResaleStars):
|
case let .starGift(apiFlags, id, sticker, stars, availabilityRemains, availabilityTotal, availabilityResale, convertStars, firstSale, lastSale, upgradeStars, minResaleStars, title):
|
||||||
var flags = StarGift.Gift.Flags()
|
var flags = StarGift.Gift.Flags()
|
||||||
if (apiFlags & (1 << 2)) != 0 {
|
if (apiFlags & (1 << 2)) != 0 {
|
||||||
flags.insert(.isBirthdayGift)
|
flags.insert(.isBirthdayGift)
|
||||||
@ -690,7 +701,7 @@ extension StarGift {
|
|||||||
guard let file = telegramMediaFileFromApiDocument(sticker, altDocuments: nil) else {
|
guard let file = telegramMediaFileFromApiDocument(sticker, altDocuments: nil) else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
self = .generic(StarGift.Gift(id: id, file: file, price: stars, convertStars: convertStars, availability: availability, soldOut: soldOut, flags: flags, upgradeStars: upgradeStars))
|
self = .generic(StarGift.Gift(id: id, title: title, file: file, price: stars, convertStars: convertStars, availability: availability, soldOut: soldOut, flags: flags, upgradeStars: upgradeStars))
|
||||||
case let .starGiftUnique(_, id, title, slug, num, ownerPeerId, ownerName, ownerAddress, attributes, availabilityIssued, availabilityTotal, giftAddress, reselltars):
|
case let .starGiftUnique(_, id, title, slug, num, ownerPeerId, ownerName, ownerAddress, attributes, availabilityIssued, availabilityTotal, giftAddress, reselltars):
|
||||||
let owner: StarGift.UniqueGift.Owner
|
let owner: StarGift.UniqueGift.Owner
|
||||||
if let ownerAddress {
|
if let ownerAddress {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user