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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _None._

### Breaking Changes

- Re-implement a few reader model types in Swift. [#556]
- Re-implement a few reader model types in Swift. [#556, #557, #558]
Copy link
Contributor

Choose a reason for hiding this comment

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

If I'm not mistaken, this would be an un-breaking change, so we could probably move this out of the Breaking Changes section (and thus avoid cutting a new major version unnecessarily?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically speaking, I'd argue they are still breaking changes, even if we revert the two properties changes I mentioned above. The types are changed from Objective-C classes to Swift classes. And Swift class has its restrictions that Objective-C class don't have, like they cann't be inherited by an Objective-C class. I guess it's not likely that the apps have a subclass of these model types, but I'd say it's best to follow semantic version strictly, what do you think?


### New Features

Expand Down
26 changes: 13 additions & 13 deletions WordPressKit/RemoteBlog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@ import NSObject_SafeExpectations
@objcMembers public class RemoteBlog: NSObject {

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

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

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

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

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

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

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

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

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

/// Indicates whether the current's blog plan is paid, or not.
public var hasPaidPlan: Bool = false
Expand All @@ -44,16 +44,16 @@ import NSObject_SafeExpectations
public var visible: Bool = false

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

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

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

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

/// Parses details from a JSON dictionary, as returned by the WordPress.com REST API.
public init(JSONDictionary json: NSDictionary) {
Expand Down
12 changes: 6 additions & 6 deletions WordPressKit/RemoteReaderSite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import Foundation

@objcMembers public class RemoteReaderSite: NSObject {

public var recordID: NSNumber?
public var siteID: NSNumber?
public var feedID: NSNumber?
public var name: String?
public var path: String? // URL
public var icon: String? // Sites only
public var recordID: NSNumber!
public var siteID: NSNumber!
public var feedID: NSNumber!
public var name: String!
public var path: String! // URL
public var icon: String! // Sites only
public var isSubscribed: Bool = false

}
26 changes: 13 additions & 13 deletions WordPressKit/RemoteReaderSiteInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ private let DeliveryMethodEmailKey = "email"
private let DeliveryMethodNotificationKey = "notification"

@objcMembers public class RemoteReaderSiteInfo: NSObject {
public var feedID: NSNumber?
public var feedURL: String?
public var feedID: NSNumber!
public var feedURL: String!
public var isFollowing: Bool = false
public var isJetpack: Bool = false
public var isPrivate: Bool = false
public var isVisible: Bool = false
public var organizationID: NSNumber?
public var postCount: NSNumber?
public var siteBlavatar: String?
public var siteDescription: String?
public var siteID: NSNumber?
public var siteName: String?
public var siteURL: String?
public var subscriberCount: NSNumber?
public var unseenCount: NSNumber?
public var postsEndpoint: String?
public var endpointPath: String?
public var organizationID: NSNumber!
public var postCount: NSNumber!
public var siteBlavatar: String!
public var siteDescription: String!
public var siteID: NSNumber!
public var siteName: String!
public var siteURL: String!
public var subscriberCount: NSNumber!
public var unseenCount: NSNumber!
public var postsEndpoint: String!
public var endpointPath: String!

public var postSubscription: RemoteReaderSiteInfoSubscriptionPost?
public var emailSubscription: RemoteReaderSiteInfoSubscriptionEmail?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The two properties above are kept as Optional since we know for sure that they are:

class func postSubscription(forSubscription subscription: NSDictionary) -> RemoteReaderSiteInfoSubscriptionPost? {
guard subscription.wp_isValidObject() else {
return nil
}
guard let deliveryMethod = subscription[SubscriptionDeliveryMethodsKey] as? [String: Any],
let method = deliveryMethod[DeliveryMethodNotificationKey] as? [String: Any]
else {
return nil
}
return RemoteReaderSiteInfoSubscriptionPost(dictionary: method)
}

class func emailSubscription(forSubscription subscription: NSDictionary) -> RemoteReaderSiteInfoSubscriptionEmail? {
guard subscription.wp_isValidObject() else {
return nil
}
guard let delieveryMethod = subscription[SubscriptionDeliveryMethodsKey] as? [String: Any],
let method = delieveryMethod[DeliveryMethodEmailKey] as? [String: Any]
else {
return nil
}
return RemoteReaderSiteInfoSubscriptionEmail(dictionary: method)
}

Expand Down
16 changes: 8 additions & 8 deletions WordPressKit/RemoteReaderTopic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import Foundation
public var isMenuItem: Bool = false
public var isRecommended: Bool = false
public var isSubscribed: Bool = false
public var path: String?
public var slug: String?
public var title: String?
public var topicDescription: String?
public var topicID: NSNumber?
public var type: String?
public var owner: String?
public var organizationID: NSNumber?
public var path: String!
public var slug: String!
public var title: String!
public var topicDescription: String!
public var topicID: NSNumber!
public var type: String!
public var owner: String!
public var organizationID: NSNumber!

}