Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 8ecfcca

Browse files
committed
Re-implement RemoteBlog and RemoteBlogOptionsHelper in Swift
1 parent a568311 commit 8ecfcca

File tree

10 files changed

+164
-263
lines changed

10 files changed

+164
-263
lines changed

WordPressKit.xcodeproj/project.pbxproj

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@
124124
46ABD0EA262EEE0400C7FF24 /* AppTransportSecuritySettingsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46ABD0E9262EEE0400C7FF24 /* AppTransportSecuritySettingsTests.swift */; };
125125
4A1DEF44293051BC00322608 /* LoggingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A1DEF43293051BC00322608 /* LoggingTests.swift */; };
126126
4A1DEF46293051C600322608 /* LoggingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A1DEF45293051C600322608 /* LoggingTests.m */; };
127+
4A68E3CD29404181004AC3DC /* RemoteBlog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A68E3CC29404181004AC3DC /* RemoteBlog.swift */; };
128+
4A68E3CF29404289004AC3DC /* RemoteBlogOptionsHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A68E3CE29404289004AC3DC /* RemoteBlogOptionsHelper.swift */; };
127129
57BCD3D426209D9500292CB3 /* AppTransportSecuritySettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57BCD3D326209D9500292CB3 /* AppTransportSecuritySettings.swift */; };
128130
730E869F21E44EFD00753E1A /* WordPressComServiceRemote+SiteVerticals.swift in Sources */ = {isa = PBXBuildFile; fileRef = 730E869E21E44EFD00753E1A /* WordPressComServiceRemote+SiteVerticals.swift */; };
129131
731BA83621DECD61000FDFCD /* SiteCreationRequestEncodingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 731BA83521DECD61000FDFCD /* SiteCreationRequestEncodingTests.swift */; };
@@ -437,10 +439,6 @@
437439
93BD27811EE73944002BB00B /* WordPressOrgXMLRPCApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93BD27791EE73944002BB00B /* WordPressOrgXMLRPCApi.swift */; };
438440
93BD27821EE73944002BB00B /* WordPressOrgXMLRPCValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93BD277A1EE73944002BB00B /* WordPressOrgXMLRPCValidator.swift */; };
439441
93BD27831EE73944002BB00B /* WordPressRSDParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93BD277B1EE73944002BB00B /* WordPressRSDParser.swift */; };
440-
93C674E71EE8345300BFAF05 /* RemoteBlog.h in Headers */ = {isa = PBXBuildFile; fileRef = 93C674E51EE8345300BFAF05 /* RemoteBlog.h */; settings = {ATTRIBUTES = (Public, ); }; };
441-
93C674E81EE8345300BFAF05 /* RemoteBlog.m in Sources */ = {isa = PBXBuildFile; fileRef = 93C674E61EE8345300BFAF05 /* RemoteBlog.m */; };
442-
93C674EB1EE8348F00BFAF05 /* RemoteBlogOptionsHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 93C674E91EE8348F00BFAF05 /* RemoteBlogOptionsHelper.h */; settings = {ATTRIBUTES = (Public, ); }; };
443-
93C674EC1EE8348F00BFAF05 /* RemoteBlogOptionsHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 93C674EA1EE8348F00BFAF05 /* RemoteBlogOptionsHelper.m */; };
444442
93C674EE1EE834B700BFAF05 /* RemoteBlogSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93C674ED1EE834B700BFAF05 /* RemoteBlogSettings.swift */; };
445443
93C674F11EE8351E00BFAF05 /* NSMutableDictionary+Helpers.h in Headers */ = {isa = PBXBuildFile; fileRef = 93C674EF1EE8351E00BFAF05 /* NSMutableDictionary+Helpers.h */; };
446444
93C674F21EE8351E00BFAF05 /* NSMutableDictionary+Helpers.m in Sources */ = {isa = PBXBuildFile; fileRef = 93C674F01EE8351E00BFAF05 /* NSMutableDictionary+Helpers.m */; };
@@ -786,6 +784,8 @@
786784
46ABD0E9262EEE0400C7FF24 /* AppTransportSecuritySettingsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppTransportSecuritySettingsTests.swift; sourceTree = "<group>"; };
787785
4A1DEF43293051BC00322608 /* LoggingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggingTests.swift; sourceTree = "<group>"; };
788786
4A1DEF45293051C600322608 /* LoggingTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LoggingTests.m; sourceTree = "<group>"; };
787+
4A68E3CC29404181004AC3DC /* RemoteBlog.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoteBlog.swift; sourceTree = "<group>"; };
788+
4A68E3CE29404289004AC3DC /* RemoteBlogOptionsHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoteBlogOptionsHelper.swift; sourceTree = "<group>"; };
789789
57BCD3D326209D9500292CB3 /* AppTransportSecuritySettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppTransportSecuritySettings.swift; sourceTree = "<group>"; };
790790
6C2A33D76FD1052D6F30466D /* Pods-WordPressKit.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressKit.debug.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressKit/Pods-WordPressKit.debug.xcconfig"; sourceTree = "<group>"; };
791791
6F2E0CC4FA01B5475A378DA2 /* Pods-WordPressKitTests.release-alpha.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WordPressKitTests.release-alpha.xcconfig"; path = "Pods/Target Support Files/Pods-WordPressKitTests/Pods-WordPressKitTests.release-alpha.xcconfig"; sourceTree = "<group>"; };
@@ -1105,10 +1105,6 @@
11051105
93BD27791EE73944002BB00B /* WordPressOrgXMLRPCApi.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WordPressOrgXMLRPCApi.swift; sourceTree = "<group>"; };
11061106
93BD277A1EE73944002BB00B /* WordPressOrgXMLRPCValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WordPressOrgXMLRPCValidator.swift; sourceTree = "<group>"; };
11071107
93BD277B1EE73944002BB00B /* WordPressRSDParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WordPressRSDParser.swift; sourceTree = "<group>"; };
1108-
93C674E51EE8345300BFAF05 /* RemoteBlog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteBlog.h; sourceTree = "<group>"; };
1109-
93C674E61EE8345300BFAF05 /* RemoteBlog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RemoteBlog.m; sourceTree = "<group>"; };
1110-
93C674E91EE8348F00BFAF05 /* RemoteBlogOptionsHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteBlogOptionsHelper.h; sourceTree = "<group>"; };
1111-
93C674EA1EE8348F00BFAF05 /* RemoteBlogOptionsHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RemoteBlogOptionsHelper.m; sourceTree = "<group>"; };
11121108
93C674ED1EE834B700BFAF05 /* RemoteBlogSettings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RemoteBlogSettings.swift; sourceTree = "<group>"; };
11131109
93C674EF1EE8351E00BFAF05 /* NSMutableDictionary+Helpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableDictionary+Helpers.h"; sourceTree = "<group>"; };
11141110
93C674F01EE8351E00BFAF05 /* NSMutableDictionary+Helpers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMutableDictionary+Helpers.m"; sourceTree = "<group>"; };
@@ -1930,13 +1926,11 @@
19301926
826016F21F9FA17B00533B6C /* Activity.swift */,
19311927
436D56342118D85800CEAA33 /* WPCountry.swift */,
19321928
436D5640211B7F4400CEAA33 /* DomainContactInformation.swift */,
1933-
93C674E51EE8345300BFAF05 /* RemoteBlog.h */,
1934-
93C674E61EE8345300BFAF05 /* RemoteBlog.m */,
1929+
4A68E3CC29404181004AC3DC /* RemoteBlog.swift */,
19351930
82FFBF511F45F04100F4573F /* RemoteBlogJetpackMonitorSettings.swift */,
19361931
8236EB4C2024B9F8007C7CF9 /* RemoteBlogJetpackModulesSettings.swift */,
19371932
82FFBF4F1F45EFD100F4573F /* RemoteBlogJetpackSettings.swift */,
1938-
93C674E91EE8348F00BFAF05 /* RemoteBlogOptionsHelper.h */,
1939-
93C674EA1EE8348F00BFAF05 /* RemoteBlogOptionsHelper.m */,
1933+
4A68E3CE29404289004AC3DC /* RemoteBlogOptionsHelper.swift */,
19401934
74585B961F0D54B400E7E667 /* RemoteDomain.swift */,
19411935
93C674ED1EE834B700BFAF05 /* RemoteBlogSettings.swift */,
19421936
74BA04F71F06DC3900ED5CD8 /* RemoteComment.h */,
@@ -2549,7 +2543,6 @@
25492543
74DA56371F06EB0500FE9BF4 /* MediaServiceRemote.h in Headers */,
25502544
74DA56321F06EAF000FE9BF4 /* MediaServiceRemoteREST.h in Headers */,
25512545
74DA563A1F06EB3000FE9BF4 /* RemoteMedia.h in Headers */,
2552-
93C674E71EE8345300BFAF05 /* RemoteBlog.h in Headers */,
25532546
74BA04F91F06DC3900ED5CD8 /* RemoteComment.h in Headers */,
25542547
74BA04F21F06DC0A00ED5CD8 /* CommentServiceRemote.h in Headers */,
25552548
74BA04F51F06DC0A00ED5CD8 /* CommentServiceRemoteXMLRPC.h in Headers */,
@@ -2586,7 +2579,6 @@
25862579
9309995B1F16616A00F006A1 /* RemoteTheme.h in Headers */,
25872580
1A4F98672279A87D00D86E8E /* WPKit-Swift.h in Headers */,
25882581
93F50A371F226B9300B5BEBA /* WordPressComServiceRemote.h in Headers */,
2589-
93C674EB1EE8348F00BFAF05 /* RemoteBlogOptionsHelper.h in Headers */,
25902582
);
25912583
runOnlyForDeploymentPostprocessing = 0;
25922584
};
@@ -3147,12 +3139,10 @@
31473139
7E3E7A4C20E443AA0075D159 /* NSMutableParagraphStyle+extensions.swift in Sources */,
31483140
40F98809221AC88700B7B369 /* StatsPostingStreakInsight.swift in Sources */,
31493141
465F889E263B0C5500F4C950 /* BlockEditorSettingsServiceRemote.swift in Sources */,
3150-
93C674EC1EE8348F00BFAF05 /* RemoteBlogOptionsHelper.m in Sources */,
31513142
E632D7781F6E047400297F6D /* SocialLogin2FANonceInfo.swift in Sources */,
31523143
32FC1D29255C91ED00CD0A7B /* JetpackScanServiceRemote.swift in Sources */,
31533144
9F3E0B9B208732B3009CB5BA /* RemoteReaderSiteInfoSubscription.swift in Sources */,
31543145
7403A2E41EF06ED500DED7DC /* AccountSettingsRemote.swift in Sources */,
3155-
93C674E81EE8345300BFAF05 /* RemoteBlog.m in Sources */,
31563146
3236F77824AE34B40088E8F3 /* ReaderTopicServiceRemote+Interests.swift in Sources */,
31573147
FE20A6A4282A96C00025E975 /* RemoteBloggingPromptsSettings.swift in Sources */,
31583148
93BD27831EE73944002BB00B /* WordPressRSDParser.swift in Sources */,
@@ -3208,6 +3198,7 @@
32083198
E1D6B558200E473A00325669 /* TimeZoneServiceRemote.swift in Sources */,
32093199
1769DEAA24729AFF00F42EFC /* HomepageSettingsServiceRemote.swift in Sources */,
32103200
93BD273D1EE73282002BB00B /* AccountServiceRemoteREST.m in Sources */,
3201+
4A68E3CF29404289004AC3DC /* RemoteBlogOptionsHelper.swift in Sources */,
32113202
82FFBF501F45EFD100F4573F /* RemoteBlogJetpackSettings.swift in Sources */,
32123203
74650F741F0EA1E200188EDB /* RemoteGravatarProfile.swift in Sources */,
32133204
40E7FEB4221063480032834E /* StatsTodayInsight.swift in Sources */,
@@ -3240,6 +3231,7 @@
32403231
74E2295B1F1E77290085F7F2 /* KeyringConnection.swift in Sources */,
32413232
74B5F0DA1EF8299B00B411E7 /* BlogServiceRemoteXMLRPC.m in Sources */,
32423233
E1EF5D5D1F9F329900B6D53E /* SitePluginCapabilities.swift in Sources */,
3234+
4A68E3CD29404181004AC3DC /* RemoteBlog.swift in Sources */,
32433235
7E3E7A4520E443060075D159 /* NSAttributedString+extensions.swift in Sources */,
32443236
40E7FEAE220FAEA10032834E /* StatsPublicizeInsight.swift in Sources */,
32453237
93F50A411F227C9700B5BEBA /* RemoteProfile.swift in Sources */,

