Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 8 additions & 16 deletions WordPressKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@
46ABD0EA262EEE0400C7FF24 /* AppTransportSecuritySettingsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46ABD0E9262EEE0400C7FF24 /* AppTransportSecuritySettingsTests.swift */; };
4A1DEF44293051BC00322608 /* LoggingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A1DEF43293051BC00322608 /* LoggingTests.swift */; };
4A1DEF46293051C600322608 /* LoggingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A1DEF45293051C600322608 /* LoggingTests.m */; };
4A68E3CD29404181004AC3DC /* RemoteBlog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A68E3CC29404181004AC3DC /* RemoteBlog.swift */; };
4A68E3CF29404289004AC3DC /* RemoteBlogOptionsHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A68E3CE29404289004AC3DC /* RemoteBlogOptionsHelper.swift */; };
4A68E3D329406AA0004AC3DC /* RemoteMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A68E3D029406AA0004AC3DC /* RemoteMenu.swift */; };
4A68E3D429406AA0004AC3DC /* RemoteMenuItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A68E3D129406AA0004AC3DC /* RemoteMenuItem.swift */; };
4A68E3D529406AA0004AC3DC /* RemoteMenuLocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A68E3D229406AA0004AC3DC /* RemoteMenuLocation.swift */; };
Expand Down Expand Up @@ -434,10 +436,6 @@
93BD27811EE73944002BB00B /* WordPressOrgXMLRPCApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93BD27791EE73944002BB00B /* WordPressOrgXMLRPCApi.swift */; };
93BD27821EE73944002BB00B /* WordPressOrgXMLRPCValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93BD277A1EE73944002BB00B /* WordPressOrgXMLRPCValidator.swift */; };
93BD27831EE73944002BB00B /* WordPressRSDParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93BD277B1EE73944002BB00B /* WordPressRSDParser.swift */; };
93C674E71EE8345300BFAF05 /* RemoteBlog.h in Headers */ = {isa = PBXBuildFile; fileRef = 93C674E51EE8345300BFAF05 /* RemoteBlog.h */; settings = {ATTRIBUTES = (Public, ); }; };
93C674E81EE8345300BFAF05 /* RemoteBlog.m in Sources */ = {isa = PBXBuildFile; fileRef = 93C674E61EE8345300BFAF05 /* RemoteBlog.m */; };
93C674EB1EE8348F00BFAF05 /* RemoteBlogOptionsHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 93C674E91EE8348F00BFAF05 /* RemoteBlogOptionsHelper.h */; settings = {ATTRIBUTES = (Public, ); }; };
93C674EC1EE8348F00BFAF05 /* RemoteBlogOptionsHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 93C674EA1EE8348F00BFAF05 /* RemoteBlogOptionsHelper.m */; };
93C674EE1EE834B700BFAF05 /* RemoteBlogSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93C674ED1EE834B700BFAF05 /* RemoteBlogSettings.swift */; };
93C674F11EE8351E00BFAF05 /* NSMutableDictionary+Helpers.h in Headers */ = {isa = PBXBuildFile; fileRef = 93C674EF1EE8351E00BFAF05 /* NSMutableDictionary+Helpers.h */; };
93C674F21EE8351E00BFAF05 /* NSMutableDictionary+Helpers.m in Sources */ = {isa = PBXBuildFile; fileRef = 93C674F01EE8351E00BFAF05 /* NSMutableDictionary+Helpers.m */; };
Expand Down Expand Up @@ -783,6 +781,8 @@
46ABD0E9262EEE0400C7FF24 /* AppTransportSecuritySettingsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppTransportSecuritySettingsTests.swift; sourceTree = "<group>"; };
4A1DEF43293051BC00322608 /* LoggingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggingTests.swift; sourceTree = "<group>"; };
4A1DEF45293051C600322608 /* LoggingTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoggingTests.m; sourceTree = "<group>"; };
4A68E3CC29404181004AC3DC /* RemoteBlog.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoteBlog.swift; sourceTree = "<group>"; };
4A68E3CE29404289004AC3DC /* RemoteBlogOptionsHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoteBlogOptionsHelper.swift; sourceTree = "<group>"; };
4A68E3D029406AA0004AC3DC /* RemoteMenu.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoteMenu.swift; sourceTree = "<group>"; };
4A68E3D129406AA0004AC3DC /* RemoteMenuItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoteMenuItem.swift; sourceTree = "<group>"; };
4A68E3D229406AA0004AC3DC /* RemoteMenuLocation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoteMenuLocation.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1099,10 +1099,6 @@
93BD27791EE73944002BB00B /* WordPressOrgXMLRPCApi.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WordPressOrgXMLRPCApi.swift; sourceTree = "<group>"; };
93BD277A1EE73944002BB00B /* WordPressOrgXMLRPCValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WordPressOrgXMLRPCValidator.swift; sourceTree = "<group>"; };
93BD277B1EE73944002BB00B /* WordPressRSDParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WordPressRSDParser.swift; sourceTree = "<group>"; };
93C674E51EE8345300BFAF05 /* RemoteBlog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteBlog.h; sourceTree = "<group>"; };
93C674E61EE8345300BFAF05 /* RemoteBlog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RemoteBlog.m; sourceTree = "<group>"; };
93C674E91EE8348F00BFAF05 /* RemoteBlogOptionsHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteBlogOptionsHelper.h; sourceTree = "<group>"; };
93C674EA1EE8348F00BFAF05 /* RemoteBlogOptionsHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RemoteBlogOptionsHelper.m; sourceTree = "<group>"; };
93C674ED1EE834B700BFAF05 /* RemoteBlogSettings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoteBlogSettings.swift; sourceTree = "<group>"; };
93C674EF1EE8351E00BFAF05 /* NSMutableDictionary+Helpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableDictionary+Helpers.h"; sourceTree = "<group>"; };
93C674F01EE8351E00BFAF05 /* NSMutableDictionary+Helpers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMutableDictionary+Helpers.m"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1924,13 +1920,11 @@
826016F21F9FA17B00533B6C /* Activity.swift */,
436D56342118D85800CEAA33 /* WPCountry.swift */,
436D5640211B7F4400CEAA33 /* DomainContactInformation.swift */,
93C674E51EE8345300BFAF05 /* RemoteBlog.h */,
93C674E61EE8345300BFAF05 /* RemoteBlog.m */,
4A68E3CC29404181004AC3DC /* RemoteBlog.swift */,
82FFBF511F45F04100F4573F /* RemoteBlogJetpackMonitorSettings.swift */,
8236EB4C2024B9F8007C7CF9 /* RemoteBlogJetpackModulesSettings.swift */,
82FFBF4F1F45EFD100F4573F /* RemoteBlogJetpackSettings.swift */,
93C674E91EE8348F00BFAF05 /* RemoteBlogOptionsHelper.h */,
93C674EA1EE8348F00BFAF05 /* RemoteBlogOptionsHelper.m */,
4A68E3CE29404289004AC3DC /* RemoteBlogOptionsHelper.swift */,
74585B961F0D54B400E7E667 /* RemoteDomain.swift */,
93C674ED1EE834B700BFAF05 /* RemoteBlogSettings.swift */,
74BA04F71F06DC3900ED5CD8 /* RemoteComment.h */,
Expand Down Expand Up @@ -2540,7 +2534,6 @@
74DA56371F06EB0500FE9BF4 /* MediaServiceRemote.h in Headers */,
74DA56321F06EAF000FE9BF4 /* MediaServiceRemoteREST.h in Headers */,
74DA563A1F06EB3000FE9BF4 /* RemoteMedia.h in Headers */,
93C674E71EE8345300BFAF05 /* RemoteBlog.h in Headers */,
74BA04F91F06DC3900ED5CD8 /* RemoteComment.h in Headers */,
74BA04F21F06DC0A00ED5CD8 /* CommentServiceRemote.h in Headers */,
74BA04F51F06DC0A00ED5CD8 /* CommentServiceRemoteXMLRPC.h in Headers */,
Expand Down Expand Up @@ -2574,7 +2567,6 @@
9309995B1F16616A00F006A1 /* RemoteTheme.h in Headers */,
1A4F98672279A87D00D86E8E /* WPKit-Swift.h in Headers */,
93F50A371F226B9300B5BEBA /* WordPressComServiceRemote.h in Headers */,
93C674EB1EE8348F00BFAF05 /* RemoteBlogOptionsHelper.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -3135,12 +3127,10 @@
7E3E7A4C20E443AA0075D159 /* NSMutableParagraphStyle+extensions.swift in Sources */,
40F98809221AC88700B7B369 /* StatsPostingStreakInsight.swift in Sources */,
465F889E263B0C5500F4C950 /* BlockEditorSettingsServiceRemote.swift in Sources */,
93C674EC1EE8348F00BFAF05 /* RemoteBlogOptionsHelper.m in Sources */,
E632D7781F6E047400297F6D /* SocialLogin2FANonceInfo.swift in Sources */,
32FC1D29255C91ED00CD0A7B /* JetpackScanServiceRemote.swift in Sources */,
9F3E0B9B208732B3009CB5BA /* RemoteReaderSiteInfoSubscription.swift in Sources */,
7403A2E41EF06ED500DED7DC /* AccountSettingsRemote.swift in Sources */,
93C674E81EE8345300BFAF05 /* RemoteBlog.m in Sources */,
3236F77824AE34B40088E8F3 /* ReaderTopicServiceRemote+Interests.swift in Sources */,
FE20A6A4282A96C00025E975 /* RemoteBloggingPromptsSettings.swift in Sources */,
93BD27831EE73944002BB00B /* WordPressRSDParser.swift in Sources */,
Expand Down Expand Up @@ -3197,6 +3187,7 @@
E1D6B558200E473A00325669 /* TimeZoneServiceRemote.swift in Sources */,
1769DEAA24729AFF00F42EFC /* HomepageSettingsServiceRemote.swift in Sources */,
93BD273D1EE73282002BB00B /* AccountServiceRemoteREST.m in Sources */,
4A68E3CF29404289004AC3DC /* RemoteBlogOptionsHelper.swift in Sources */,
82FFBF501F45EFD100F4573F /* RemoteBlogJetpackSettings.swift in Sources */,
74650F741F0EA1E200188EDB /* RemoteGravatarProfile.swift in Sources */,
40E7FEB4221063480032834E /* StatsTodayInsight.swift in Sources */,
Expand Down Expand Up @@ -3228,6 +3219,7 @@
74E2295B1F1E77290085F7F2 /* KeyringConnection.swift in Sources */,
74B5F0DA1EF8299B00B411E7 /* BlogServiceRemoteXMLRPC.m in Sources */,
E1EF5D5D1F9F329900B6D53E /* SitePluginCapabilities.swift in Sources */,
4A68E3CD29404181004AC3DC /* RemoteBlog.swift in Sources */,
7E3E7A4520E443060075D159 /* NSAttributedString+extensions.swift in Sources */,
40E7FEAE220FAEA10032834E /* StatsPublicizeInsight.swift in Sources */,
93F50A411F227C9700B5BEBA /* RemoteProfile.swift in Sources */,
Expand Down
2 changes: 0 additions & 2 deletions WordPressKit/AccountServiceRemoteREST.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#import "AccountServiceRemoteREST.h"
#import "RemoteBlog.h"
#import "RemoteBlogOptionsHelper.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Chasing down these two imports, I noticed their footprint is minimal in this implementation. As far as I could see, only this method:

