Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Commit

Permalink
Rename Publishers
Browse files Browse the repository at this point in the history
  • Loading branch information
otaviocc committed Apr 18, 2021
1 parent 29a49ab commit 1aa061d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Using the wrapper is straight-forward:
var cancellables = Set<AnyCancellable>()

apiClient
.recents() // <- Publisher
.recentsPublisher() // <- Publisher
.sink(
receiveCompletion: { _ in },
receiveValue: { print($0) }
Expand All @@ -28,7 +28,7 @@ apiClient
public protocol PostsAPI {

/// Add a bookmark.
func add(
func addPublisher(
url: URL,
description: String,
extended: String?,
Expand All @@ -40,31 +40,31 @@ public protocol PostsAPI {
) -> AnyPublisher<GenericResponse, Error>

/// Delete a bookmark.
func delete(
func deletePublisher(
url: URL
) -> AnyPublisher<GenericResponse, Error>

/// Returns one or more posts on a single day matching the arguments.
func get(
func getPublisher(
tag: String?,
dt: Date?,
url: URL?,
meta: String?
) -> AnyPublisher<RecentResponse, Error>

/// Returns a list of dates with the number of posts at each date.
func dates(
func datesPublisher(
tag: String?
) -> AnyPublisher<DatesResponse, Error>

/// Returns a list of the user's most recent posts, filtered by tag.
func recents(
func recentsPublisher(
tag: String?,
count: Int?
) -> AnyPublisher<RecentResponse, Error>

/// Returns all bookmarks in the user's account.
func all(
func allPublisher(
tag: String?,
start: Int?,
results: Int?,
Expand All @@ -74,7 +74,7 @@ public protocol PostsAPI {
) -> AnyPublisher<RecentResponse, Error>

/// Returns a list of popular tags and recommended tags for a given URL.
func suggest(
func suggestPublisher(
url: URL
) -> AnyPublisher<SuggestResponse, Error>
}
Expand All @@ -85,16 +85,16 @@ public protocol TagsAPI {

/// Returns a full list of the user's tags along with the number of
/// times they were used.
func get(
func getPublisher(
) -> AnyPublisher<TagsGetResponse, Error>

/// Delete an existing tag.
func delete(
func deletePublisher(
tag: String
) -> AnyPublisher<GenericResponse, Error>

/// Rename a tag, or fold it in to an existing tag.
func rename(
func renamePublisher(
old: String,
new: String
) -> AnyPublisher<GenericResponse, Error>
Expand All @@ -107,7 +107,7 @@ public protocol UpdateAPI {
/// Returns the most recent time a bookmark was added, updated or deleted.
/// Use this before calling posts/all to see if the data has changed since
/// the last fetch.
func update(
func updatePublisher(
) -> AnyPublisher<UpdateResponse, Error>
}
```
28 changes: 14 additions & 14 deletions Sources/PinboardKit/API/PostsAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Combine
public protocol PostsAPI {

/// Add a bookmark.
func add(
func addPublisher(
url: URL,
description: String,
extended: String?,
Expand All @@ -16,31 +16,31 @@ public protocol PostsAPI {
) -> AnyPublisher<GenericResponse, Error>

/// Delete a bookmark.
func delete(
func deletePublisher(
url: URL
) -> AnyPublisher<GenericResponse, Error>

/// Returns one or more posts on a single day matching the arguments.
func get(
func getPublisher(
tag: String?,
date: Date?,
url: URL?,
meta: String?
) -> AnyPublisher<RecentResponse, Error>

/// Returns a list of dates with the number of posts at each date.
func dates(
func datesPublisher(
tag: String?
) -> AnyPublisher<DatesResponse, Error>

/// Returns a list of the user's most recent posts, filtered by tag.
func recents(
func recentsPublisher(
tag: String?,
count: Int?
) -> AnyPublisher<RecentResponse, Error>

/// Returns all bookmarks in the user's account.
func all(
func allPublisher(
tag: String?,
start: Int?,
results: Int?,
Expand All @@ -50,7 +50,7 @@ public protocol PostsAPI {
) -> AnyPublisher<[PostResponse], Error>

/// Returns a list of popular tags and recommended tags for a given URL.
func suggest(
func suggestPublisher(
url: URL
) -> AnyPublisher<SuggestResponse, Error>
}
Expand All @@ -59,7 +59,7 @@ extension PinboardAPI: PostsAPI {

// MARK: - Public

public func add(
public func addPublisher(
url: URL,
description: String,
extended: String? = nil,
Expand All @@ -86,7 +86,7 @@ extension PinboardAPI: PostsAPI {
.eraseToAnyPublisher()
}

public func delete(
public func deletePublisher(
url: URL
) -> AnyPublisher<GenericResponse, Error> {
networkClient
Expand All @@ -95,7 +95,7 @@ extension PinboardAPI: PostsAPI {
.eraseToAnyPublisher()
}

public func get(
public func getPublisher(
tag: String? = nil,
date: Date? = nil,
url: URL? = nil,
Expand All @@ -114,7 +114,7 @@ extension PinboardAPI: PostsAPI {
.eraseToAnyPublisher()
}

public func dates(
public func datesPublisher(
tag: String? = nil
) -> AnyPublisher<DatesResponse, Error> {
networkClient
Expand All @@ -123,7 +123,7 @@ extension PinboardAPI: PostsAPI {
.eraseToAnyPublisher()
}

public func recents(
public func recentsPublisher(
tag: String? = nil,
count: Int? = nil
) -> AnyPublisher<RecentResponse, Error> {
Expand All @@ -133,7 +133,7 @@ extension PinboardAPI: PostsAPI {
.eraseToAnyPublisher()
}

public func all(
public func allPublisher(
tag: String? = nil,
start: Int? = nil,
results: Int? = nil,
Expand All @@ -156,7 +156,7 @@ extension PinboardAPI: PostsAPI {
.eraseToAnyPublisher()
}

public func suggest(
public func suggestPublisher(
url: URL
) -> AnyPublisher<SuggestResponse, Error> {
networkClient
Expand Down
12 changes: 6 additions & 6 deletions Sources/PinboardKit/API/TagsAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ public protocol TagsAPI {

/// Returns a full list of the user's tags along with the number of
/// times they were used.
func get(
func getPublisher(
) -> AnyPublisher<TagsGetResponse, Error>

/// Delete an existing tag.
func delete(
func deletePublisher(
tag: String
) -> AnyPublisher<GenericResponse, Error>

/// Rename a tag, or fold it in to an existing tag.
func rename(
func renamePublisher(
old: String,
new: String
) -> AnyPublisher<GenericResponse, Error>
Expand All @@ -24,15 +24,15 @@ extension PinboardAPI: TagsAPI {

// MARK: - Public

public func get(
public func getPublisher(
) -> AnyPublisher<TagsGetResponse, Error> {
networkClient
.run(makeGetRequest())
.map(\.value)
.eraseToAnyPublisher()
}

public func delete(
public func deletePublisher(
tag: String
) -> AnyPublisher<GenericResponse, Error> {
networkClient
Expand All @@ -41,7 +41,7 @@ extension PinboardAPI: TagsAPI {
.eraseToAnyPublisher()
}

public func rename(
public func renamePublisher(
old: String,
new: String
) -> AnyPublisher<GenericResponse, Error> {
Expand Down
4 changes: 2 additions & 2 deletions Sources/PinboardKit/API/UpdateAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public protocol UpdateAPI {
/// Returns the most recent time a bookmark was added, updated or deleted.
/// Use this before calling posts/all to see if the data has changed since
/// the last fetch.
func update(
func updatePublisher(
) -> AnyPublisher<UpdateResponse, Error>
}

Expand All @@ -16,7 +16,7 @@ extension PinboardAPI: UpdateAPI {

// MARK: - Public

public func update(
public func updatePublisher(
) -> AnyPublisher<UpdateResponse, Error> {
networkClient
.run(makeUpdateRequest())
Expand Down

0 comments on commit 1aa061d

Please sign in to comment.