WordPressKit/AccountServiceRemoteREST.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#import "AccountServiceRemoteREST.h"
2-
#import "RemoteBlog.h"
3-
#import "RemoteBlogOptionsHelper.h"
42
#import "WPKit-Swift.h"
53
@import NSObject_SafeExpectations;
64
@import WordPressShared;

WordPressKit/RemoteBlog.h

Lines changed: 0 additions & 102 deletions
This file was deleted.

WordPressKit/RemoteBlog.m

Lines changed: 0 additions & 48 deletions
This file was deleted.

WordPressKit/RemoteBlog.swift

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import Foundation
2+
import NSObject_SafeExpectations
3+
4+
/// This class encapsulates all of the *remote* Blog properties
5+
@objcMembers public class RemoteBlog: NSObject {
6+
7+
/// The ID of the Blog entity.
8+
public var blogID: NSNumber?
9+
10+
/// The organization ID of the Blog entity.
11+
public var organizationID: NSNumber?
12+
13+
/// Represents the Blog Name.
14+
public var name: String?
15+
16+
/// Description of the WordPress Blog.
17+
public var tagline: String?
18+
19+
/// Represents the Blog Name.
20+
public var url: String?
21+
22+
/// Maps to the XMLRPC endpoint.
23+
public var xmlrpc: String?
24+
25+
/// Site Icon's URL.
26+
public var icon: String?
27+
28+
/// Product ID of the site's current plan, if it has one.
29+
public var planID: NSNumber?
30+
31+
/// Product name of the site's current plan, if it has one.
32+
public var planTitle: String?
33+
34+
/// Indicates whether the current's blog plan is paid, or not.
35+
public var hasPaidPlan: Bool = false
36+
37+
/// Indicates whether it's a jetpack site, or not.
38+
public var jetpack: Bool = false
39+
40+
/// Boolean indicating whether the current user has Admin privileges, or not.
41+
public var isAdmin: Bool = false
42+
43+
/// Blog's visibility preferences.
44+
public var visible: Bool = false
45+
46+
/// Blog's options preferences.
47+
public var options: NSDictionary?
48+
49+
/// Blog's capabilities: Indicate which actions are allowed / not allowed, for the current user.
50+
public var capabilities: NSDictionary?
51+
52+
/// Blog's total disk quota space.
53+
public var quotaSpaceAllowed: NSNumber?
54+
55+
/// Blog's total disk quota space used.
56+
public var quotaSpaceUsed: NSNumber?
57+
58+
/// Parses details from a JSON dictionary, as returned by the WordPress.com REST API.
59+
public init(JSONDictionary json: NSDictionary) {
60+
self.blogID = json.number(forKey: "ID")
61+
self.organizationID = json.number(forKey: "organization_id")
62+
self.name = json.string(forKey: "name")
63+
self.tagline = json.string(forKey: "description")
64+
self.url = json.string(forKey: "URL")
65+
self.xmlrpc = json.string(forKeyPath: "meta.links.xmlrpc")
66+
self.jetpack = json.number(forKey: "jetpack")?.boolValue ?? false
67+
self.icon = json.string(forKeyPath: "icon.img")
68+
self.capabilities = json.object(forKey: "capabilities") as? NSDictionary
69+
self.isAdmin = json.number(forKeyPath: "capabilities.manage_options")?.boolValue ?? false
70+
self.visible = json.number(forKey: "visible")?.boolValue ?? false
71+
self.options = RemoteBlogOptionsHelper.mapOptions(fromResponse: json)
72+
self.planID = json.number(forKeyPath: "plan.product_id")
73+
self.planTitle = json.string(forKeyPath: "plan.product_name_short")
74+
self.hasPaidPlan = json.number(forKeyPath: "plan.is_free")?.boolValue ?? false
75+
self.quotaSpaceAllowed = json.number(forKeyPath: "quota.space_allowed")
76+
self.quotaSpaceUsed = json.number(forKeyPath: "quota.space_used")
77+
}
78+
79+
}

WordPressKit/RemoteBlogOptionsHelper.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)