Skip to content

Instantly share code, notes, and snippets.

@jamesrochabrun
Last active January 3, 2022 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesrochabrun/3e180a92d40ef092e10d7dffb0e52510 to your computer and use it in GitHub Desktop.
Save jamesrochabrun/3e180a92d40ef092e10d7dffb0e52510 to your computer and use it in GitHub Desktop.
Itunes category identifier model.
enum ItunesCategoryIdentifier: Int, CaseIterable {
// 1
case apps
case podcasts
case tvShows
// 2
var title: String {
switch self {
case .apps: return "Apps From the Appstore"
case .podcasts: return "Podcasts"
case .music: return "Music"
}
}
// 3
private static let limit = 4 // the number of results that we want from each category.
// 4
var mediaType: MediaType {
switch self {
case .apps: return .apps(contentType: .apps, chart: .topFree, limit: Self.limit, format: .json)
case .podcasts: return .podcasts(contentType: .episodes, chart: .top, limit: Self.limit, format: .json)
case .music: return .music(contentType: .albums, chart: .mostPlayed, limit: Self.limit, format: .json)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment