From 48293bbac338201be60a3bae99adab08f67479df Mon Sep 17 00:00:00 2001 From: David Christiandy <1299411+dvdchr@users.noreply.github.com> Date: Thu, 25 Nov 2021 20:39:43 +0700 Subject: [PATCH 1/3] Parse comment author's user ID --- WordPressKit/CommentServiceRemoteREST.m | 1 + WordPressKit/RemoteComment.h | 1 + WordPressKitTests/CommentServiceRemoteRESTTests.swift | 1 + WordPressKitTests/Mock Data/site-comments-success.json | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/WordPressKit/CommentServiceRemoteREST.m b/WordPressKit/CommentServiceRemoteREST.m index 94629020..157aba86 100644 --- a/WordPressKit/CommentServiceRemoteREST.m +++ b/WordPressKit/CommentServiceRemoteREST.m @@ -451,6 +451,7 @@ - (RemoteComment *)remoteCommentFromJSONDictionary:(NSDictionary *)jsonDictionar { RemoteComment *comment = [RemoteComment new]; + comment.authorID = [jsonDictionary numberForKeyPath:@"author.ID"]; comment.author = jsonDictionary[@"author"][@"name"]; // Email might be `false`, turn into `nil` comment.authorEmail = [jsonDictionary[@"author"] stringForKey:@"email"]; diff --git a/WordPressKit/RemoteComment.h b/WordPressKit/RemoteComment.h index 087e30d9..82c1917c 100644 --- a/WordPressKit/RemoteComment.h +++ b/WordPressKit/RemoteComment.h @@ -2,6 +2,7 @@ @interface RemoteComment : NSObject @property (nonatomic, strong) NSNumber *commentID; +@property (nonatomic, strong) NSNumber *authorID; @property (nonatomic, strong) NSString *author; @property (nonatomic, strong) NSString *authorEmail; @property (nonatomic, strong) NSString *authorUrl; diff --git a/WordPressKitTests/CommentServiceRemoteRESTTests.swift b/WordPressKitTests/CommentServiceRemoteRESTTests.swift index 189ec002..6de8cb67 100644 --- a/WordPressKitTests/CommentServiceRemoteRESTTests.swift +++ b/WordPressKitTests/CommentServiceRemoteRESTTests.swift @@ -39,6 +39,7 @@ final class CommentServiceRemoteRESTTests: RemoteTestCase, RESTTestable { return } + XCTAssertEqual(comment.authorID, NSNumber(value: 12345)) XCTAssertEqual(comment.author, "Comment Author") XCTAssertEqual(comment.authorEmail, "author@email.com") XCTAssertEqual(comment.authorUrl, "author URL") diff --git a/WordPressKitTests/Mock Data/site-comments-success.json b/WordPressKitTests/Mock Data/site-comments-success.json index 8dc626f1..d8a42a4b 100644 --- a/WordPressKitTests/Mock Data/site-comments-success.json +++ b/WordPressKitTests/Mock Data/site-comments-success.json @@ -11,7 +11,7 @@ "link": "post URL" }, "author": { - "ID": 0, + "ID": 12345, "login": "", "email": "author@email.com", "name": "Comment Author", From 58f9fe1c4794b4d5bb1153d2e45f8a9433698750 Mon Sep 17 00:00:00 2001 From: David Christiandy <1299411+dvdchr@users.noreply.github.com> Date: Thu, 25 Nov 2021 20:47:19 +0700 Subject: [PATCH 2/3] Bump podspec version to 4.44.0-beta.2 --- WordPressKit.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressKit.podspec b/WordPressKit.podspec index ce9595a6..819eb9d9 100644 --- a/WordPressKit.podspec +++ b/WordPressKit.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |s| s.name = 'WordPressKit' - s.version = '4.44.0-beta.1' + s.version = '4.44.0-beta.2' s.summary = 'WordPressKit offers a clean and simple WordPress.com and WordPress.org API.' s.description = <<-DESC From f78bb4cc300f5147cb3a2cdb3656b8480bc7c8e8 Mon Sep 17 00:00:00 2001 From: David Christiandy <1299411+dvdchr@users.noreply.github.com> Date: Mon, 29 Nov 2021 19:07:06 +0700 Subject: [PATCH 3/3] Parse post authorID in RemoteReaderPost --- WordPressKit/RemoteReaderPost.h | 1 + WordPressKit/RemoteReaderPost.m | 1 + 2 files changed, 2 insertions(+) diff --git a/WordPressKit/RemoteReaderPost.h b/WordPressKit/RemoteReaderPost.h index cf230911..f25b51a7 100644 --- a/WordPressKit/RemoteReaderPost.h +++ b/WordPressKit/RemoteReaderPost.h @@ -56,6 +56,7 @@ @property (nonatomic) BOOL receivesCommentNotifications; // Base Post Model +@property (nonatomic, strong) NSNumber *authorID; @property (nonatomic, strong) NSString *author; @property (nonatomic, strong) NSString *content; @property (nonatomic, strong) NSString *date_created_gmt; diff --git a/WordPressKit/RemoteReaderPost.m b/WordPressKit/RemoteReaderPost.m index a014a8cd..ee0032ed 100644 --- a/WordPressKit/RemoteReaderPost.m +++ b/WordPressKit/RemoteReaderPost.m @@ -92,6 +92,7 @@ - (instancetype)initWithDictionary:(NSDictionary *)dict; NSDictionary *authorDict = [dict dictionaryForKey:PostRESTKeyAuthor]; NSDictionary *discussionDict = [dict dictionaryForKey:PostRESTKeyDiscussion] ?: dict; + self.authorID = [authorDict numberForKey:PostRESTKeyID]; self.author = [self stringOrEmptyString:[authorDict stringForKey:PostRESTKeyNiceName]]; // typically the author's screen name self.authorAvatarURL = [self stringOrEmptyString:[authorDict stringForKey:PostRESTKeyAvatarURL]]; self.authorDisplayName = [[self stringOrEmptyString:[authorDict stringForKey:PostRESTKeyName]] stringByDecodingXMLCharacters]; // Typically the author's given name