File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,23 @@ public class Comment(Author author) {
50
50
/// The comment's type.
51
51
/// </summary>
52
52
public string Type { get ; set ; } = string . Empty ;
53
+
54
+ /// <summary>
55
+ /// Returns a JSON representation of this object.
56
+ /// </summary>
57
+ /// <returns>The JSON representation of this object.</returns>
58
+ internal IDictionary < string , string > ToJson ( ) {
59
+ var map = Author . ToJson ( ) ;
60
+ if ( ! string . IsNullOrWhiteSpace ( Content ) ) map [ "comment_content" ] = Content ;
61
+ // TODO if (Context.Count > 0) map["comment_context"] = Context.ToString();
62
+ if ( Date is not null ) map [ "comment_date_gmt" ] = Date ? . ToUniversalTime ( ) . ToString ( "yyyy-MM-ddTHH:mm:ssZ" ) ! ;
63
+ if ( Permalink is not null ) map [ "permalink" ] = Permalink . ToString ( ) ;
64
+ if ( PostModified is not null ) map [ "comment_post_modified_gmt" ] = PostModified ? . ToUniversalTime ( ) . ToString ( "yyyy-MM-ddTHH:mm:ssZ" ) ! ;
65
+ if ( ! string . IsNullOrWhiteSpace ( RecheckReason ) ) map [ "recheck_reason" ] = RecheckReason ;
66
+ if ( Referrer is not null ) map [ "referrer" ] = Referrer . ToString ( ) ;
67
+ if ( ! string . IsNullOrWhiteSpace ( Type ) ) map [ "comment_type" ] = Type ;
68
+ return map ;
69
+ }
53
70
}
54
71
55
72
/// <summary>
You can’t perform that action at this time.
0 commit comments