mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Update API
This commit is contained in:
@@ -120,7 +120,7 @@ func _internal_getPremiumGiveawayInfo(account: Account, peerId: EnginePeer.Id, m
|
||||
} else {
|
||||
return .ongoing(startDate: startDate, status: .notQualified)
|
||||
}
|
||||
case let .giveawayInfoResults(flags, startDate, giftCodeSlug, finishDate, winnersCount, activatedCount):
|
||||
case let .giveawayInfoResults(flags, startDate, giftCodeSlug, finishDate, winnersCount, activatedCount, _):
|
||||
let status: PremiumGiveawayInfo.ResultStatus
|
||||
if (flags & (1 << 1)) != 0 {
|
||||
status = .refunded
|
||||
@@ -201,18 +201,19 @@ public enum LaunchPrepaidGiveawayError {
|
||||
case generic
|
||||
}
|
||||
|
||||
func _internal_launchPrepaidGiveaway(account: Account, peerId: EnginePeer.Id, id: Int64, additionalPeerIds: [EnginePeer.Id], countries: [String], onlyNewSubscribers: Bool, randomId: Int64, untilDate: Int32) -> Signal<Never, LaunchPrepaidGiveawayError> {
|
||||
func _internal_launchPrepaidGiveaway(account: Account, peerId: EnginePeer.Id, id: Int64, additionalPeerIds: [EnginePeer.Id], countries: [String], onlyNewSubscribers: Bool, showWinners: Bool, prizeDescription: String?, randomId: Int64, untilDate: Int32) -> Signal<Never, LaunchPrepaidGiveawayError> {
|
||||
return account.postbox.transaction { transaction -> Signal<Never, LaunchPrepaidGiveawayError> in
|
||||
var flags: Int32 = 0
|
||||
if onlyNewSubscribers {
|
||||
flags |= (1 << 0)
|
||||
}
|
||||
|
||||
if showWinners {
|
||||
flags |= (1 << 3)
|
||||
}
|
||||
var inputPeer: Api.InputPeer?
|
||||
if let peer = transaction.getPeer(peerId), let apiPeer = apiInputPeer(peer) {
|
||||
inputPeer = apiPeer
|
||||
}
|
||||
|
||||
var additionalPeers: [Api.InputPeer] = []
|
||||
if !additionalPeerIds.isEmpty {
|
||||
flags |= (1 << 1)
|
||||
@@ -222,15 +223,16 @@ func _internal_launchPrepaidGiveaway(account: Account, peerId: EnginePeer.Id, id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !countries.isEmpty {
|
||||
flags |= (1 << 2)
|
||||
}
|
||||
|
||||
if let _ = prizeDescription {
|
||||
flags |= (1 << 4)
|
||||
}
|
||||
guard let inputPeer = inputPeer else {
|
||||
return .complete()
|
||||
}
|
||||
return account.network.request(Api.functions.payments.launchPrepaidGiveaway(peer: inputPeer, giveawayId: id, purpose: .inputStorePaymentPremiumGiveaway(flags: flags, boostPeer: inputPeer, additionalPeers: additionalPeers, countriesIso2: countries, randomId: randomId, untilDate: untilDate, currency: "", amount: 0)))
|
||||
return account.network.request(Api.functions.payments.launchPrepaidGiveaway(peer: inputPeer, giveawayId: id, purpose: .inputStorePaymentPremiumGiveaway(flags: flags, boostPeer: inputPeer, additionalPeers: additionalPeers, countriesIso2: countries, prizeDescription: prizeDescription, randomId: randomId, untilDate: untilDate, currency: "", amount: 0)))
|
||||
|> mapError { _ -> LaunchPrepaidGiveawayError in
|
||||
return .generic
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user