Skip to content

Commit

Permalink
Add ReaderStream enum
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Oct 18, 2024
1 parent 05af184 commit a5dfe35
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ let package = Package(
targets: [
.binaryTarget(
name: "WordPressKit",
url: "https://github.com/user-attachments/files/17435861/WordPressKit.zip",
checksum: "af7239442da8470a91ef5ab923fd91222bb3c0ea345b18f581bfafd63f0dd6b6"
url: "https://github.com/user-attachments/files/17435956/WordPressKit.zip",
checksum: "b3babe54d211d862e485ab3a742080dc9f2a5f04e2a6fa1d675545b0d00a795e"
),
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public enum ReaderSortingOption: String, CaseIterable {
}
}

public enum ReaderStream: String {
case discover = "discover"
case firstPosts = "first-posts"
}

extension ReaderPostServiceRemote {
/// Returns a collection of RemoteReaderCard using the tags API
/// a Reader Card can represent an item for the reader feed, such as
Expand Down Expand Up @@ -46,22 +51,22 @@ extension ReaderPostServiceRemote {
/// - Topics you may like
/// - Blogs you may like and so on
///
/// - Parameter stream: The name of the stream. By default, `discover`.
/// - Parameter stream: The name of the stream. By default, `.discover`.
/// - Parameter topics: an array of String representing the topics
/// - Parameter page: a String that represents a page handle
/// - Parameter sortingOption: a ReaderSortingOption that represents a sorting option
/// - Parameter count: the number of cards to fetch. Warning: This also changes the number of objects returned for recommended sites/tags.
/// - Parameter success: Called when the request succeeds and the data returned is valid
/// - Parameter failure: Called if the request fails for any reason, or the response data is invalid
public func fetchStreamCards(stream: String = "discover",
public func fetchStreamCards(stream: ReaderStream = .discover,
for topics: [String],
page: String? = nil,
sortingOption: ReaderSortingOption = .noSorting,
refreshCount: Int? = nil,
count: Int? = nil,
success: @escaping ([RemoteReaderCard], String?) -> Void,
failure: @escaping (Error) -> Void) {
let path = "read/streams/\(stream)"
let path = "read/streams/\(stream.rawValue)"
guard let requestUrl = cardsEndpoint(with: path,
topics: topics,
page: page,
Expand Down

0 comments on commit a5dfe35

Please sign in to comment.