Skip to content

Commit

Permalink
Fix Linux compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jkmassel committed Nov 27, 2024
1 parent 1b446f5 commit 625914e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ extension CallbackAwarePerformer {
return
}

guard let httpResponse = response as? HTTPURLResponse, let data else {
guard let response, let data else {
completion(.failure(WordPressAPI.Errors.unableToParseResponse))
return
}

do {
let rawResponse = try WpNetworkResponse.from(data: data, response: httpResponse)
let rawResponse = try WpNetworkResponse.from(data: data, response: response)
let parsedResponse = try responseConverter(rawResponse)
completion(.success(parsedResponse))
} catch {
Expand All @@ -135,5 +135,4 @@ extension CallbackAwarePerformer where Self: NoDeletionParams {
try parseDeleteResponse(response: $0)
}, completion: callback)
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import Foundation
@preconcurrency import WordPressAPIInternal
import Combine

#if os(Linux)
import FoundationNetworking
#endif

public final class MediaRequestPerformer {
typealias ExecutorType = MediaRequestExecutor
Expand All @@ -19,9 +22,12 @@ public final class MediaRequestPerformer {
public struct MediaCreateParams {}
public struct MediaRequestCreateResponse {}

extension MediaRequestPerformer: PublisherAwarePerformer {}
extension MediaRequestPerformer: CallbackAwarePerformer {}

#if canImport(Combine)
extension MediaRequestPerformer: PublisherAwarePerformer {}
#endif

extension MediaRequestPerformer: RequestPerformer {
public func buildListWithEditRequest(params: MediaListParams) -> WpNetworkRequest {
builder.listWithEditContext(params: params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import Foundation
@preconcurrency import WordPressAPIInternal
#endif

#if os(Linux)
import FoundationNetworking
#endif

public final class PostTypeRequestPerformer {
typealias ExecutorType = PostTypesRequestExecutor
typealias RequestBuilderType = PostTypesRequestBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import Foundation
@preconcurrency import WordPressAPIInternal
#endif

#if os(Linux)
import FoundationNetworking
#endif

public final class PostsRequestPerformer {
typealias ExecutorType = PostsRequestExecutor
typealias RequestBuilderType = PostsRequestBuilder
Expand Down Expand Up @@ -98,7 +102,6 @@ extension PostsRequestPerformer: PaginationAwarePerformer {}
extension PostsRequestPerformer: SequenceAwarePerformer {}

#if canImport(Combine)
import Combine
extension PostsRequestPerformer: PublisherAwarePerformer {}
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import Foundation
@preconcurrency import WordPressAPIInternal
#endif

#if os(Linux)
import FoundationNetworking
#endif

public final class UsersRequestPerformer {
typealias ExecutorType = UsersRequestExecutor
typealias RequestBuilderType = UsersRequestBuilder
Expand All @@ -24,7 +28,6 @@ extension UsersRequestPerformer: PaginationAwarePerformer {}
extension UsersRequestPerformer: SequenceAwarePerformer {}

#if canImport(Combine)
import Combine
extension UsersRequestPerformer: PublisherAwarePerformer {}
#endif

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import Foundation

#if os(Linux)
import FoundationNetworking
#endif

public protocol RequestPerformer: Sendable {
associatedtype IdType

Expand Down

0 comments on commit 625914e

Please sign in to comment.