mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Update API [skip ci]
This commit is contained in:
parent
a69d78fdaf
commit
38a5a886c8
@ -373,7 +373,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-977967015] = { return Api.InputInvoice.parse_inputInvoiceMessage($0) }
|
||||
dict[-1734841331] = { return Api.InputInvoice.parse_inputInvoicePremiumGiftCode($0) }
|
||||
dict[-1020867857] = { return Api.InputInvoice.parse_inputInvoiceSlug($0) }
|
||||
dict[497236696] = { return Api.InputInvoice.parse_inputInvoiceStars($0) }
|
||||
dict[1710230755] = { return Api.InputInvoice.parse_inputInvoiceStars($0) }
|
||||
dict[-122978821] = { return Api.InputMedia.parse_inputMediaContact($0) }
|
||||
dict[-428884101] = { return Api.InputMedia.parse_inputMediaDice($0) }
|
||||
dict[860303448] = { return Api.InputMedia.parse_inputMediaDocument($0) }
|
||||
@ -464,7 +464,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-1551868097] = { return Api.InputStorePaymentPurpose.parse_inputStorePaymentPremiumGiftCode($0) }
|
||||
dict[369444042] = { return Api.InputStorePaymentPurpose.parse_inputStorePaymentPremiumGiveaway($0) }
|
||||
dict[-1502273946] = { return Api.InputStorePaymentPurpose.parse_inputStorePaymentPremiumSubscription($0) }
|
||||
dict[1326377183] = { return Api.InputStorePaymentPurpose.parse_inputStorePaymentStars($0) }
|
||||
dict[494149367] = { return Api.InputStorePaymentPurpose.parse_inputStorePaymentStarsGift($0) }
|
||||
dict[-572715178] = { return Api.InputStorePaymentPurpose.parse_inputStorePaymentStarsTopup($0) }
|
||||
dict[1012306921] = { return Api.InputTheme.parse_inputTheme($0) }
|
||||
dict[-175567375] = { return Api.InputTheme.parse_inputThemeSlug($0) }
|
||||
dict[-1881255857] = { return Api.InputThemeSettings.parse_inputThemeSettings($0) }
|
||||
@ -543,12 +544,14 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-1730095465] = { return Api.MessageAction.parse_messageActionGeoProximityReached($0) }
|
||||
dict[1737240073] = { return Api.MessageAction.parse_messageActionGiftCode($0) }
|
||||
dict[-935499028] = { return Api.MessageAction.parse_messageActionGiftPremium($0) }
|
||||
dict[1171632161] = { return Api.MessageAction.parse_messageActionGiftStars($0) }
|
||||
dict[858499565] = { return Api.MessageAction.parse_messageActionGiveawayLaunch($0) }
|
||||
dict[715107781] = { return Api.MessageAction.parse_messageActionGiveawayResults($0) }
|
||||
dict[2047704898] = { return Api.MessageAction.parse_messageActionGroupCall($0) }
|
||||
dict[-1281329567] = { return Api.MessageAction.parse_messageActionGroupCallScheduled($0) }
|
||||
dict[-1615153660] = { return Api.MessageAction.parse_messageActionHistoryClear($0) }
|
||||
dict[1345295095] = { return Api.MessageAction.parse_messageActionInviteToGroupCall($0) }
|
||||
dict[1102307842] = { return Api.MessageAction.parse_messageActionPaymentRefunded($0) }
|
||||
dict[-1776926890] = { return Api.MessageAction.parse_messageActionPaymentSent($0) }
|
||||
dict[-1892568281] = { return Api.MessageAction.parse_messageActionPaymentSentMe($0) }
|
||||
dict[-2132731265] = { return Api.MessageAction.parse_messageActionPhoneCall($0) }
|
||||
@ -873,6 +876,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-425595208] = { return Api.SmsJob.parse_smsJob($0) }
|
||||
dict[-1108478618] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) }
|
||||
dict[1124938064] = { return Api.SponsoredMessageReportOption.parse_sponsoredMessageReportOption($0) }
|
||||
dict[1577421297] = { return Api.StarsGiftOption.parse_starsGiftOption($0) }
|
||||
dict[2033461574] = { return Api.StarsRevenueStatus.parse_starsRevenueStatus($0) }
|
||||
dict[198776256] = { return Api.StarsTopupOption.parse_starsTopupOption($0) }
|
||||
dict[766853519] = { return Api.StarsTransaction.parse_starsTransaction($0) }
|
||||
@ -1984,6 +1988,8 @@ public extension Api {
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.SponsoredMessageReportOption:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.StarsGiftOption:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.StarsRevenueStatus:
|
||||
_1.serialize(buffer, boxed)
|
||||
case let _1 as Api.StarsTopupOption:
|
||||
|
@ -396,7 +396,8 @@ public extension Api {
|
||||
case inputStorePaymentPremiumGiftCode(flags: Int32, users: [Api.InputUser], boostPeer: Api.InputPeer?, currency: String, amount: Int64)
|
||||
case inputStorePaymentPremiumGiveaway(flags: Int32, boostPeer: Api.InputPeer, additionalPeers: [Api.InputPeer]?, countriesIso2: [String]?, prizeDescription: String?, randomId: Int64, untilDate: Int32, currency: String, amount: Int64)
|
||||
case inputStorePaymentPremiumSubscription(flags: Int32)
|
||||
case inputStorePaymentStars(flags: Int32, stars: Int64, currency: String, amount: Int64)
|
||||
case inputStorePaymentStarsGift(userId: Api.InputUser, stars: Int64, currency: String, amount: Int64)
|
||||
case inputStorePaymentStarsTopup(stars: Int64, currency: String, amount: Int64)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
@ -450,11 +451,19 @@ public extension Api {
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .inputStorePaymentStars(let flags, let stars, let currency, let amount):
|
||||
case .inputStorePaymentStarsGift(let userId, let stars, let currency, let amount):
|
||||
if boxed {
|
||||
buffer.appendInt32(1326377183)
|
||||
buffer.appendInt32(494149367)
|
||||
}
|
||||
userId.serialize(buffer, true)
|
||||
serializeInt64(stars, buffer: buffer, boxed: false)
|
||||
serializeString(currency, buffer: buffer, boxed: false)
|
||||
serializeInt64(amount, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .inputStorePaymentStarsTopup(let stars, let currency, let amount):
|
||||
if boxed {
|
||||
buffer.appendInt32(-572715178)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt64(stars, buffer: buffer, boxed: false)
|
||||
serializeString(currency, buffer: buffer, boxed: false)
|
||||
serializeInt64(amount, buffer: buffer, boxed: false)
|
||||
@ -472,8 +481,10 @@ public extension Api {
|
||||
return ("inputStorePaymentPremiumGiveaway", [("flags", flags as Any), ("boostPeer", boostPeer as Any), ("additionalPeers", additionalPeers as Any), ("countriesIso2", countriesIso2 as Any), ("prizeDescription", prizeDescription as Any), ("randomId", randomId as Any), ("untilDate", untilDate as Any), ("currency", currency as Any), ("amount", amount as Any)])
|
||||
case .inputStorePaymentPremiumSubscription(let flags):
|
||||
return ("inputStorePaymentPremiumSubscription", [("flags", flags as Any)])
|
||||
case .inputStorePaymentStars(let flags, let stars, let currency, let amount):
|
||||
return ("inputStorePaymentStars", [("flags", flags as Any), ("stars", stars as Any), ("currency", currency as Any), ("amount", amount as Any)])
|
||||
case .inputStorePaymentStarsGift(let userId, let stars, let currency, let amount):
|
||||
return ("inputStorePaymentStarsGift", [("userId", userId as Any), ("stars", stars as Any), ("currency", currency as Any), ("amount", amount as Any)])
|
||||
case .inputStorePaymentStarsTopup(let stars, let currency, let amount):
|
||||
return ("inputStorePaymentStarsTopup", [("stars", stars as Any), ("currency", currency as Any), ("amount", amount as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -575,9 +586,11 @@ public extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_inputStorePaymentStars(_ reader: BufferReader) -> InputStorePaymentPurpose? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
public static func parse_inputStorePaymentStarsGift(_ reader: BufferReader) -> InputStorePaymentPurpose? {
|
||||
var _1: Api.InputUser?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.InputUser
|
||||
}
|
||||
var _2: Int64?
|
||||
_2 = reader.readInt64()
|
||||
var _3: String?
|
||||
@ -589,7 +602,24 @@ public extension Api {
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 {
|
||||
return Api.InputStorePaymentPurpose.inputStorePaymentStars(flags: _1!, stars: _2!, currency: _3!, amount: _4!)
|
||||
return Api.InputStorePaymentPurpose.inputStorePaymentStarsGift(userId: _1!, stars: _2!, currency: _3!, amount: _4!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_inputStorePaymentStarsTopup(_ reader: BufferReader) -> InputStorePaymentPurpose? {
|
||||
var _1: Int64?
|
||||
_1 = reader.readInt64()
|
||||
var _2: String?
|
||||
_2 = parseString(reader)
|
||||
var _3: Int64?
|
||||
_3 = reader.readInt64()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.InputStorePaymentPurpose.inputStorePaymentStarsTopup(stars: _1!, currency: _2!, amount: _3!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
@ -904,57 +934,3 @@ public extension Api {
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum InputWebDocument: TypeConstructorDescription {
|
||||
case inputWebDocument(url: String, size: Int32, mimeType: String, attributes: [Api.DocumentAttribute])
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .inputWebDocument(let url, let size, let mimeType, let attributes):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1678949555)
|
||||
}
|
||||
serializeString(url, buffer: buffer, boxed: false)
|
||||
serializeInt32(size, buffer: buffer, boxed: false)
|
||||
serializeString(mimeType, buffer: buffer, boxed: false)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(attributes.count))
|
||||
for item in attributes {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .inputWebDocument(let url, let size, let mimeType, let attributes):
|
||||
return ("inputWebDocument", [("url", url as Any), ("size", size as Any), ("mimeType", mimeType as Any), ("attributes", attributes as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_inputWebDocument(_ reader: BufferReader) -> InputWebDocument? {
|
||||
var _1: String?
|
||||
_1 = parseString(reader)
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
var _3: String?
|
||||
_3 = parseString(reader)
|
||||
var _4: [Api.DocumentAttribute]?
|
||||
if let _ = reader.readInt32() {
|
||||
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.DocumentAttribute.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 {
|
||||
return Api.InputWebDocument.inputWebDocument(url: _1!, size: _2!, mimeType: _3!, attributes: _4!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,57 @@
|
||||
public extension Api {
|
||||
enum InputWebDocument: TypeConstructorDescription {
|
||||
case inputWebDocument(url: String, size: Int32, mimeType: String, attributes: [Api.DocumentAttribute])
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .inputWebDocument(let url, let size, let mimeType, let attributes):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1678949555)
|
||||
}
|
||||
serializeString(url, buffer: buffer, boxed: false)
|
||||
serializeInt32(size, buffer: buffer, boxed: false)
|
||||
serializeString(mimeType, buffer: buffer, boxed: false)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(attributes.count))
|
||||
for item in attributes {
|
||||
item.serialize(buffer, true)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .inputWebDocument(let url, let size, let mimeType, let attributes):
|
||||
return ("inputWebDocument", [("url", url as Any), ("size", size as Any), ("mimeType", mimeType as Any), ("attributes", attributes as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_inputWebDocument(_ reader: BufferReader) -> InputWebDocument? {
|
||||
var _1: String?
|
||||
_1 = parseString(reader)
|
||||
var _2: Int32?
|
||||
_2 = reader.readInt32()
|
||||
var _3: String?
|
||||
_3 = parseString(reader)
|
||||
var _4: [Api.DocumentAttribute]?
|
||||
if let _ = reader.readInt32() {
|
||||
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.DocumentAttribute.self)
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 {
|
||||
return Api.InputWebDocument.inputWebDocument(url: _1!, size: _2!, mimeType: _3!, attributes: _4!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum InputWebFileLocation: TypeConstructorDescription {
|
||||
case inputWebFileAudioAlbumThumbLocation(flags: Int32, document: Api.InputDocument?, title: String?, performer: String?)
|
||||
@ -982,71 +1036,3 @@ public extension Api {
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum LangPackLanguage: TypeConstructorDescription {
|
||||
case langPackLanguage(flags: Int32, name: String, nativeName: String, langCode: String, baseLangCode: String?, pluralCode: String, stringsCount: Int32, translatedCount: Int32, translationsUrl: String)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .langPackLanguage(let flags, let name, let nativeName, let langCode, let baseLangCode, let pluralCode, let stringsCount, let translatedCount, let translationsUrl):
|
||||
if boxed {
|
||||
buffer.appendInt32(-288727837)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeString(name, buffer: buffer, boxed: false)
|
||||
serializeString(nativeName, buffer: buffer, boxed: false)
|
||||
serializeString(langCode, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 1) != 0 {serializeString(baseLangCode!, buffer: buffer, boxed: false)}
|
||||
serializeString(pluralCode, buffer: buffer, boxed: false)
|
||||
serializeInt32(stringsCount, buffer: buffer, boxed: false)
|
||||
serializeInt32(translatedCount, buffer: buffer, boxed: false)
|
||||
serializeString(translationsUrl, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .langPackLanguage(let flags, let name, let nativeName, let langCode, let baseLangCode, let pluralCode, let stringsCount, let translatedCount, let translationsUrl):
|
||||
return ("langPackLanguage", [("flags", flags as Any), ("name", name as Any), ("nativeName", nativeName as Any), ("langCode", langCode as Any), ("baseLangCode", baseLangCode as Any), ("pluralCode", pluralCode as Any), ("stringsCount", stringsCount as Any), ("translatedCount", translatedCount as Any), ("translationsUrl", translationsUrl as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_langPackLanguage(_ reader: BufferReader) -> LangPackLanguage? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: String?
|
||||
_2 = parseString(reader)
|
||||
var _3: String?
|
||||
_3 = parseString(reader)
|
||||
var _4: String?
|
||||
_4 = parseString(reader)
|
||||
var _5: String?
|
||||
if Int(_1!) & Int(1 << 1) != 0 {_5 = parseString(reader) }
|
||||
var _6: String?
|
||||
_6 = parseString(reader)
|
||||
var _7: Int32?
|
||||
_7 = reader.readInt32()
|
||||
var _8: Int32?
|
||||
_8 = reader.readInt32()
|
||||
var _9: String?
|
||||
_9 = parseString(reader)
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil
|
||||
let _c6 = _6 != nil
|
||||
let _c7 = _7 != nil
|
||||
let _c8 = _8 != nil
|
||||
let _c9 = _9 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 {
|
||||
return Api.LangPackLanguage.langPackLanguage(flags: _1!, name: _2!, nativeName: _3!, langCode: _4!, baseLangCode: _5, pluralCode: _6!, stringsCount: _7!, translatedCount: _8!, translationsUrl: _9!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,71 @@
|
||||
public extension Api {
|
||||
enum LangPackLanguage: TypeConstructorDescription {
|
||||
case langPackLanguage(flags: Int32, name: String, nativeName: String, langCode: String, baseLangCode: String?, pluralCode: String, stringsCount: Int32, translatedCount: Int32, translationsUrl: String)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .langPackLanguage(let flags, let name, let nativeName, let langCode, let baseLangCode, let pluralCode, let stringsCount, let translatedCount, let translationsUrl):
|
||||
if boxed {
|
||||
buffer.appendInt32(-288727837)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeString(name, buffer: buffer, boxed: false)
|
||||
serializeString(nativeName, buffer: buffer, boxed: false)
|
||||
serializeString(langCode, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 1) != 0 {serializeString(baseLangCode!, buffer: buffer, boxed: false)}
|
||||
serializeString(pluralCode, buffer: buffer, boxed: false)
|
||||
serializeInt32(stringsCount, buffer: buffer, boxed: false)
|
||||
serializeInt32(translatedCount, buffer: buffer, boxed: false)
|
||||
serializeString(translationsUrl, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .langPackLanguage(let flags, let name, let nativeName, let langCode, let baseLangCode, let pluralCode, let stringsCount, let translatedCount, let translationsUrl):
|
||||
return ("langPackLanguage", [("flags", flags as Any), ("name", name as Any), ("nativeName", nativeName as Any), ("langCode", langCode as Any), ("baseLangCode", baseLangCode as Any), ("pluralCode", pluralCode as Any), ("stringsCount", stringsCount as Any), ("translatedCount", translatedCount as Any), ("translationsUrl", translationsUrl as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_langPackLanguage(_ reader: BufferReader) -> LangPackLanguage? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: String?
|
||||
_2 = parseString(reader)
|
||||
var _3: String?
|
||||
_3 = parseString(reader)
|
||||
var _4: String?
|
||||
_4 = parseString(reader)
|
||||
var _5: String?
|
||||
if Int(_1!) & Int(1 << 1) != 0 {_5 = parseString(reader) }
|
||||
var _6: String?
|
||||
_6 = parseString(reader)
|
||||
var _7: Int32?
|
||||
_7 = reader.readInt32()
|
||||
var _8: Int32?
|
||||
_8 = reader.readInt32()
|
||||
var _9: String?
|
||||
_9 = parseString(reader)
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil
|
||||
let _c6 = _6 != nil
|
||||
let _c7 = _7 != nil
|
||||
let _c8 = _8 != nil
|
||||
let _c9 = _9 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 {
|
||||
return Api.LangPackLanguage.langPackLanguage(flags: _1!, name: _2!, nativeName: _3!, langCode: _4!, baseLangCode: _5, pluralCode: _6!, stringsCount: _7!, translatedCount: _8!, translationsUrl: _9!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum LangPackString: TypeConstructorDescription {
|
||||
case langPackString(key: String, value: String)
|
||||
@ -750,12 +818,14 @@ public extension Api {
|
||||
case messageActionGeoProximityReached(fromId: Api.Peer, toId: Api.Peer, distance: Int32)
|
||||
case messageActionGiftCode(flags: Int32, boostPeer: Api.Peer?, months: Int32, slug: String, currency: String?, amount: Int64?, cryptoCurrency: String?, cryptoAmount: Int64?)
|
||||
case messageActionGiftPremium(flags: Int32, currency: String, amount: Int64, months: Int32, cryptoCurrency: String?, cryptoAmount: Int64?)
|
||||
case messageActionGiftStars(flags: Int32, currency: String, amount: Int64, stars: Int64, cryptoCurrency: String?, cryptoAmount: Int64?, transactionId: String?)
|
||||
case messageActionGiveawayLaunch
|
||||
case messageActionGiveawayResults(winnersCount: Int32, unclaimedCount: Int32)
|
||||
case messageActionGroupCall(flags: Int32, call: Api.InputGroupCall, duration: Int32?)
|
||||
case messageActionGroupCallScheduled(call: Api.InputGroupCall, scheduleDate: Int32)
|
||||
case messageActionHistoryClear
|
||||
case messageActionInviteToGroupCall(call: Api.InputGroupCall, users: [Int64])
|
||||
case messageActionPaymentRefunded(flags: Int32, peer: Api.Peer, currency: String, totalAmount: Int64, payload: Buffer?, charge: Api.PaymentCharge)
|
||||
case messageActionPaymentSent(flags: Int32, currency: String, totalAmount: Int64, invoiceSlug: String?)
|
||||
case messageActionPaymentSentMe(flags: Int32, currency: String, totalAmount: Int64, payload: Buffer, info: Api.PaymentRequestedInfo?, shippingOptionId: String?, charge: Api.PaymentCharge)
|
||||
case messageActionPhoneCall(flags: Int32, callId: Int64, reason: Api.PhoneCallDiscardReason?, duration: Int32?)
|
||||
@ -923,6 +993,18 @@ public extension Api {
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeString(cryptoCurrency!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt64(cryptoAmount!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
case .messageActionGiftStars(let flags, let currency, let amount, let stars, let cryptoCurrency, let cryptoAmount, let transactionId):
|
||||
if boxed {
|
||||
buffer.appendInt32(1171632161)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeString(currency, buffer: buffer, boxed: false)
|
||||
serializeInt64(amount, buffer: buffer, boxed: false)
|
||||
serializeInt64(stars, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeString(cryptoCurrency!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt64(cryptoAmount!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 1) != 0 {serializeString(transactionId!, buffer: buffer, boxed: false)}
|
||||
break
|
||||
case .messageActionGiveawayLaunch:
|
||||
if boxed {
|
||||
buffer.appendInt32(858499565)
|
||||
@ -968,6 +1050,17 @@ public extension Api {
|
||||
serializeInt64(item, buffer: buffer, boxed: false)
|
||||
}
|
||||
break
|
||||
case .messageActionPaymentRefunded(let flags, let peer, let currency, let totalAmount, let payload, let charge):
|
||||
if boxed {
|
||||
buffer.appendInt32(1102307842)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
peer.serialize(buffer, true)
|
||||
serializeString(currency, buffer: buffer, boxed: false)
|
||||
serializeInt64(totalAmount, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeBytes(payload!, buffer: buffer, boxed: false)}
|
||||
charge.serialize(buffer, true)
|
||||
break
|
||||
case .messageActionPaymentSent(let flags, let currency, let totalAmount, let invoiceSlug):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1776926890)
|
||||
@ -1157,6 +1250,8 @@ public extension Api {
|
||||
return ("messageActionGiftCode", [("flags", flags as Any), ("boostPeer", boostPeer as Any), ("months", months as Any), ("slug", slug as Any), ("currency", currency as Any), ("amount", amount as Any), ("cryptoCurrency", cryptoCurrency as Any), ("cryptoAmount", cryptoAmount as Any)])
|
||||
case .messageActionGiftPremium(let flags, let currency, let amount, let months, let cryptoCurrency, let cryptoAmount):
|
||||
return ("messageActionGiftPremium", [("flags", flags as Any), ("currency", currency as Any), ("amount", amount as Any), ("months", months as Any), ("cryptoCurrency", cryptoCurrency as Any), ("cryptoAmount", cryptoAmount as Any)])
|
||||
case .messageActionGiftStars(let flags, let currency, let amount, let stars, let cryptoCurrency, let cryptoAmount, let transactionId):
|
||||
return ("messageActionGiftStars", [("flags", flags as Any), ("currency", currency as Any), ("amount", amount as Any), ("stars", stars as Any), ("cryptoCurrency", cryptoCurrency as Any), ("cryptoAmount", cryptoAmount as Any), ("transactionId", transactionId as Any)])
|
||||
case .messageActionGiveawayLaunch:
|
||||
return ("messageActionGiveawayLaunch", [])
|
||||
case .messageActionGiveawayResults(let winnersCount, let unclaimedCount):
|
||||
@ -1169,6 +1264,8 @@ public extension Api {
|
||||
return ("messageActionHistoryClear", [])
|
||||
case .messageActionInviteToGroupCall(let call, let users):
|
||||
return ("messageActionInviteToGroupCall", [("call", call as Any), ("users", users as Any)])
|
||||
case .messageActionPaymentRefunded(let flags, let peer, let currency, let totalAmount, let payload, let charge):
|
||||
return ("messageActionPaymentRefunded", [("flags", flags as Any), ("peer", peer as Any), ("currency", currency as Any), ("totalAmount", totalAmount as Any), ("payload", payload as Any), ("charge", charge as Any)])
|
||||
case .messageActionPaymentSent(let flags, let currency, let totalAmount, let invoiceSlug):
|
||||
return ("messageActionPaymentSent", [("flags", flags as Any), ("currency", currency as Any), ("totalAmount", totalAmount as Any), ("invoiceSlug", invoiceSlug as Any)])
|
||||
case .messageActionPaymentSentMe(let flags, let currency, let totalAmount, let payload, let info, let shippingOptionId, let charge):
|
||||
@ -1465,6 +1562,35 @@ public extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_messageActionGiftStars(_ reader: BufferReader) -> MessageAction? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: String?
|
||||
_2 = parseString(reader)
|
||||
var _3: Int64?
|
||||
_3 = reader.readInt64()
|
||||
var _4: Int64?
|
||||
_4 = reader.readInt64()
|
||||
var _5: String?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {_5 = parseString(reader) }
|
||||
var _6: Int64?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {_6 = reader.readInt64() }
|
||||
var _7: String?
|
||||
if Int(_1!) & Int(1 << 1) != 0 {_7 = parseString(reader) }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil
|
||||
let _c6 = (Int(_1!) & Int(1 << 0) == 0) || _6 != nil
|
||||
let _c7 = (Int(_1!) & Int(1 << 1) == 0) || _7 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
|
||||
return Api.MessageAction.messageActionGiftStars(flags: _1!, currency: _2!, amount: _3!, stars: _4!, cryptoCurrency: _5, cryptoAmount: _6, transactionId: _7)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_messageActionGiveawayLaunch(_ reader: BufferReader) -> MessageAction? {
|
||||
return Api.MessageAction.messageActionGiveawayLaunch
|
||||
}
|
||||
@ -1538,6 +1664,36 @@ public extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_messageActionPaymentRefunded(_ reader: BufferReader) -> MessageAction? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Api.Peer?
|
||||
if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.Peer
|
||||
}
|
||||
var _3: String?
|
||||
_3 = parseString(reader)
|
||||
var _4: Int64?
|
||||
_4 = reader.readInt64()
|
||||
var _5: Buffer?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {_5 = parseBytes(reader) }
|
||||
var _6: Api.PaymentCharge?
|
||||
if let signature = reader.readInt32() {
|
||||
_6 = Api.parse(reader, signature: signature) as? Api.PaymentCharge
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil
|
||||
let _c6 = _6 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
|
||||
return Api.MessageAction.messageActionPaymentRefunded(flags: _1!, peer: _2!, currency: _3!, totalAmount: _4!, payload: _5, charge: _6!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_messageActionPaymentSent(_ reader: BufferReader) -> MessageAction? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
|
@ -566,6 +566,58 @@ public extension Api {
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum StarsGiftOption: TypeConstructorDescription {
|
||||
case starsGiftOption(flags: Int32, stars: Int64, storeProduct: String?, currency: String, amount: Int64)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .starsGiftOption(let flags, let stars, let storeProduct, let currency, let amount):
|
||||
if boxed {
|
||||
buffer.appendInt32(1577421297)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt64(stars, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeString(storeProduct!, buffer: buffer, boxed: false)}
|
||||
serializeString(currency, buffer: buffer, boxed: false)
|
||||
serializeInt64(amount, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .starsGiftOption(let flags, let stars, let storeProduct, let currency, let amount):
|
||||
return ("starsGiftOption", [("flags", flags as Any), ("stars", stars as Any), ("storeProduct", storeProduct as Any), ("currency", currency as Any), ("amount", amount as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_starsGiftOption(_ reader: BufferReader) -> StarsGiftOption? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int64?
|
||||
_2 = reader.readInt64()
|
||||
var _3: String?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {_3 = parseString(reader) }
|
||||
var _4: String?
|
||||
_4 = parseString(reader)
|
||||
var _5: Int64?
|
||||
_5 = reader.readInt64()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
|
||||
let _c4 = _4 != nil
|
||||
let _c5 = _5 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 {
|
||||
return Api.StarsGiftOption.starsGiftOption(flags: _1!, stars: _2!, storeProduct: _3, currency: _4!, amount: _5!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public extension Api {
|
||||
enum StarsRevenueStatus: TypeConstructorDescription {
|
||||
case starsRevenueStatus(flags: Int32, currentBalance: Int64, availableBalance: Int64, overallRevenue: Int64, nextWithdrawalAt: Int32?)
|
||||
|
@ -8731,6 +8731,22 @@ public extension Api.functions.payments {
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.payments {
|
||||
static func getStarsGiftOptions(flags: Int32, userId: Api.InputUser?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<[Api.StarsGiftOption]>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-741774392)
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {userId!.serialize(buffer, true)}
|
||||
return (FunctionDescription(name: "payments.getStarsGiftOptions", parameters: [("flags", String(describing: flags)), ("userId", String(describing: userId))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> [Api.StarsGiftOption]? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: [Api.StarsGiftOption]?
|
||||
if let _ = reader.readInt32() {
|
||||
result = Api.parseVector(reader, elementSignature: 0, elementType: Api.StarsGiftOption.self)
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.payments {
|
||||
static func getStarsRevenueAdsAccountUrl(peer: Api.InputPeer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.payments.StarsRevenueAdsAccountUrl>) {
|
||||
let buffer = Buffer()
|
||||
|
@ -1007,7 +1007,7 @@ public extension Api {
|
||||
case inputInvoiceMessage(peer: Api.InputPeer, msgId: Int32)
|
||||
case inputInvoicePremiumGiftCode(purpose: Api.InputStorePaymentPurpose, option: Api.PremiumGiftCodeOption)
|
||||
case inputInvoiceSlug(slug: String)
|
||||
case inputInvoiceStars(option: Api.StarsTopupOption)
|
||||
case inputInvoiceStars(purpose: Api.InputStorePaymentPurpose)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
@ -1031,11 +1031,11 @@ public extension Api {
|
||||
}
|
||||
serializeString(slug, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .inputInvoiceStars(let option):
|
||||
case .inputInvoiceStars(let purpose):
|
||||
if boxed {
|
||||
buffer.appendInt32(497236696)
|
||||
buffer.appendInt32(1710230755)
|
||||
}
|
||||
option.serialize(buffer, true)
|
||||
purpose.serialize(buffer, true)
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -1048,8 +1048,8 @@ public extension Api {
|
||||
return ("inputInvoicePremiumGiftCode", [("purpose", purpose as Any), ("option", option as Any)])
|
||||
case .inputInvoiceSlug(let slug):
|
||||
return ("inputInvoiceSlug", [("slug", slug as Any)])
|
||||
case .inputInvoiceStars(let option):
|
||||
return ("inputInvoiceStars", [("option", option as Any)])
|
||||
case .inputInvoiceStars(let purpose):
|
||||
return ("inputInvoiceStars", [("purpose", purpose as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -1099,13 +1099,13 @@ public extension Api {
|
||||
}
|
||||
}
|
||||
public static func parse_inputInvoiceStars(_ reader: BufferReader) -> InputInvoice? {
|
||||
var _1: Api.StarsTopupOption?
|
||||
var _1: Api.InputStorePaymentPurpose?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.StarsTopupOption
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.InputStorePaymentPurpose
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
if _c1 {
|
||||
return Api.InputInvoice.inputInvoiceStars(option: _1!)
|
||||
return Api.InputInvoice.inputInvoiceStars(purpose: _1!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
@ -227,7 +227,7 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] {
|
||||
}
|
||||
|
||||
switch action {
|
||||
case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionSetMessagesTTL, .messageActionGroupCallScheduled, .messageActionSetChatTheme, .messageActionChatJoinedByRequest, .messageActionWebViewDataSent, .messageActionWebViewDataSentMe, .messageActionGiftPremium, .messageActionTopicCreate, .messageActionTopicEdit, .messageActionSuggestProfilePhoto, .messageActionSetChatWallPaper, .messageActionGiveawayLaunch, .messageActionGiveawayResults, .messageActionBoostApply, .messageActionRequestedPeerSentMe:
|
||||
case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionSetMessagesTTL, .messageActionGroupCallScheduled, .messageActionSetChatTheme, .messageActionChatJoinedByRequest, .messageActionWebViewDataSent, .messageActionWebViewDataSentMe, .messageActionGiftPremium, .messageActionGiftStars, .messageActionTopicCreate, .messageActionTopicEdit, .messageActionSuggestProfilePhoto, .messageActionSetChatWallPaper, .messageActionGiveawayLaunch, .messageActionGiveawayResults, .messageActionBoostApply, .messageActionRequestedPeerSentMe:
|
||||
break
|
||||
case let .messageActionChannelMigrateFrom(_, chatId):
|
||||
result.append(PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)))
|
||||
@ -258,6 +258,8 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] {
|
||||
if let boostPeer = boostPeer {
|
||||
result.append(boostPeer.peerId)
|
||||
}
|
||||
case let .messageActionPaymentRefunded(_, peer, _, _, _, _):
|
||||
result.append(peer.peerId)
|
||||
}
|
||||
|
||||
return result
|
||||
|
@ -102,6 +102,8 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe
|
||||
return TelegramMediaAction(action: .webViewData(text))
|
||||
case let .messageActionGiftPremium(_, currency, amount, months, cryptoCurrency, cryptoAmount):
|
||||
return TelegramMediaAction(action: .giftPremium(currency: currency, amount: amount, months: months, cryptoCurrency: cryptoCurrency, cryptoAmount: cryptoAmount))
|
||||
case let .messageActionGiftStars(_, currency, amount, stars, cryptoCurrency, cryptoAmount, transactionId):
|
||||
return TelegramMediaAction(action: .giftStars(currency: currency, amount: amount, count: stars, cryptoCurrency: cryptoCurrency, cryptoAmount: cryptoAmount, transactionId: transactionId))
|
||||
case let .messageActionTopicCreate(_, title, iconColor, iconEmojiId):
|
||||
return TelegramMediaAction(action: .topicCreated(title: title, iconColor: iconColor, iconFileId: iconEmojiId))
|
||||
case let .messageActionTopicEdit(flags, title, iconEmojiId, closed, hidden):
|
||||
@ -139,6 +141,13 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe
|
||||
return TelegramMediaAction(action: .giveawayResults(winners: winners, unclaimed: unclaimed))
|
||||
case let .messageActionBoostApply(boosts):
|
||||
return TelegramMediaAction(action: .boostsApplied(boosts: boosts))
|
||||
case let .messageActionPaymentRefunded(_, peer, currency, totalAmount, payload, charge):
|
||||
let transactionId: String
|
||||
switch charge {
|
||||
case let .paymentCharge(id, _):
|
||||
transactionId = id
|
||||
}
|
||||
return TelegramMediaAction(action: .paymentRefunded(peerId: peer.peerId, currency: currency, totalAmount: totalAmount, payload: payload?.makeData(), transactionId: transactionId))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ public class BoxedMessage: NSObject {
|
||||
|
||||
public class Serialization: NSObject, MTSerialization {
|
||||
public func currentLayer() -> UInt {
|
||||
return 183
|
||||
return 185
|
||||
}
|
||||
|
||||
public func parseMessage(_ data: Data!) -> Any! {
|
||||
|
@ -127,6 +127,8 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
case joinedChannel
|
||||
case giveawayResults(winners: Int32, unclaimed: Int32)
|
||||
case boostsApplied(boosts: Int32)
|
||||
case paymentRefunded(peerId: PeerId, currency: String, totalAmount: Int64, payload: Data?, transactionId: String)
|
||||
case giftStars(currency: String, amount: Int64, count: Int64, cryptoCurrency: String?, cryptoAmount: Int64?, transactionId: String?)
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
let rawValue: Int32 = decoder.decodeInt32ForKey("_rawValue", orElse: 0)
|
||||
@ -235,6 +237,10 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
self = .giveawayResults(winners: decoder.decodeInt32ForKey("winners", orElse: 0), unclaimed: decoder.decodeInt32ForKey("unclaimed", orElse: 0))
|
||||
case 40:
|
||||
self = .boostsApplied(boosts: decoder.decodeInt32ForKey("boosts", orElse: 0))
|
||||
case 41:
|
||||
self = .paymentRefunded(peerId: PeerId(decoder.decodeInt64ForKey("pi", orElse: 0)), currency: decoder.decodeStringForKey("currency", orElse: ""), totalAmount: decoder.decodeInt64ForKey("amount", orElse: 0), payload: decoder.decodeDataForKey("payload"), transactionId: decoder.decodeStringForKey("transactionId", orElse: ""))
|
||||
case 42:
|
||||
self = .giftStars(currency: decoder.decodeStringForKey("currency", orElse: ""), amount: decoder.decodeInt64ForKey("amount", orElse: 0), count: decoder.decodeInt64ForKey("count", orElse: 0), cryptoCurrency: decoder.decodeOptionalStringForKey("cryptoCurrency"), cryptoAmount: decoder.decodeOptionalInt64ForKey("cryptoAmount"), transactionId: decoder.decodeOptionalStringForKey("transactionId"))
|
||||
default:
|
||||
self = .unknown
|
||||
}
|
||||
@ -457,6 +463,34 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
case let .boostsApplied(boosts):
|
||||
encoder.encodeInt32(40, forKey: "_rawValue")
|
||||
encoder.encodeInt32(boosts, forKey: "boosts")
|
||||
case let .paymentRefunded(peerId, currency, totalAmount, payload, transactionId):
|
||||
encoder.encodeInt32(41, forKey: "_rawValue")
|
||||
encoder.encodeInt64(peerId.toInt64(), forKey: "pi")
|
||||
encoder.encodeString(currency, forKey: "currency")
|
||||
encoder.encodeInt64(totalAmount, forKey: "amount")
|
||||
if let payload {
|
||||
encoder.encodeData(payload, forKey: "payload")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "payload")
|
||||
}
|
||||
encoder.encodeString(transactionId, forKey: "transactionId")
|
||||
case let .giftStars(currency, amount, count, cryptoCurrency, cryptoAmount, transactionId):
|
||||
encoder.encodeInt32(42, forKey: "_rawValue")
|
||||
encoder.encodeString(currency, forKey: "currency")
|
||||
encoder.encodeInt64(amount, forKey: "amount")
|
||||
encoder.encodeInt64(count, forKey: "count")
|
||||
if let cryptoCurrency = cryptoCurrency, let cryptoAmount = cryptoAmount {
|
||||
encoder.encodeString(cryptoCurrency, forKey: "cryptoCurrency")
|
||||
encoder.encodeInt64(cryptoAmount, forKey: "cryptoAmount")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "cryptoCurrency")
|
||||
encoder.encodeNil(forKey: "cryptoAmount")
|
||||
}
|
||||
if let transactionId {
|
||||
encoder.encodeString(transactionId, forKey: "transactionId")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "transactionId")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -480,6 +514,8 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
return peerIds
|
||||
case let .giftCode(_, _, _, boostPeerId, _, _, _, _, _):
|
||||
return boostPeerId.flatMap { [$0] } ?? []
|
||||
case let .paymentRefunded(peerId, _, _, _, _):
|
||||
return [peerId]
|
||||
default:
|
||||
return []
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ public enum AppStoreTransactionPurpose {
|
||||
case giftCode(peerIds: [EnginePeer.Id], boostPeer: EnginePeer.Id?, currency: String, amount: Int64)
|
||||
case giveaway(boostPeer: EnginePeer.Id, additionalPeerIds: [EnginePeer.Id], countries: [String], onlyNewSubscribers: Bool, showWinners: Bool, prizeDescription: String?, randomId: Int64, untilDate: Int32, currency: String, amount: Int64)
|
||||
case stars(count: Int64, currency: String, amount: Int64)
|
||||
case starsGift(peerId: EnginePeer.Id, count: Int64, currency: String, amount: Int64)
|
||||
}
|
||||
|
||||
private func apiInputStorePaymentPurpose(account: Account, purpose: AppStoreTransactionPurpose) -> Signal<Api.InputStorePaymentPurpose, NoError> {
|
||||
@ -91,7 +92,15 @@ private func apiInputStorePaymentPurpose(account: Account, purpose: AppStoreTran
|
||||
}
|
||||
|> switchToLatest
|
||||
case let .stars(count, currency, amount):
|
||||
return .single(.inputStorePaymentStars(flags: 0, stars: count, currency: currency, amount: amount))
|
||||
return .single(.inputStorePaymentStarsTopup(stars: count, currency: currency, amount: amount))
|
||||
case let .starsGift(peerId, count, currency, amount):
|
||||
return account.postbox.loadedPeerWithId(peerId)
|
||||
|> mapToSignal { peer -> Signal<Api.InputStorePaymentPurpose, NoError> in
|
||||
guard let inputUser = apiInputUser(peer) else {
|
||||
return .complete()
|
||||
}
|
||||
return .single(.inputStorePaymentStarsGift(userId: inputUser, stars: count, currency: currency, amount: amount))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ public enum BotPaymentInvoiceSource {
|
||||
case premiumGiveaway(boostPeer: EnginePeer.Id, additionalPeerIds: [EnginePeer.Id], countries: [String], onlyNewSubscribers: Bool, showWinners: Bool, prizeDescription: String?, randomId: Int64, untilDate: Int32, currency: String, amount: Int64, option: PremiumGiftCodeOption)
|
||||
case giftCode(users: [PeerId], currency: String, amount: Int64, option: PremiumGiftCodeOption)
|
||||
case stars(option: StarsTopUpOption)
|
||||
case starsGift(peerId: EnginePeer.Id, count: Int64, currency: String, amount: Int64)
|
||||
}
|
||||
|
||||
public struct BotPaymentInvoiceFields: OptionSet {
|
||||
@ -307,9 +308,12 @@ func _internal_parseInputInvoice(transaction: Transaction, source: BotPaymentInv
|
||||
if let _ = option.storeProductId {
|
||||
flags |= (1 << 0)
|
||||
}
|
||||
return .inputInvoiceStars(
|
||||
option: .starsTopupOption(flags: flags, stars: option.count, storeProduct: option.storeProductId, currency: option.currency, amount: option.amount)
|
||||
)
|
||||
return .inputInvoiceStars(purpose: .inputStorePaymentStarsTopup(stars: option.count, currency: option.currency, amount: option.amount))
|
||||
case let .starsGift(peerId, count, currency, amount):
|
||||
guard let peer = transaction.getPeer(peerId), let inputUser = apiInputUser(peer) else {
|
||||
return nil
|
||||
}
|
||||
return .inputInvoiceStars(purpose: .inputStorePaymentStarsGift(userId: inputUser, stars: count, currency: currency, amount: amount))
|
||||
}
|
||||
}
|
||||
|
||||
@ -608,9 +612,7 @@ func _internal_sendBotPaymentForm(account: Account, formId: Int64, source: BotPa
|
||||
receiptMessageId = id
|
||||
}
|
||||
}
|
||||
case .giftCode:
|
||||
receiptMessageId = nil
|
||||
case .stars:
|
||||
case .giftCode, .stars, .starsGift:
|
||||
receiptMessageId = nil
|
||||
}
|
||||
}
|
||||
|
@ -4,24 +4,27 @@ import MtProtoKit
|
||||
import SwiftSignalKit
|
||||
import TelegramApi
|
||||
|
||||
public struct StarsTopUpOption: Codable, Equatable {
|
||||
public struct StarsTopUpOption: Equatable, Codable {
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case count
|
||||
case storeProductId
|
||||
case currency
|
||||
case amount
|
||||
case isExtended
|
||||
}
|
||||
|
||||
public let count: Int64
|
||||
public let storeProductId: String?
|
||||
public let currency: String
|
||||
public let amount: Int64
|
||||
public let isExtended: Bool
|
||||
|
||||
public init(count: Int64, storeProductId: String?, currency: String, amount: Int64) {
|
||||
public init(count: Int64, storeProductId: String?, currency: String, amount: Int64, isExtended: Bool) {
|
||||
self.count = count
|
||||
self.storeProductId = storeProductId
|
||||
self.currency = currency
|
||||
self.amount = amount
|
||||
self.isExtended = isExtended
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
@ -30,7 +33,7 @@ public struct StarsTopUpOption: Codable, Equatable {
|
||||
self.storeProductId = try container.decodeIfPresent(String.self, forKey: .storeProductId)
|
||||
self.currency = try container.decode(String.self, forKey: .currency)
|
||||
self.amount = try container.decode(Int64.self, forKey: .amount)
|
||||
|
||||
self.isExtended = try container.decodeIfPresent(Bool.self, forKey: .isExtended) ?? false
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@ -39,14 +42,15 @@ public struct StarsTopUpOption: Codable, Equatable {
|
||||
try container.encodeIfPresent(self.storeProductId, forKey: .storeProductId)
|
||||
try container.encode(self.currency, forKey: .currency)
|
||||
try container.encode(self.amount, forKey: .amount)
|
||||
try container.encode(self.isExtended, forKey: .isExtended)
|
||||
}
|
||||
}
|
||||
|
||||
extension StarsTopUpOption {
|
||||
init(apiStarsTopupOption: Api.StarsTopupOption) {
|
||||
switch apiStarsTopupOption {
|
||||
case let .starsTopupOption(_, stars, storeProduct, currency, amount):
|
||||
self.init(count: stars, storeProductId: storeProduct, currency: currency, amount: amount)
|
||||
case let .starsTopupOption(flags, stars, storeProduct, currency, amount):
|
||||
self.init(count: stars, storeProductId: storeProduct, currency: currency, amount: amount, isExtended: (flags & (1 << 1)) != 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -66,6 +70,81 @@ func _internal_starsTopUpOptions(account: Account) -> Signal<[StarsTopUpOption],
|
||||
}
|
||||
}
|
||||
|
||||
public struct StarsGiftOption: Equatable, Codable {
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case count
|
||||
case currency
|
||||
case amount
|
||||
case storeProductId
|
||||
case isExtended
|
||||
}
|
||||
|
||||
public let count: Int64
|
||||
public let currency: String
|
||||
public let amount: Int64
|
||||
public let storeProductId: String?
|
||||
public let isExtended: Bool
|
||||
|
||||
public init(count: Int64, storeProductId: String?, currency: String, amount: Int64, isExtended: Bool) {
|
||||
self.count = count
|
||||
self.currency = currency
|
||||
self.amount = amount
|
||||
self.storeProductId = storeProductId
|
||||
self.isExtended = isExtended
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
self.count = try container.decode(Int64.self, forKey: .count)
|
||||
self.storeProductId = try container.decodeIfPresent(String.self, forKey: .storeProductId)
|
||||
self.currency = try container.decode(String.self, forKey: .currency)
|
||||
self.amount = try container.decode(Int64.self, forKey: .amount)
|
||||
self.isExtended = try container.decodeIfPresent(Bool.self, forKey: .isExtended) ?? false
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(self.count, forKey: .count)
|
||||
try container.encodeIfPresent(self.storeProductId, forKey: .storeProductId)
|
||||
try container.encode(self.currency, forKey: .currency)
|
||||
try container.encode(self.amount, forKey: .amount)
|
||||
try container.encode(self.isExtended, forKey: .isExtended)
|
||||
}
|
||||
}
|
||||
|
||||
extension StarsGiftOption {
|
||||
init(apiStarsGiftOption: Api.StarsGiftOption) {
|
||||
switch apiStarsGiftOption {
|
||||
case let .starsGiftOption(flags, stars, storeProduct, currency, amount):
|
||||
self.init(count: stars, storeProductId: storeProduct, currency: currency, amount: amount, isExtended: (flags & (1 << 1)) != 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func _internal_starsGiftOptions(account: Account, peerId: EnginePeer.Id?) -> Signal<[StarsGiftOption], NoError> {
|
||||
return account.postbox.transaction { transaction -> Api.InputUser? in
|
||||
return peerId.flatMap { transaction.getPeer($0).flatMap(apiInputUser) }
|
||||
}
|
||||
|> mapToSignal { inputUser in
|
||||
var flags: Int32 = 0
|
||||
if let _ = inputUser {
|
||||
flags |= (1 << 0)
|
||||
}
|
||||
return account.network.request(Api.functions.payments.getStarsGiftOptions(flags: flags, userId: inputUser))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<[Api.StarsGiftOption]?, NoError> in
|
||||
return .single(nil)
|
||||
}
|
||||
|> mapToSignal { results -> Signal<[StarsGiftOption], NoError> in
|
||||
if let results = results {
|
||||
return .single(results.map { StarsGiftOption(apiStarsGiftOption: $0) })
|
||||
} else {
|
||||
return .single([])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct InternalStarsStatus {
|
||||
let balance: Int64
|
||||
let transactions: [StarsContext.State.Transaction]
|
||||
@ -278,6 +357,9 @@ private extension StarsContext.State.Transaction {
|
||||
if (apiFlags & (1 << 6)) != 0 {
|
||||
flags.insert(.isFailed)
|
||||
}
|
||||
if (apiFlags & (1 << 10)) != 0 {
|
||||
flags.insert(.isGift)
|
||||
}
|
||||
|
||||
let media = extendedMedia.flatMap({ $0.compactMap { textMediaAndExpirationTimerFromApiMedia($0, PeerId(0)).media } }) ?? []
|
||||
self.init(flags: flags, id: id, count: stars, date: date, peer: parsedPeer, title: title, description: description, photo: photo.flatMap(TelegramMediaWebFile.init), transactionDate: transactionDate, transactionUrl: transactionUrl, paidMessageId: paidMessageId, media: media)
|
||||
@ -299,6 +381,7 @@ public final class StarsContext {
|
||||
public static let isLocal = Flags(rawValue: 1 << 1)
|
||||
public static let isPending = Flags(rawValue: 1 << 2)
|
||||
public static let isFailed = Flags(rawValue: 1 << 3)
|
||||
public static let isGift = Flags(rawValue: 1 << 4)
|
||||
}
|
||||
|
||||
public enum Peer: Equatable {
|
||||
@ -734,9 +817,7 @@ func _internal_sendStarsPaymentForm(account: Account, formId: Int64, source: Bot
|
||||
receiptMessageId = id
|
||||
}
|
||||
}
|
||||
case .giftCode:
|
||||
receiptMessageId = nil
|
||||
case .stars:
|
||||
case .giftCode, .stars, .starsGift:
|
||||
receiptMessageId = nil
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +70,10 @@ public extension TelegramEngine {
|
||||
return _internal_starsTopUpOptions(account: self.account)
|
||||
}
|
||||
|
||||
public func starsGiftOptions(peerId: EnginePeer.Id?) -> Signal<[StarsGiftOption], NoError> {
|
||||
return _internal_starsGiftOptions(account: self.account, peerId: peerId)
|
||||
}
|
||||
|
||||
public func peerStarsContext() -> StarsContext {
|
||||
return StarsContext(account: self.account)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user