- (NSArray *)remoteBlogsFromJSONArray:(NSArray *)jsonBlogs
{
NSArray *blogs = jsonBlogs;
return [blogs wp_map:^id(NSDictionary *jsonBlog) {
return [[RemoteBlog alloc] initWithJSONDictionary:jsonBlog];
}];
return blogs;
}

Might it be useful to re-write it in Swift in the context of this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I intentionally started with the easy ones to translate. This AccountServiceRemoteREST falls into my harder basket, and will be dealt with after I have finished with the easy ones 🥲

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure.

Just to be clear, I was suggesting converting only that method, but I can see how adding a dedicated extension just for it would be wasteful given we'd remove it once the whole class is converted soon enough.

#import "WPKit-Swift.h"
@import NSObject_SafeExpectations;
@import WordPressShared;
Expand Down
102 changes: 0 additions & 102 deletions WordPressKit/RemoteBlog.h

This file was deleted.

48 changes: 0 additions & 48 deletions WordPressKit/RemoteBlog.m

This file was deleted.

79 changes: 79 additions & 0 deletions WordPressKit/RemoteBlog.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import Foundation
import NSObject_SafeExpectations

/// This class encapsulates all of the *remote* Blog properties
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know what a remote blog is? And what's the difference with a "non-remote (?)" blog?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think "remote" indicates it's an HTTP API model, which is defined by the WordPress API schema (hence the "remote" name?). A "non-remote" blog (or just Blog) means it's a custom model type defined by the app, which may have a different structure than the "remote" one.

