diff --git a/README.md b/README.md index 0116adf..237f408 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ You can use The Swift Package Manager to install SwiftEmailValidator by adding i ### Usage ```swift +import AppStoreReviewsAPI + let appStore = AppStoreReviewsAPI(appID: "310633997") // This app id belongs to WhatsApp let reviews = try await appStore.reviews() diff --git a/Sources/AppStoreReviewsAPI/AppStoreReviewsAPI.swift b/Sources/AppStoreReviewsAPI/AppStoreReviewsAPI.swift index a005118..a306bf8 100644 --- a/Sources/AppStoreReviewsAPI/AppStoreReviewsAPI.swift +++ b/Sources/AppStoreReviewsAPI/AppStoreReviewsAPI.swift @@ -10,22 +10,14 @@ public struct AppStoreReviewsAPI { case mostRecent = "mostrecent" } - var appID = String() - var page: String = "1" - var sortBy: Sortby = .mostHelpful - private var url: String? public init(appID: String, page: String = "1", sortBy: Sortby = .mostHelpful) { - self.appID = appID - self.page = page - self.sortBy = sortBy - url = "https://itunes.apple.com/rss/customerreviews/page=" + page + "/id=" + appID + "/sortby=" + sortBy.rawValue + "/json?l=en&cc=gb" } - func reviews() async throws -> ReviewsFeed { + public func reviews() async throws -> ReviewsFeed { guard let urlString = url, let url = URL(string: urlString) diff --git a/Sources/AppStoreReviewsAPI/Models/Author/Author.swift b/Sources/AppStoreReviewsAPI/Models/Author/Author.swift index c6473fd..d0e313d 100644 --- a/Sources/AppStoreReviewsAPI/Models/Author/Author.swift +++ b/Sources/AppStoreReviewsAPI/Models/Author/Author.swift @@ -7,12 +7,12 @@ import Foundation -struct Author: Decodable { +public struct Author: Decodable { - let name, uri: URI + public let name, uri: URI } -struct URI: Decodable { +public struct URI: Decodable { - let label: String + public let label: String } diff --git a/Sources/AppStoreReviewsAPI/Models/Entry/Entry.swift b/Sources/AppStoreReviewsAPI/Models/Entry/Entry.swift index 2b14532..1624c4a 100644 --- a/Sources/AppStoreReviewsAPI/Models/Entry/Entry.swift +++ b/Sources/AppStoreReviewsAPI/Models/Entry/Entry.swift @@ -7,17 +7,17 @@ import Foundation -struct Entry: Decodable { - - let author: EntryAuthor - let updated: Updated - let imRating, imVersion, id: ID - let title: Title - let content: Content - let link: EntryLink - let imVoteSum: Vote - let imContentType: IMContentType - let imVoteCount: Vote +public struct Entry: Decodable { + + public let author: EntryAuthor + public let updated: Updated + public let imRating, imVersion, id: ID + public let title: Title + public let content: Content + public let link: EntryLink + public let imVoteSum: Vote + public let imContentType: IMContentType + public let imVoteCount: Vote enum CodingKeys: String, CodingKey { @@ -32,64 +32,64 @@ struct Entry: Decodable { } // MARK: - Author -struct EntryAuthor: Decodable { +public struct EntryAuthor: Decodable { - let uri, name: ID - let label: String + public let uri, name: ID + public let label: String } // MARK: - Content -struct Content: Decodable { +public struct Content: Decodable { - let label: String - let attributes: ContentAttributes + public let label: String + public let attributes: ContentAttributes } // MARK: - ContentAttributes -struct ContentAttributes: Decodable { +public struct ContentAttributes: Decodable { - let type: TypeEnum + public let type: TypeEnum } -enum TypeEnum: String, Decodable { +public enum TypeEnum: String, Decodable { case text = "text" } // MARK: - Vote -struct Vote: Decodable { +public struct Vote: Decodable { - let label: String + public let label: String } // MARK: - IMContentType -struct IMContentType: Decodable { +public struct IMContentType: Decodable { - let attributes: IMContentTypeAttributes + public let attributes: IMContentTypeAttributes } // MARK: - IMContentTypeAttributes -struct IMContentTypeAttributes: Decodable { +public struct IMContentTypeAttributes: Decodable { - let term, label: Label + public let term, label: Label } -enum Label: String, Decodable { +public enum Label: String, Decodable { case application = "Application" } // MARK: - EntryLink -struct EntryLink: Decodable { +public struct EntryLink: Decodable { - let attributes: LinkAttributes + public let attributes: LinkAttributes } // MARK: - LinkAttributes -struct LinkAttributes: Decodable { +public struct LinkAttributes: Decodable { - let rel: String - let href: String + public let rel: String + public let href: String } diff --git a/Sources/AppStoreReviewsAPI/Models/ID/ID.swift b/Sources/AppStoreReviewsAPI/Models/ID/ID.swift index 4b9fe0b..e3949a1 100644 --- a/Sources/AppStoreReviewsAPI/Models/ID/ID.swift +++ b/Sources/AppStoreReviewsAPI/Models/ID/ID.swift @@ -7,7 +7,7 @@ import Foundation -struct ID: Decodable { +public struct ID: Decodable { - let label: String + public let label: String } diff --git a/Sources/AppStoreReviewsAPI/Models/Icon/Icon.swift b/Sources/AppStoreReviewsAPI/Models/Icon/Icon.swift index 7678e26..19b614f 100644 --- a/Sources/AppStoreReviewsAPI/Models/Icon/Icon.swift +++ b/Sources/AppStoreReviewsAPI/Models/Icon/Icon.swift @@ -7,7 +7,7 @@ import Foundation -struct Icon: Decodable { +public struct Icon: Decodable { - let label: String + public let label: String } diff --git a/Sources/AppStoreReviewsAPI/Models/Link/Link.swift b/Sources/AppStoreReviewsAPI/Models/Link/Link.swift index a33dfa3..5704d5f 100644 --- a/Sources/AppStoreReviewsAPI/Models/Link/Link.swift +++ b/Sources/AppStoreReviewsAPI/Models/Link/Link.swift @@ -7,14 +7,14 @@ import Foundation -struct Link: Decodable { +public struct Link: Decodable { - let attributes: Attributes + public let attributes: Attributes } -struct Attributes: Decodable { +public struct Attributes: Decodable { - let rel: String - let type: String? - let href: String + public let rel: String + public let type: String? + public let href: String } diff --git a/Sources/AppStoreReviewsAPI/Models/ReviewsFeed.swift b/Sources/AppStoreReviewsAPI/Models/ReviewsFeed.swift index a89e536..ad7c4c1 100644 --- a/Sources/AppStoreReviewsAPI/Models/ReviewsFeed.swift +++ b/Sources/AppStoreReviewsAPI/Models/ReviewsFeed.swift @@ -7,19 +7,19 @@ import Foundation -struct ReviewsFeed: Decodable { +public struct ReviewsFeed: Decodable { - let feed: Feed + public let feed: Feed } -struct Feed: Decodable { +public struct Feed: Decodable { - let id: ID - let author: Author - let entry: [Entry] - let updated: Updated - let rights: Rights - let title: Title - let icon: Icon - let link: [Link] + public let id: ID + public let author: Author + public let entry: [Entry] + public let updated: Updated + public let rights: Rights + public let title: Title + public let icon: Icon + public let link: [Link] } diff --git a/Sources/AppStoreReviewsAPI/Models/Rights/Rights.swift b/Sources/AppStoreReviewsAPI/Models/Rights/Rights.swift index a690e60..b50a989 100644 --- a/Sources/AppStoreReviewsAPI/Models/Rights/Rights.swift +++ b/Sources/AppStoreReviewsAPI/Models/Rights/Rights.swift @@ -7,7 +7,7 @@ import Foundation -struct Rights: Decodable { +public struct Rights: Decodable { - let label: String + public let label: String } diff --git a/Sources/AppStoreReviewsAPI/Models/Title/Title.swift b/Sources/AppStoreReviewsAPI/Models/Title/Title.swift index d25a5f4..7e62bdb 100644 --- a/Sources/AppStoreReviewsAPI/Models/Title/Title.swift +++ b/Sources/AppStoreReviewsAPI/Models/Title/Title.swift @@ -7,7 +7,7 @@ import Foundation -struct Title: Decodable { +public struct Title: Decodable { - let label: String + public let label: String } diff --git a/Sources/AppStoreReviewsAPI/Models/Updated/Updated.swift b/Sources/AppStoreReviewsAPI/Models/Updated/Updated.swift index e75ab4e..3c2749e 100644 --- a/Sources/AppStoreReviewsAPI/Models/Updated/Updated.swift +++ b/Sources/AppStoreReviewsAPI/Models/Updated/Updated.swift @@ -7,7 +7,7 @@ import Foundation -struct Updated: Decodable { +public struct Updated: Decodable { - let label: Date + public let label: Date }