Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Foundation
import WordPressAPIInternal

public actor WordPressApiCache {
public final class WordPressApiCache: Sendable {

private let cache: WpApiCache
public let cache: WpApiCache
private let delegate: any DatabaseDelegate

public struct Notifications {
Expand All @@ -24,12 +24,12 @@ public actor WordPressApiCache {
}

/// Creates a new in-memory cache
public init(delegate: DatabaseDelegate = ApiCacheDelegate()) throws {
public convenience init(delegate: DatabaseDelegate = ApiCacheDelegate()) throws {
try self.init(path: ":memory:", delegate: delegate)
}

/// Creates a new cache at the specified file system URL
public init(url: URL, delegate: DatabaseDelegate = ApiCacheDelegate()) throws {
public convenience init(url: URL, delegate: DatabaseDelegate = ApiCacheDelegate()) throws {
try self.init(path: url.absoluteString, delegate: delegate)
}

Expand Down
14 changes: 7 additions & 7 deletions native/swift/Sources/wordpress-api/WordPressAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import FoundationNetworking
import Combine
#endif

public actor WordPressAPI {
public final class WordPressAPI: Sendable {

enum Errors: Error {
case unableToParseResponse
}

private let apiUrlResolver: ApiUrlResolver
let requestExecutor: SafeRequestExecutor
private let apiClientDelegate: WpApiClientDelegate
public let apiClientDelegate: WpApiClientDelegate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for this change? I think I'd rather define whatever methods we need on WordPressAPI than allow others to reach into this objects implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to provide a convenient way to pass the delegate instance to WpSelfHostedService. I have reverted this change. There are other ways, though less convenient.

package let requestBuilder: UniffiWpApiClient

public init(
public convenience init(
urlSession: URLSession,
apiRootUrl: ParsedUrl,
authentication: WpAuthentication,
Expand All @@ -36,7 +36,7 @@ public actor WordPressAPI {
)
}

public init(
public convenience init(
urlSession: URLSession,
apiRootUrl: ParsedUrl,
authenticationProvider: WpAuthenticationProvider,
Expand All @@ -52,7 +52,7 @@ public actor WordPressAPI {
)
}

public init(
public convenience init(
urlSession: URLSession,
apiUrlResolver: ApiUrlResolver,
authenticationProvider: WpAuthenticationProvider,
Expand All @@ -68,7 +68,7 @@ public actor WordPressAPI {
)
}

public init(
public convenience init(
urlSession: URLSession,
siteUrl: String,
apiRootUrl: ParsedUrl,
Expand All @@ -93,7 +93,7 @@ public actor WordPressAPI {
)
}

public init(
public convenience init(
urlSession: URLSession,
details: AutoDiscoveryAttemptSuccess,
username: String,
Expand Down