@objcMembers public class RemoteBlog: NSObject {

/// The ID of the Blog entity.
public var blogID: NSNumber?

/// The organization ID of the Blog entity.
public var organizationID: NSNumber?

/// Represents the Blog Name.
public var name: String?

/// Description of the WordPress Blog.
public var tagline: String?

/// Represents the Blog Name.
public var url: String?

/// Maps to the XMLRPC endpoint.
public var xmlrpc: String?

/// Site Icon's URL.
public var icon: String?

/// Product ID of the site's current plan, if it has one.
public var planID: NSNumber?

/// Product name of the site's current plan, if it has one.
public var planTitle: String?

/// Indicates whether the current's blog plan is paid, or not.
public var hasPaidPlan: Bool = false

/// Indicates whether it's a jetpack site, or not.
public var jetpack: Bool = false

/// Boolean indicating whether the current user has Admin privileges, or not.
public var isAdmin: Bool = false

/// Blog's visibility preferences.
public var visible: Bool = false

/// Blog's options preferences.
public var options: NSDictionary?

/// Blog's capabilities: Indicate which actions are allowed / not allowed, for the current user.
public var capabilities: NSDictionary?

/// Blog's total disk quota space.
public var quotaSpaceAllowed: NSNumber?

/// Blog's total disk quota space used.
public var quotaSpaceUsed: NSNumber?

/// Parses details from a JSON dictionary, as returned by the WordPress.com REST API.
public init(JSONDictionary json: NSDictionary) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm sure you thought of this, too, but at some point it'd be good to make this and the other types currently using JSONDictionary Decodable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed. Once I've finished the Swift translation, I'll have a look at the NSDictionary usage across all the models. I'll probably start with specializing the argument type first, to be [String: Any] for example. I'm not sure about Decodable, as it's a more drastic change to the JSON parsing code. But I'll for sure considering adopting Decodable when I get to it. 👍

self.blogID = json.number(forKey: "ID")
self.organizationID = json.number(forKey: "organization_id")
self.name = json.string(forKey: "name")
self.tagline = json.string(forKey: "description")
self.url = json.string(forKey: "URL")
self.xmlrpc = json.string(forKeyPath: "meta.links.xmlrpc")
self.jetpack = json.number(forKey: "jetpack")?.boolValue ?? false
self.icon = json.string(forKeyPath: "icon.img")
self.capabilities = json.object(forKey: "capabilities") as? NSDictionary
self.isAdmin = json.number(forKeyPath: "capabilities.manage_options")?.boolValue ?? false
self.visible = json.number(forKey: "visible")?.boolValue ?? false
self.options = RemoteBlogOptionsHelper.mapOptions(fromResponse: json)
self.planID = json.number(forKeyPath: "plan.product_id")
self.planTitle = json.string(forKeyPath: "plan.product_name_short")
self.hasPaidPlan = json.number(forKeyPath: "plan.is_free")?.boolValue ?? false
self.quotaSpaceAllowed = json.number(forKeyPath: "quota.space_allowed")
self.quotaSpaceUsed = json.number(forKeyPath: "quota.space_used")
}

}
15 changes: 0 additions & 15 deletions WordPressKit/RemoteBlogOptionsHelper.h

This file was deleted.

Loading