Improve MediaKind usage.

This commit is contained in:
Damiano Galassi committed 2020-02-04 17:54:08 +01:00
1 parent 2ad39bfed6
commit 2694bdee45
9 files changed
+185 -191

No files matched your search

+4 -4
View File
@@ -19,14 +19,14 @@ final class Ratings {
self.countries = countries
}
func rating(countryCode: String, media: String, name: String) -> Rating? {
func rating(countryCode: String, mediaKind: MediaKind, name: String) -> Rating? {
guard let country = countries.first(where: { $0.displayName == countryCode }) else { return nil }
return country.ratings.first(where: {$0.media.contains(media) && $0.displayName == name})
return country.ratings.first(where: {$0.media.contains(mediaKind.description) && $0.displayName == name})
}
func rating(storeCode: Int, media: String, code: String) -> Rating? {
func rating(storeCode: Int, mediaKind: MediaKind, code: String) -> Rating? {
guard let country = countries.first(where: { $0.storeCode == storeCode }) else { return nil }
return country.ratings.first(where: {$0.media.contains(media) && $0.code == code})
return country.ratings.first(where: {$0.media.contains(mediaKind.description) && $0.code == code})
}
}