mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Update API [skip ci]
This commit is contained in:
@@ -34,38 +34,59 @@ public struct PremiumPromoConfiguration: Codable, Equatable {
|
||||
}
|
||||
|
||||
public struct PremiumProductOption: Codable, Equatable {
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case isCurrent
|
||||
case months
|
||||
case currency
|
||||
case amount
|
||||
case botUrl
|
||||
case transactionId
|
||||
case availableForUpgrade
|
||||
case storeProductId
|
||||
}
|
||||
|
||||
public let isCurrent: Bool
|
||||
public let months: Int32
|
||||
public let currency: String
|
||||
public let amount: Int64
|
||||
public let botUrl: String
|
||||
public let transactionId: String?
|
||||
public let availableForUpgrade: Bool
|
||||
public let storeProductId: String?
|
||||
|
||||
public init(months: Int32, currency: String, amount: Int64, botUrl: String, storeProductId: String?) {
|
||||
public init(isCurrent: Bool, months: Int32, currency: String, amount: Int64, botUrl: String, transactionId: String?, availableForUpgrade: Bool, storeProductId: String?) {
|
||||
self.isCurrent = isCurrent
|
||||
self.months = months
|
||||
self.currency = currency
|
||||
self.amount = amount
|
||||
self.botUrl = botUrl
|
||||
self.transactionId = transactionId
|
||||
self.availableForUpgrade = availableForUpgrade
|
||||
self.storeProductId = storeProductId
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.months = decoder.decodeInt32ForKey("months", orElse: 0)
|
||||
self.currency = decoder.decodeStringForKey("currency", orElse: "")
|
||||
self.amount = decoder.decodeInt64ForKey("amount", orElse: 0)
|
||||
self.botUrl = decoder.decodeStringForKey("botUrl", orElse: "")
|
||||
self.storeProductId = decoder.decodeOptionalStringForKey("storeProductId")
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
self.isCurrent = try container.decode(Bool.self, forKey: .isCurrent)
|
||||
self.months = try container.decode(Int32.self, forKey: .months)
|
||||
self.currency = try container.decode(String.self, forKey: .currency)
|
||||
self.amount = try container.decode(Int64.self, forKey: .amount)
|
||||
self.botUrl = try container.decode(String.self, forKey: .botUrl)
|
||||
self.transactionId = try container.decodeIfPresent(String.self, forKey: .transactionId)
|
||||
self.availableForUpgrade = try container.decode(Bool.self, forKey: .availableForUpgrade)
|
||||
self.storeProductId = try container.decodeIfPresent(String.self, forKey: .storeProductId)
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeInt32(self.months, forKey: "months")
|
||||
encoder.encodeString(self.currency, forKey: "currency")
|
||||
encoder.encodeInt64(self.amount, forKey: "amount")
|
||||
encoder.encodeString(self.botUrl, forKey: "botUrl")
|
||||
if let storeProductId = self.storeProductId {
|
||||
encoder.encodeString(storeProductId, forKey: "storeProductId")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "storeProductId")
|
||||
}
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(self.isCurrent, forKey: .isCurrent)
|
||||
try container.encode(self.months, forKey: .months)
|
||||
try container.encode(self.currency, forKey: .currency)
|
||||
try container.encode(self.amount, forKey: .amount)
|
||||
try container.encode(self.botUrl, forKey: .botUrl)
|
||||
try container.encodeIfPresent(self.transactionId, forKey: .transactionId)
|
||||
try container.encode(self.availableForUpgrade, forKey: .availableForUpgrade)
|
||||
try container.encodeIfPresent(self.storeProductId, forKey: .storeProductId)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,10 +130,42 @@ public final class TelegramMediaImage: Media, Equatable, Codable {
|
||||
}
|
||||
}
|
||||
|
||||
public final class EmojiMarkup: Equatable, PostboxCoding {
|
||||
public let fileId: Int64
|
||||
public let backgroundColors: [Int32]
|
||||
|
||||
public init(fileId: Int64, backgroundColors: [Int32]) {
|
||||
self.fileId = fileId
|
||||
self.backgroundColors = backgroundColors
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.fileId = decoder.decodeInt64ForKey("f", orElse: 0)
|
||||
self.backgroundColors = decoder.decodeInt32ArrayForKey("b")
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeInt64(self.fileId, forKey: "f")
|
||||
encoder.encodeInt32Array(self.backgroundColors, forKey: "b")
|
||||
}
|
||||
|
||||
public static func ==(lhs: EmojiMarkup, rhs: EmojiMarkup) -> Bool {
|
||||
if lhs.fileId != rhs.fileId {
|
||||
return false
|
||||
}
|
||||
if lhs.backgroundColors != rhs.backgroundColors {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public let imageId: MediaId
|
||||
public let representations: [TelegramMediaImageRepresentation]
|
||||
public let videoRepresentations: [TelegramMediaImage.VideoRepresentation]
|
||||
public let immediateThumbnailData: Data?
|
||||
public let emojiMarkup: TelegramMediaImage.EmojiMarkup?
|
||||
public let reference: TelegramMediaImageReference?
|
||||
public let partialReference: PartialMediaReference?
|
||||
public let peerIds: [PeerId] = []
|
||||
@@ -143,11 +175,12 @@ public final class TelegramMediaImage: Media, Equatable, Codable {
|
||||
return self.imageId
|
||||
}
|
||||
|
||||
public init(imageId: MediaId, representations: [TelegramMediaImageRepresentation], videoRepresentations: [TelegramMediaImage.VideoRepresentation] = [], immediateThumbnailData: Data?, reference: TelegramMediaImageReference?, partialReference: PartialMediaReference?, flags: TelegramMediaImageFlags) {
|
||||
public init(imageId: MediaId, representations: [TelegramMediaImageRepresentation], videoRepresentations: [TelegramMediaImage.VideoRepresentation] = [], immediateThumbnailData: Data?, emojiMarkup: TelegramMediaImage.EmojiMarkup? = nil, reference: TelegramMediaImageReference?, partialReference: PartialMediaReference?, flags: TelegramMediaImageFlags) {
|
||||
self.imageId = imageId
|
||||
self.representations = representations
|
||||
self.videoRepresentations = videoRepresentations
|
||||
self.immediateThumbnailData = immediateThumbnailData
|
||||
self.emojiMarkup = emojiMarkup
|
||||
self.reference = reference
|
||||
self.partialReference = partialReference
|
||||
self.flags = flags
|
||||
@@ -158,6 +191,7 @@ public final class TelegramMediaImage: Media, Equatable, Codable {
|
||||
self.representations = decoder.decodeObjectArrayForKey("r")
|
||||
self.videoRepresentations = decoder.decodeObjectArrayForKey("vr")
|
||||
self.immediateThumbnailData = decoder.decodeDataForKey("itd")
|
||||
self.emojiMarkup = decoder.decodeObjectForKey("em", decoder: { TelegramMediaImage.EmojiMarkup(decoder: $0) }) as? TelegramMediaImage.EmojiMarkup
|
||||
self.reference = decoder.decodeObjectForKey("rf", decoder: { TelegramMediaImageReference(decoder: $0) }) as? TelegramMediaImageReference
|
||||
self.partialReference = decoder.decodeAnyObjectForKey("prf", decoder: { PartialMediaReference(decoder: $0) }) as? PartialMediaReference
|
||||
self.flags = TelegramMediaImageFlags(rawValue: decoder.decodeInt32ForKey("fl", orElse: 0))
|
||||
@@ -174,6 +208,11 @@ public final class TelegramMediaImage: Media, Equatable, Codable {
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "itd")
|
||||
}
|
||||
if let emojiMarkup = self.emojiMarkup {
|
||||
encoder.encodeObject(emojiMarkup, forKey: "em")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "em")
|
||||
}
|
||||
if let reference = self.reference {
|
||||
encoder.encodeObject(reference, forKey: "rf")
|
||||
} else {
|
||||
@@ -198,6 +237,7 @@ public final class TelegramMediaImage: Media, Equatable, Codable {
|
||||
self.representations = object.representations
|
||||
self.videoRepresentations = object.videoRepresentations
|
||||
self.immediateThumbnailData = object.immediateThumbnailData
|
||||
self.emojiMarkup = object.emojiMarkup
|
||||
self.reference = object.reference
|
||||
self.partialReference = object.partialReference
|
||||
self.flags = object.flags
|
||||
@@ -252,10 +292,13 @@ public final class TelegramMediaImage: Media, Equatable, Codable {
|
||||
if other.immediateThumbnailData != self.immediateThumbnailData {
|
||||
return false
|
||||
}
|
||||
if self.partialReference != other.partialReference {
|
||||
if other.emojiMarkup != self.emojiMarkup {
|
||||
return false
|
||||
}
|
||||
if self.flags != other.flags {
|
||||
if other.partialReference != self.partialReference {
|
||||
return false
|
||||
}
|
||||
if other.flags != self.flags {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import Postbox
|
||||
|
||||
public class TranslationMessageAttribute: MessageAttribute, Equatable {
|
||||
public let text: String
|
||||
public let entities: [MessageTextEntity]
|
||||
public let toLang: String
|
||||
|
||||
public var associatedPeerIds: [PeerId] {
|
||||
return []
|
||||
}
|
||||
|
||||
public init(
|
||||
text: String,
|
||||
entities: [MessageTextEntity],
|
||||
toLang: String
|
||||
) {
|
||||
self.text = text
|
||||
self.entities = entities
|
||||
self.toLang = toLang
|
||||
}
|
||||
|
||||
required public init(decoder: PostboxDecoder) {
|
||||
self.text = decoder.decodeStringForKey("text", orElse: "")
|
||||
self.entities = decoder.decodeObjectArrayWithDecoderForKey("entities")
|
||||
self.toLang = decoder.decodeStringForKey("toLang", orElse: "")
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeString(self.text, forKey: "text")
|
||||
encoder.encodeObjectArray(self.entities, forKey: "entities")
|
||||
encoder.encodeString(self.toLang, forKey: "toLang")
|
||||
}
|
||||
|
||||
public static func ==(lhs: TranslationMessageAttribute, rhs: TranslationMessageAttribute) -> Bool {
|
||||
if lhs.text != rhs.text {
|
||||
return false
|
||||
}
|
||||
if lhs.entities != rhs.entities {
|
||||
return false
|
||||
}
|
||||
if lhs.toLang != rhs.toLang {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user