This repository was archived by the owner on Sep 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Remove PostServiceRemoteExtended
and implementations
#784
Draft
mokagio
wants to merge
18
commits into
trunk
Choose a base branch
from
mokagio/remove-PostServiceRemoteExtended
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
96ae82f
Remove an `enum` builder in favor of default associated value
mokagio d17587a
Remove `PostServiceRemoteExtended` and implementations
mokagio 58a6386
Update access control to components called by removed types
mokagio 19bbd29
Move `upload(...` definition before `perform(...`
mokagio 61dbb4e
Make a couple of properties used in `async` API `public`
mokagio 5571b03
Remove a stray double new line
mokagio be9635f
Move `processError` to an extension on `WordPressComRESTAPIInterfacing`
mokagio 61f6a44
Require `URLSession` in root `async` `perform` method
mokagio b03cc2d
Move `session` argument before `taskCreated`
mokagio a5edf0d
Require `invalidTokenHandler` in `perform`
mokagio 68e32b8
Move root `perform` definition to `WordPressComRESTAPIInterfacing`
mokagio 16f2af7
Extract logic to create builder with locale to extension
mokagio 63ac625
Add new `localeValue` property to `WordPressComRESTAPIInterfacing`
mokagio b09ee31
Move request builder to `WordPressComRESTAPIInterfacing` extension
mokagio 72c8f7b
Redefine `APIResult` typealias in the context of `WPComRESTAPIInterfa…
mokagio ed6a634
Move `urlSession` and `invalidTokenHandler` to API interface protocol
mokagio 55d8e8f
Move a couple more `perform` types to API protocol
mokagio f9a15a5
Remove a couple of unused variable assignments
mokagio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
Sources/WordPressKit/Services/PostServiceRemoteExtended.swift
This file was deleted.
Oops, something went wrong.
67 changes: 0 additions & 67 deletions
67
Sources/WordPressKit/Services/PostServiceRemoteREST+Extended.swift
This file was deleted.
Oops, something went wrong.
77 changes: 0 additions & 77 deletions
77
Sources/WordPressKit/Services/PostServiceRemoteXMLRPC+Extended.swift
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,14 +18,10 @@ public enum WordPressAPIError<EndpointError>: Error where EndpointError: Localiz | |
/// The API call returned an status code that's unacceptable to the endpoint. | ||
case unacceptableStatusCode(response: HTTPURLResponse, body: Data) | ||
/// The API call returned an HTTP response that WordPressKit can't parse. Receiving this error could be an indicator that there is an error response that's not handled properly by WordPressKit. | ||
case unparsableResponse(response: HTTPURLResponse?, body: Data?, underlyingError: Error) | ||
case unparsableResponse(response: HTTPURLResponse?, body: Data?, underlyingError: Error = URLError(.cannotParseResponse)) | ||
/// Other error occured. | ||
case unknown(underlyingError: Error) | ||
|
||
static func unparsableResponse(response: HTTPURLResponse?, body: Data?) -> Self { | ||
return WordPressAPIError<EndpointError>.unparsableResponse(response: response, body: body, underlyingError: URLError(.cannotParseResponse)) | ||
} | ||
Comment on lines
-21
to
-27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't look up when, but relatively recently, I think, Swift acquired default values for associated parameters. So we can remove this builder method in favor of defining the underlying error as a default for the case. |
||
|
||
var response: HTTPURLResponse? { | ||
switch self { | ||
case .requestEncodingFailure, .connection, .unknown: | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the type became
public
, apublic init
became necessary because the compiler does not synthesize one outside of the package.As for
encode(to:)
, it needs to bepublic
becauseEncodable
is declared as part of thepublic
type interface.🤔 In hindsight, I suppose the
Encodable
part could be moved into aninternal
extension, but I think it's okay to leave it as is. Let me know if you can think of a strong reason to hide it.