This repository was archived by the owner on Sep 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Re-implement a few remote post related types #559
Merged
crazytonyli
merged 3 commits into
translate-objc-to-swift
from
swift-translation-remote-post-types
Dec 16, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| extension NSObject { | ||
|
|
||
| var allProperties: [String: Any] { | ||
| let properties = Mirror(reflecting: self) | ||
| .children | ||
| .compactMap { child -> (String, Any)? in | ||
| if let label = child.label { | ||
| return (label, child.value) | ||
| } else { | ||
| return nil | ||
| } | ||
| } | ||
| return Dictionary(properties) { (_, new) in new } | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| import Foundation | ||
| import ObjectiveC | ||
|
|
||
| @objcMembers public class RemotePost: NSObject { | ||
|
|
||
| public static let statusDraft = "draft" | ||
| public static let statusPending = "pending" | ||
| public static let statusPrivate = "private" | ||
| public static let statusPublish = "publish" | ||
| public static let statusScheduled = "future" | ||
| public static let statusTrash = "trash" | ||
| /// Returned by the WordPress.com REST API when a post is permanently deleted. | ||
| public static let statusDeleted = "deleted" | ||
|
|
||
| public var postID: NSNumber? | ||
| public var siteID: NSNumber? | ||
| public var authorAvatarURL: String? | ||
| public var authorDisplayName: String? | ||
| public var authorEmail: String? | ||
| public var authorURL: String? | ||
| public var authorID: NSNumber? | ||
| public var date: NSDate? | ||
| public var dateModified: NSDate? | ||
| public var title: String? | ||
| public var URL: NSURL? | ||
| public var shortURL: NSURL? | ||
| public var content: String? | ||
| public var excerpt: String? | ||
| public var slug: String? | ||
| public var suggestedSlug: String? | ||
| public var status: String? | ||
| public var password: String? | ||
| public var parentID: NSNumber? | ||
| public var postThumbnailID: NSNumber? | ||
| public var postThumbnailPath: String? | ||
| public var type: String? | ||
| public var format: String? | ||
|
|
||
| /** | ||
| * A snapshot of the post at the last autosave. | ||
| * | ||
| * This is nullable. | ||
| */ | ||
| public var autosave: RemotePostAutosave? | ||
|
|
||
| public var commentCount: NSNumber? | ||
| public var likeCount: NSNumber? | ||
|
|
||
| public var categories: NSArray? | ||
| public var revisions: NSArray? | ||
| public var tags: NSArray? | ||
| public var pathForDisplayImage: String? | ||
| public var isStickyPost: NSNumber? | ||
| public var isFeaturedImageChanged: Bool = false | ||
|
|
||
| /** | ||
| Array of custom fields. Each value is a dictionary containing {ID, key, value} | ||
| */ | ||
| public var metadata: [[String: Any]]? | ||
|
|
||
| // Featured images? | ||
| // Geolocation? | ||
| // Attachments? | ||
| // Metadata? | ||
|
|
||
| public override init() { | ||
| super.init() | ||
| } | ||
|
|
||
| public init(siteID: NSNumber, status: String, title: String?, content: String?) { | ||
| super.init() | ||
| self.siteID = siteID | ||
| self.status = status | ||
| self.title = title | ||
| self.content = content | ||
| } | ||
|
|
||
| public override var debugDescription: String { | ||
| "\(super.description) (\(allProperties))" | ||
| } | ||
|
|
||
| } | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import Foundation | ||
|
|
||
| @objcMembers public class RemotePostCategory: NSObject { | ||
| public var categoryID: NSNumber? | ||
| public var name: String? | ||
| public var parentID: NSNumber? | ||
|
|
||
| public override var debugDescription: String { | ||
| "\(super.description) (\(allProperties))" | ||
| } | ||
|
|
||
| public override var description: String { | ||
| return "\(super.description) \(String(describing: name))[\(String(describing: categoryID))]" | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import Foundation | ||
|
|
||
| @objcMembers public class RemotePostTag: NSObject { | ||
|
|
||
| public var tagID: NSNumber? | ||
| public var name: String? | ||
| public var slug: String? | ||
| public var tagDescription: String? | ||
| public var postCount: NSNumber? | ||
|
|
||
| public override var debugDescription: String { | ||
| "\(super.description) (\(allProperties))" | ||
| } | ||
|
|
||
| public override var description: String { | ||
| return "\(super.description) \(String(describing: name))[\(String(describing: tagID))]" | ||
| } | ||
|
|
||
| } |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL
debugDescription.