🚚 Rename purchase parameter, set default to false

This commit is contained in:
Ben Chatelain 2020-05-14 21:24:27 -06:00
parent a9553ae4d0
commit f47e0bef3b
6 changed files with 11 additions and 9 deletions

View file

@ -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?

View file

@ -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
}

View file

@ -37,7 +37,7 @@ public struct InstallCommand: CommandProtocol {
return nil
}
return download(appId, isPurchase: false)
return download(appId)
}
switch downloadResults.count {

View file

@ -73,7 +73,7 @@ public struct LuckyCommand: CommandProtocol {
return nil
}
return download(appId, isPurchase: false)
return download(appId)
}
switch downloadResults.count {

View file

@ -36,7 +36,7 @@ public struct PurchaseCommand: CommandProtocol {
return nil
}
return download(appId, isPurchase: true)
return download(appId, purchase: true)
}
switch downloadResults.count {

View file

@ -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 {