@@ -11,33 +11,54 @@ public actor WordPressAPI {
1111 case unableToParseResponse
1212 }
1313
14- private let internalExecutor : SafeRequestExecutor
14+ private let apiClientDelegate : WpApiClientDelegate
1515 package let requestBuilder : UniffiWpApiClient
1616
17- public init ( urlSession: URLSession , apiRootUrl: ParsedUrl , authenticationStategy: WpAuthentication ) {
17+ public init (
18+ urlSession: URLSession ,
19+ apiRootUrl: ParsedUrl ,
20+ authentication: WpAuthentication ,
21+ middlewarePipeline: MiddlewarePipeline = . default
22+ ) {
23+ self . init (
24+ apiRootUrl: apiRootUrl,
25+ authenticationProvider: . staticWithAuth( auth: authentication) ,
26+ executor: WpRequestExecutor ( urlSession: urlSession) ,
27+ middlewarePipeline: middlewarePipeline
28+ )
29+ }
30+
31+ public init (
32+ urlSession: URLSession ,
33+ apiRootUrl: ParsedUrl ,
34+ authenticationProvider: WpAuthenticationProvider ,
35+ middlewarePipeline: MiddlewarePipeline = . default,
36+ appNotifier: WpAppNotifier ? = nil
37+ ) {
1838 self . init (
1939 apiRootUrl: apiRootUrl,
20- authenticationStategy: authenticationStategy,
21- executor: WpRequestExecutor ( urlSession: urlSession)
40+ authenticationProvider: authenticationProvider,
41+ executor: WpRequestExecutor ( urlSession: urlSession) ,
42+ middlewarePipeline: middlewarePipeline
2243 )
2344 }
2445
2546 init (
2647 apiRootUrl: ParsedUrl ,
27- authenticationStategy : WpAuthentication ,
48+ authenticationProvider : WpAuthenticationProvider ,
2849 executor: SafeRequestExecutor ,
29- middlewarePipeline: MiddlewarePipeline = . default
50+ middlewarePipeline: MiddlewarePipeline ,
51+ appNotifier: WpAppNotifier ? = nil
3052 ) {
31- self . internalExecutor = executor
32-
53+ self . apiClientDelegate = WpApiClientDelegate (
54+ authProvider: authenticationProvider,
55+ requestExecutor: executor,
56+ middlewarePipeline: middlewarePipeline,
57+ appNotifier: appNotifier ?? EmptyAppNotifier ( )
58+ )
3359 self . requestBuilder = UniffiWpApiClient (
3460 apiRootUrl: apiRootUrl,
35- delegate: . init(
36- authProvider: . staticWithAuth( auth: authenticationStategy) ,
37- requestExecutor: executor,
38- middlewarePipeline: middlewarePipeline,
39- appNotifier: NoopAppNotifier ( )
40- )
61+ delegate: self . apiClientDelegate
4162 )
4263 }
4364
@@ -170,9 +191,3 @@ public extension ParsedUrl {
170191 try parse ( input: url. absoluteString)
171192 }
172193}
173-
174- class NoopAppNotifier : @unchecked Sendable , WpAppNotifier {
175- func requestedWithInvalidAuthentication( ) async {
176- // Do nothing.
177- }
178- }
0 commit comments