Add & use Entity.desktopSoftware instead of macSoftware.

`desktopSoftware` returns info (including version & description) that aligns with what is displayed earlier in the App Store, while `macSoftware` is at least sometimes out of alignment.

Partial #561

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
Ross Goldberg 2024-10-14 16:24:39 -04:00
parent 6489daa0e3
commit 6c5a277ad9
No known key found for this signature in database
3 changed files with 10 additions and 6 deletions

View file

@ -40,7 +40,7 @@ class MasStoreSearch: StoreSearch {
func search(for appName: String) -> Promise<[SearchResult]> {
// Search for apps for compatible platforms, in order of preference.
// Macs with Apple Silicon can run iPad and iPhone apps.
var entities = [Entity.macSoftware]
var entities = [Entity.desktopSoftware]
if SysCtlSystemCommand.isAppleSilicon {
entities += [.iPadSoftware, .iPhoneSoftware]
}

View file

@ -16,6 +16,7 @@ protocol StoreSearch {
}
enum Entity: String {
case desktopSoftware
case macSoftware
case iPadSoftware
case iPhoneSoftware = "software"
@ -27,7 +28,11 @@ extension StoreSearch {
///
/// - Parameter appName: MAS app identifier.
/// - Returns: URL for the search service or nil if appName can't be encoded.
func searchURL(for appName: String, inCountry country: String?, ofEntity entity: Entity = .macSoftware) -> URL? {
func searchURL(
for appName: String,
inCountry country: String?,
ofEntity entity: Entity = .desktopSoftware
) -> URL? {
guard var components = URLComponents(string: "https://itunes.apple.com/search") else {
return nil
}

View file

@ -18,17 +18,16 @@ public class MasStoreSearchSpec: QuickSpec {
}
describe("url string") {
it("contains the app name") {
let appName = "myapp"
expect {
MasStoreSearch().searchURL(for: appName, inCountry: "US")?.absoluteString
MasStoreSearch().searchURL(for: "myapp", inCountry: "US")?.absoluteString
}
== "https://itunes.apple.com/search?media=software&entity=macSoftware&term=\(appName)&country=US"
== "https://itunes.apple.com/search?media=software&entity=desktopSoftware&term=myapp&country=US"
}
it("contains the encoded app name") {
expect {
MasStoreSearch().searchURL(for: "My App", inCountry: "US")?.absoluteString
}
== "https://itunes.apple.com/search?media=software&entity=macSoftware&term=My%20App&country=US"
== "https://itunes.apple.com/search?media=software&entity=desktopSoftware&term=My%20App&country=US"
}
}
describe("store") {