mirror of
https://github.com/mas-cli/mas
synced 2024-11-22 11:33:13 +00:00
🚚 Rename purchase parameter, set default to false
This commit is contained in:
parent
a9553ae4d0
commit
f47e0bef3b
6 changed files with 11 additions and 9 deletions
|
@ -12,15 +12,17 @@ import StoreFoundation
|
|||
/// Monitors app download progress.
|
||||
///
|
||||
/// - Parameter adamId: An app ID?
|
||||
/// - Parameter purchase: Flag indicating whether the app needs to be purchased.
|
||||
/// Only works for free apps. Defaults to false.
|
||||
/// - Returns: An error, if one occurred.
|
||||
func download(_ adamId: UInt64, isPurchase: Bool) -> MASError? {
|
||||
func download(_ adamId: UInt64, purchase: Bool = false) -> MASError? {
|
||||
guard let account = ISStoreAccount.primaryAccount else {
|
||||
return .notSignedIn
|
||||
}
|
||||
|
||||
guard let storeAccount = account as? ISStoreAccount
|
||||
else { fatalError("Unable to cast StoreAccount to ISStoreAccount") }
|
||||
let purchase = SSPurchase(adamId: adamId, account: storeAccount, isPurchase: isPurchase)
|
||||
let purchase = SSPurchase(adamId: adamId, account: storeAccount, purchase: purchase)
|
||||
|
||||
var purchaseError: MASError?
|
||||
var observerIdentifier: CKDownloadQueueObserver?
|
||||
|
|
|
@ -13,7 +13,7 @@ typealias SSPurchaseCompletion =
|
|||
(_ purchase: SSPurchase?, _ completed: Bool, _ error: Error?, _ response: SSPurchaseResponse?) -> Void
|
||||
|
||||
extension SSPurchase {
|
||||
convenience init(adamId: UInt64, account: ISStoreAccount, isPurchase: Bool) {
|
||||
convenience init(adamId: UInt64, account: ISStoreAccount, purchase: Bool = false) {
|
||||
self.init()
|
||||
|
||||
var parameters: [String: Any] = [
|
||||
|
@ -24,7 +24,7 @@ extension SSPurchase {
|
|||
"appExtVrsId": 0
|
||||
]
|
||||
|
||||
if isPurchase {
|
||||
if purchase {
|
||||
parameters["macappinstalledconfirmed"] = 1
|
||||
parameters["pricingParameters"] = "STDQ"
|
||||
|
||||
|
@ -42,7 +42,7 @@ extension SSPurchase {
|
|||
appleID = account.identifier
|
||||
|
||||
// Not sure if this is needed, but lets use it here.
|
||||
if isPurchase {
|
||||
if purchase {
|
||||
isRedownload = false
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public struct InstallCommand: CommandProtocol {
|
|||
return nil
|
||||
}
|
||||
|
||||
return download(appId, isPurchase: false)
|
||||
return download(appId)
|
||||
}
|
||||
|
||||
switch downloadResults.count {
|
||||
|
|
|
@ -73,7 +73,7 @@ public struct LuckyCommand: CommandProtocol {
|
|||
return nil
|
||||
}
|
||||
|
||||
return download(appId, isPurchase: false)
|
||||
return download(appId)
|
||||
}
|
||||
|
||||
switch downloadResults.count {
|
||||
|
|
|
@ -36,7 +36,7 @@ public struct PurchaseCommand: CommandProtocol {
|
|||
return nil
|
||||
}
|
||||
|
||||
return download(appId, isPurchase: true)
|
||||
return download(appId, purchase: true)
|
||||
}
|
||||
|
||||
switch downloadResults.count {
|
||||
|
|
|
@ -71,7 +71,7 @@ public struct UpgradeCommand: CommandProtocol {
|
|||
print(updates.map({ "\($0.title) (\($0.bundleVersion))" }).joined(separator: ", "))
|
||||
|
||||
let updateResults = updates.compactMap {
|
||||
download($0.itemIdentifier.uint64Value, isPurchase: false)
|
||||
download($0.itemIdentifier.uint64Value)
|
||||
}
|
||||
|
||||
switch updateResults.count {
|
||||
|
|
Loading…
Reference in a new issue