Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressKitObjC

public class AccountSettingsRemote: ServiceRemoteWordPressComREST {
@objc public static let remotes = NSMapTable<AnyObject, AnyObject>(keyOptions: NSPointerFunctions.Options(), valueOptions: NSPointerFunctions.Options.weakMemory)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressKitModels

public struct Activity: Decodable {

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

open class ActivityServiceRemote: ServiceRemoteWordPressComREST {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import Foundation
import WordPressKitObjC

@objc public class ActivityServiceRemote_ApiVersion1_0: ServiceRemoteWordPressComREST {

public enum ResponseError: Error {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressKitObjC

/// Retrieves feature announcements from the related endpoint
open class AnnouncementServiceRemote: ServiceRemoteWordPressComREST {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressKitObjC

public class AtomicAuthenticationServiceRemote: ServiceRemoteWordPressComREST {

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

public final class AtomicSiteServiceRemote: ServiceRemoteWordPressComREST {
/// - parameter scrollID: Pass the scroll ID from the previous response to
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressKitObjC

/// Class encapsualting all requests related to performing Automated Transfer operations.
public class AutomatedTransferService: ServiceRemoteWordPressComREST {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressKitObjC

open class BlazeServiceRemote: ServiceRemoteWordPressComREST {

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

public class BlogJetpackSettingsServiceRemote: ServiceRemoteWordPressComREST {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import Foundation
import WordPressKitObjC

/// Encapsulates logic to fetch blogging prompts from the remote endpoint.
///
open class BloggingPromptsServiceRemote: ServiceRemoteWordPressComREST {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
public extension CommentServiceRemoteREST {
/// Lists the available keys for the request parameter.
enum RequestKeys: String {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressKitObjC

open class DashboardServiceRemote: ServiceRemoteWordPressComREST {
open func fetch(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
struct JSONCodingKeys: CodingKey {
var stringValue: String

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

/// Allows the construction of a request for domain suggestions.
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressKitObjC

public class EditorServiceRemote: ServiceRemoteWordPressComREST {
public func postDesignateMobileEditor(_ siteID: Int, editor: EditorSettings.Mobile, success: @escaping (EditorSettings) -> Void, failure: @escaping (Error) -> Void) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
private struct RemoteEditorSettings: Codable {
let editorMobile: String
let editorWeb: String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
/// Allows automatic defaulting to `unknown` for any Enum that conforms to `UnknownCaseRepresentable`
/// Credits: https://www.latenightswift.com/2019/02/04/unknown-enum-cases/
protocol UnknownCaseRepresentable: RawRepresentable, CaseIterable where RawValue: Equatable {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import Foundation
import UIKit
import WordPressKitObjC

open class FeatureFlagRemote: ServiceRemoteWordPressComREST {

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

/// A builder type that appends HTTP request data to a URL.
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressKitObjC

public class HomepageSettingsServiceRemote: ServiceRemoteWordPressComREST {

Expand Down
24 changes: 0 additions & 24 deletions Sources/WordPressKit/Info.plist

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressKitObjC

open class JetpackBackupServiceRemote: ServiceRemoteWordPressComREST {

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

/// A service that returns the Jetpack Capabilities for a set of blogs
open class JetpackCapabilitiesServiceRemote: ServiceRemoteWordPressComREST {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
public class JetpackPluginManagementClient: PluginManagementClient {
private let siteID: Int
private let remote: PluginServiceRemote
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import Foundation
import WordPressKitObjC

/// Encapsulates Jetpack Proxy requests.
public class JetpackProxyServiceRemote: ServiceRemoteWordPressComREST {

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

public class JetpackScanServiceRemote: ServiceRemoteWordPressComREST {
// MARK: - Scanning
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressKitObjC

public struct JetpackInstallError: LocalizedError, Equatable {
public enum ErrorType: String {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import Foundation
import WordPressKitObjC

/// Encapsulates remote service logic related to Jetpack Social.
public class JetpackSocialServiceRemote: ServiceRemoteWordPressComREST {

Expand Down
15 changes: 0 additions & 15 deletions Sources/WordPressKit/Models/RemoteUser.h

This file was deleted.

5 changes: 0 additions & 5 deletions Sources/WordPressKit/Models/RemoteUser.m

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressKitObjC

/// The purpose of this class is to encapsulate all of the interaction with the Notifications REST endpoints.
/// Here we'll deal mostly with the Settings / Push Notifications API.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressKitObjC

// MARK: - NotificationSyncServiceRemote
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressKitObjC

/// Encapsulates all of the People Management WordPress.com Methods
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressKitObjC

open class PlanServiceRemote: ServiceRemoteWordPressComREST {
public typealias AvailablePlans = (plans: [RemoteWpcomPlan], groups: [RemotePlanGroup], features: [RemotePlanFeature])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressKitObjC

@objc public class PlanServiceRemote_ApiVersion1_3: ServiceRemoteWordPressComREST {

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

public class PluginServiceRemote: ServiceRemoteWordPressComREST {
public enum ResponseError: Error {
Expand Down
56 changes: 56 additions & 0 deletions Sources/WordPressKit/PostServiceRemoteREST.swift

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I need to translate this function to Swift, because it's used in a Swift module. I'll explain a little bit more of why this is needed in the upcoming app PR (which would provide a full context).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks good. We'll just need to make sure we test the features that needed rewrite.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import WordPressKitObjC
import NSObject_SafeExpectations

extension PostServiceRemoteREST {

/// Requests a list of users that liked the post with the specified ID.
///
/// Due to the API limitation, up to 90 users will be returned from the endpoint.
///
/// - Parameters:
/// - postID: The ID for the post. Cannot be nil.
/// - count: Number of records to retrieve. Cannot be nil. If 0, will default to endpoint max.
/// - before: Filter results to Likes before this date/time string. Can be nil.
/// - excludeUserIDs: Array of user IDs to exclude from response. Can be nil.
/// - success: The block that will be executed on success. Can be nil.
/// - failure: The block that will be executed on failure. Can be nil.
@objc(getLikesForPostID:count:before:excludeUserIDs:success:failure:)
public func getLikesForPostID(
_ postID: NSNumber,
count: NSNumber,
before: String?,
excludeUserIDs: [NSNumber]?,
success: (([RemoteLikeUser], NSNumber) -> Void)?,
failure: ((Error?) -> Void)?
) {
let path = "sites/\(siteID)/posts/\(postID)/likes"
let requestUrl = self.path(forEndpoint: path, withVersion: ._1_2)
let siteID = self.siteID

// If no count provided, default to endpoint max.
var parameters: [String: Any] = ["number": count == 0 ? 90 : count]

if let before {
parameters["before"] = before
}

if let excludeUserIDs {
parameters["exclude"] = excludeUserIDs
}

wordPressComRestAPI.get(requestUrl,
parameters: parameters,
success: { (responseObject, httpResponse) in
if let success {
let responseDict = responseObject as? [String: Any] ?? [:]
let jsonUsers = responseDict["likes"] as? [[String: Any]] ?? []
let users = jsonUsers.map { RemoteLikeUser(dictionary: $0, postID: postID, siteID: siteID) }
let found = responseDict["found"] as? NSNumber ?? 0
success(users, found)
}
}, failure: { (error, _) in
failure?(error)
})
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation
@_implementationOnly import wpxmlrpc
import wpxmlrpc
import WordPressKitObjC

extension PostServiceRemoteXMLRPC: PostServiceRemoteExtended {
public func post(withID postID: Int) async throws -> RemotePost {
Expand Down
8 changes: 0 additions & 8 deletions Sources/WordPressKit/Private/WPKit-Swift.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressKitObjC

/// Provides information about available products for user purchases, such as plans, domains, etc.
///
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressKitObjC

/// The purpose of this class is to encapsulate all of the interaction with the REST endpoint,
/// required to handle WordPress.com 2FA Code Veritication via Push Notifications
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import WordPressKitObjC

open class QRLoginServiceRemote: ServiceRemoteWordPressComREST {
/// Validates the incoming QR Login token and retrieves the requesting browser, and location
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
public enum ReaderSortingOption: String, CaseIterable {
case popularity
case date
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Foundation

extension ReaderPostServiceRemote {
/// Returns a collection of RemoteReaderPost
/// This method returns the best available content for the given topics.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Foundation

public struct RemoteBloggingPrompt {
public var promptID: Int
public var text: String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
public struct RemoteBloggingPromptsSettings: Codable {
public var promptCardEnabled: Bool
public var promptRemindersEnabled: Bool
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
/// Captures the JSON structure for Comments returned from API v2 endpoint.
public struct RemoteCommentV2 {
public var commentID: Int
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
/// Defines the information structure used for recommending the app to others.
///
public struct RemoteShareAppContent: Codable {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
public extension Swift.Result {

// Notice there are no explicit unit tests for this utility because it is implicitly tested via the consuming code's tests.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
public class SelfHostedPluginManagementClient: PluginManagementClient {
private let remote: WordPressOrgRestApi

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
public struct SessionDetails {
let deviceId: String
let platform: String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Foundation
/// Encapsulates logic for fetching content to be shared by the user.
///
open class ShareAppContentServiceRemote: ServiceRemoteWordPressComREST {
Expand Down
Loading