Skip to content

pieforhead.comment

Comment

Class to hold Comment endpoints.

Source code in pieforhead/comment.py
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
class Comment:
    """Class to hold Comment endpoints."""

    def __init__(self, client: PieFedClient):
        self._client = client

    def list_comments(
        self,
        limit: int | None = None,
        page: int | None = None,
        sort: str | None = None,
        type_: str | None = None,
        liked_only: bool | None = None,
        saved_only: bool | None = None,
        person_id: int | None = None,
        community_id: int | None = None,
        post_id: int | None = None,
        parent_id: int | None = None,
        max_depth: int | None = None,
        depth_first: bool | None = None,
    ) -> dict | None:
        """Get list of comments.

        API endpoint: GET comment/list

        Args:
            limit (int | None, optional): Max number to return for a page of results. Defaults to None.
            page (int | None, optional): Page of results to request. Defaults to None.
            sort (str | None, optional): Sorting method for the returned comments. Defaults to None.
            type_ (str | None, optional): Type filter (Subscribed, Local, etc.). Defaults to None.
            liked_only (bool | None, optional): Only return liked comments. Defaults to None.
            saved_only (bool | None, optional): Only return saved comments. Defaults to None.
            person_id (int | None, optional): Filter to comments by a specific user. Defaults to None.
            community_id (int | None, optional): Filter to comments in a specific community. Defaults to None.
            post_id (int | None, optional): Filter to comments on a specific post. Defaults to None.
            parent_id (int | None, optional): Filter to replies to a specific comment. Defaults to None.
            max_depth (int | None, optional): Max number of nested levels to return. Defaults to None.
            depth_first (bool | None, optional): Guarantee parent comments are on the same page as any fetched comments.
                Defaults to None.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """

        params = {}

        if limit is not None:
            params["limit"] = limit
        if page is not None:
            params["page"] = page
        if sort is not None:
            params["sort"] = sort
        if type_ is not None:
            params["type_"] = type_
        if liked_only is not None:
            params["liked_only"] = liked_only
        if saved_only is not None:
            params["saved_only"] = saved_only
        if person_id is not None:
            params["person_id"] = person_id
        if community_id is not None:
            params["community_id"] = community_id
        if post_id is not None:
            params["post_id"] = post_id
        if parent_id is not None:
            params["parent_id"] = parent_id
        if max_depth is not None:
            params["max_depth"] = max_depth
        if depth_first is not None:
            params["depth_first"] = depth_first

        return self._client.request(method="GET", endpoint="comment/list", params=params)

    def get(self, comment_id: int) -> dict | None:
        """Get info for a single comment.

        API endpoint: GET comment

        Args:
            comment_id (int): Comment id of the comment to retrieve.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        return self._client.request(method="GET", endpoint="comment", params={"id": comment_id})

    def create(
        self,
        body: str,
        post_id: int,
        parent_id: int | None = None,
        language_id: int | None = None,
    ) -> dict | None:
        """Create a comment.

        API endpoint: POST comment

        Args:
            body (str): Content of the comment in markdown.
            post_id (int): Post id that the comment is replying to.
            parent_id (int | None, optional): Parent comment id if the comment is a reply to another comment. Defaults
                to None.
            language_id (int | None, optional): Language id of the comment. Defaults to None.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"body": body, "post_id": post_id}

        if parent_id is not None:
            data["parent_id"] = parent_id
        if language_id is not None:
            data["language_id"] = language_id

        return self._client.request(method="POST", endpoint="comment", data=data)

    def edit(
        self,
        comment_id: int,
        body: str,
        language_id: int | None = None,
        distinguished: bool | None = None,
    ) -> dict | None:
        """Edit a comment

        API endpoint: PUT comment

        Args:
            comment_id (int): The comment id of the comment to edit.
            body (str): New, edited content of the body in markdown.
            language_id (int | None, optional): Language id of the comment. Defaults to None.
            distinguished (bool | None, optional): Distinguish the comment as written by a moderator. Defaults to None.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_id": comment_id, "body": body}

        if language_id is not None:
            data["language_id"] = language_id
        if distinguished is not None:
            data["distinguished"] = distinguished

        return self._client.request(method="PUT", endpoint="comment", data=data)

    def like(self, comment_id: int, score: int, private: bool | None = None, emoji: str | None = None) -> dict | None:
        """Vote on a comment.

        API endpoint: POST comment/like

        Args:
            comment_id (int): Comment id being voted on.
            score (int): 1 and -1 for up/down vote respectively. 0 to undo a vote.
            private (bool | None, optional): Should this vote be federated? Defaults to None.
            emoji (str | None, optional): Emoji reaction to include with vote if desired. Defaults to None.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_id": comment_id, "score": score}

        if private is not None:
            data["private"] = private
        if emoji is not None:
            data["emoji"] = emoji

        return self._client.request(method="POST", endpoint="comment/like", data=data)

    def save(self, comment_id: int, save: bool) -> dict | None:
        """Save a comment.

        API endpoint: PUT comment/save

        Args:
            comment_id (int): Comment id being saved.
            save (bool): True to save. False to remove from saved.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_id": comment_id, "save": save}

        return self._client.request(method="PUT", endpoint="comment/save", data=data)

    def subscribe(self, comment_id: int, subscribe: bool) -> dict | None:
        """Get notified of new replies to a comment.

        API endpoint: PUT comment/subscribe

        Args:
            comment_id (int): Comment id to subscribe to.
            subscribe (bool): True to subscribe. False to remove subscription.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_id": comment_id, "subscribe": subscribe}

        return self._client.request(method="PUT", endpoint="comment/subscribe", data=data)

    def delete(self, comment_id: int, deleted: bool) -> dict | None:
        """Delete a comment.

        API endpoint: POST comment/delete

        Args:
            comment_id (int): Comment id of the comment being deleted.
            deleted (bool): True to delete the comment. False to restore it.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_id": comment_id, "deleted": deleted}

        return self._client.request(method="POST", endpoint="comment/delete", data=data)

    def report(
        self,
        comment_id: int,
        reason: str,
        description: str | None = None,
        report_remote: bool | None = None,
    ) -> dict | None:
        """Report a comment to moderators/admins.

        API endpoint: POST comment/report

        Args:
            comment_id (int): Comment id to report.
            reason (str): Reason for the report.
            description (str | None, optional): Additional details to provide with the report. Defaults to None.
            report_remote (bool | None, optional): Forward report to the author's remote admins if applicable. Defaults
                to None.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_id": comment_id, "reason": reason}

        if description is not None:
            data["description"] = description
        if report_remote is not None:
            data["report_remote"] = report_remote

        return self._client.request(method="POST", endpoint="comment/report", data=data)

    def list_reports(
        self,
        comment_id: int | None = None,
        community_id: int | None = None,
        limit: int | None = None,
        page: int | None = None,
        unresolved_only: bool | None = None,
    ) -> dict | None:
        """List comment reports.

        API endpoint: GET comment/report/list

        Args:
            comment_id (int | None, optional): Filter reports to a single comment by id. Defaults to None.
            community_id (int | None, optional): Filter reports to a single community by id. Defaults to None.
            limit (int | None, optional): Max number of reports per page. Defaults to None.
            page (int | None, optional): Page number to request. Defaults to None.
            unresolved_only (bool | None, optional): Only return unresolved reports. Defaults to None.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        params = {}

        if comment_id is not None:
            params["comment_id"] = comment_id
        if community_id is not None:
            params["community_id"] = community_id
        if limit is not None:
            params["limit"] = limit
        if page is not None:
            params["page"] = page
        if unresolved_only is not None:
            params["unresolved_only"] = unresolved_only

        return self._client.request(method="GET", endpoint="comment/report/list", params=params)

    def resolve_report(self, report_id: int, resolved: bool) -> dict | None:
        """Resolve a report.

        API endpoint: PUT comment/report/resolve

        Args:
            report_id (int): Report id that is being resolved (or unresolved).
            resolved (bool): True to resolve the report. False to unresolve it.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"report_id": report_id, "resolved": resolved}

        return self._client.request(method="PUT", endpoint="comment/report/resolve", data=data)

    def remove(self, comment_id: int, removed: bool, reason: str | None = None) -> dict | None:
        """Remove a comment as a moderator/admin.

        API endpoint: POST comment/remove

        Args:
            comment_id (int): Comment id of the comment being removed.
            removed (bool): True to remove the comment. False to restore it.
            reason (str | None, optional): Reason for removal. Defaults to None.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_id": comment_id, "removed": removed}

        if reason is not None:
            data["reason"] = reason

        return self._client.request(method="POST", endpoint="comment/remove", data=data)

    def mark_as_read(self, comment_reply_id: int, read: bool) -> dict | None:
        """Mark a comment as read or unread.

        API endpoint: POST comment/mark_as_read

        Args:
            comment_reply_id (int): Comment id being marked as read or unread.
            read (bool): True to mark as read. False to mark as unread.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_reply_id": comment_reply_id, "read": read}

        return self._client.request(method="POST", endpoint="comment/mark_as_read", data=data)

    def mark_as_answer(self, comment_reply_id: int, answer: bool) -> dict | None:
        """Mark a comment as an answer in a question and answer community.

        API endpoint: POST comment/mark_as_answer

        Args:
            comment_reply_id (int): Comment id being marked as an answer.
            answer (bool): True to mark it as an answer. False to unmark it.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_reply_id": comment_reply_id, "answer": answer}

        return self._client.request(method="POST", endpoint="comment/mark_as_answer", data=data)

    def distinguish(self, comment_reply_id: int, distinguished: bool) -> dict | None:
        """Mark or unmark a comment as being spoken by a moderator.

        API endpoint: POST comment/distinguish

        Args:
            comment_reply_id (int): Comment id being distinguished.
            distinguished (bool): True to distinguish the comment. False to undistinguish it.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_reply_id": comment_reply_id, "distinguished": distinguished}

        return self._client.request(method="POST", endpoint="comment/distinguish", data=data)

    def lock(self, comment_id: int, locked: bool) -> dict | None:
        """Lock a comment chain, preventing further replies.

        API endpoint: POST comment/lock

        Args:
            comment_id (int): Comment id of comment being locked.
            locked (bool): True to lock the comment. False to unlock it.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_id": comment_id, "locked": locked}

        return self._client.request(method="POST", endpoint="comment/lock", data=data)

    def list_likes(self, comment_id: int, page: int | None = None, limit: int | None = None) -> dict | None:
        """List the votes on a comment.

        API endpoint: GET comment/like/list

        Args:
            comment_id (int): Comment id of the comment votes being fetched.
            page (int | None, optional): Page number of the results to fetch. Defaults to None.
            limit (int | None, optional): Max number of votes on each page of results. Defaults to None.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        params = {"comment_id": comment_id}

        if page is not None:
            params["page"] = page
        if limit is not None:
            params["limit"] = limit

        return self._client.request(method="GET", endpoint="comment/like/list", params=params)

create(body, post_id, parent_id=None, language_id=None)

Create a comment.

API endpoint: POST comment

Parameters:

Name Type Description Default
body str

Content of the comment in markdown.

required
post_id int

Post id that the comment is replying to.

required
parent_id int | None

Parent comment id if the comment is a reply to another comment. Defaults to None.

None
language_id int | None

Language id of the comment. Defaults to None.

None

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
def create(
    self,
    body: str,
    post_id: int,
    parent_id: int | None = None,
    language_id: int | None = None,
) -> dict | None:
    """Create a comment.

    API endpoint: POST comment

    Args:
        body (str): Content of the comment in markdown.
        post_id (int): Post id that the comment is replying to.
        parent_id (int | None, optional): Parent comment id if the comment is a reply to another comment. Defaults
            to None.
        language_id (int | None, optional): Language id of the comment. Defaults to None.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"body": body, "post_id": post_id}

    if parent_id is not None:
        data["parent_id"] = parent_id
    if language_id is not None:
        data["language_id"] = language_id

    return self._client.request(method="POST", endpoint="comment", data=data)

delete(comment_id, deleted)

Delete a comment.

API endpoint: POST comment/delete

Parameters:

Name Type Description Default
comment_id int

Comment id of the comment being deleted.

required
deleted bool

True to delete the comment. False to restore it.

required

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
def delete(self, comment_id: int, deleted: bool) -> dict | None:
    """Delete a comment.

    API endpoint: POST comment/delete

    Args:
        comment_id (int): Comment id of the comment being deleted.
        deleted (bool): True to delete the comment. False to restore it.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_id": comment_id, "deleted": deleted}

    return self._client.request(method="POST", endpoint="comment/delete", data=data)

distinguish(comment_reply_id, distinguished)

Mark or unmark a comment as being spoken by a moderator.

API endpoint: POST comment/distinguish

Parameters:

Name Type Description Default
comment_reply_id int

Comment id being distinguished.

required
distinguished bool

True to distinguish the comment. False to undistinguish it.

required

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
def distinguish(self, comment_reply_id: int, distinguished: bool) -> dict | None:
    """Mark or unmark a comment as being spoken by a moderator.

    API endpoint: POST comment/distinguish

    Args:
        comment_reply_id (int): Comment id being distinguished.
        distinguished (bool): True to distinguish the comment. False to undistinguish it.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_reply_id": comment_reply_id, "distinguished": distinguished}

    return self._client.request(method="POST", endpoint="comment/distinguish", data=data)

edit(comment_id, body, language_id=None, distinguished=None)

Edit a comment

API endpoint: PUT comment

Parameters:

Name Type Description Default
comment_id int

The comment id of the comment to edit.

required
body str

New, edited content of the body in markdown.

required
language_id int | None

Language id of the comment. Defaults to None.

None
distinguished bool | None

Distinguish the comment as written by a moderator. Defaults to None.

None

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
def edit(
    self,
    comment_id: int,
    body: str,
    language_id: int | None = None,
    distinguished: bool | None = None,
) -> dict | None:
    """Edit a comment

    API endpoint: PUT comment

    Args:
        comment_id (int): The comment id of the comment to edit.
        body (str): New, edited content of the body in markdown.
        language_id (int | None, optional): Language id of the comment. Defaults to None.
        distinguished (bool | None, optional): Distinguish the comment as written by a moderator. Defaults to None.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_id": comment_id, "body": body}

    if language_id is not None:
        data["language_id"] = language_id
    if distinguished is not None:
        data["distinguished"] = distinguished

    return self._client.request(method="PUT", endpoint="comment", data=data)

get(comment_id)

Get info for a single comment.

API endpoint: GET comment

Parameters:

Name Type Description Default
comment_id int

Comment id of the comment to retrieve.

required

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
def get(self, comment_id: int) -> dict | None:
    """Get info for a single comment.

    API endpoint: GET comment

    Args:
        comment_id (int): Comment id of the comment to retrieve.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    return self._client.request(method="GET", endpoint="comment", params={"id": comment_id})

like(comment_id, score, private=None, emoji=None)

Vote on a comment.

API endpoint: POST comment/like

Parameters:

Name Type Description Default
comment_id int

Comment id being voted on.

required
score int

1 and -1 for up/down vote respectively. 0 to undo a vote.

required
private bool | None

Should this vote be federated? Defaults to None.

None
emoji str | None

Emoji reaction to include with vote if desired. Defaults to None.

None

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
def like(self, comment_id: int, score: int, private: bool | None = None, emoji: str | None = None) -> dict | None:
    """Vote on a comment.

    API endpoint: POST comment/like

    Args:
        comment_id (int): Comment id being voted on.
        score (int): 1 and -1 for up/down vote respectively. 0 to undo a vote.
        private (bool | None, optional): Should this vote be federated? Defaults to None.
        emoji (str | None, optional): Emoji reaction to include with vote if desired. Defaults to None.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_id": comment_id, "score": score}

    if private is not None:
        data["private"] = private
    if emoji is not None:
        data["emoji"] = emoji

    return self._client.request(method="POST", endpoint="comment/like", data=data)

list_comments(limit=None, page=None, sort=None, type_=None, liked_only=None, saved_only=None, person_id=None, community_id=None, post_id=None, parent_id=None, max_depth=None, depth_first=None)

Get list of comments.

API endpoint: GET comment/list

Parameters:

Name Type Description Default
limit int | None

Max number to return for a page of results. Defaults to None.

None
page int | None

Page of results to request. Defaults to None.

None
sort str | None

Sorting method for the returned comments. Defaults to None.

None
type_ str | None

Type filter (Subscribed, Local, etc.). Defaults to None.

None
liked_only bool | None

Only return liked comments. Defaults to None.

None
saved_only bool | None

Only return saved comments. Defaults to None.

None
person_id int | None

Filter to comments by a specific user. Defaults to None.

None
community_id int | None

Filter to comments in a specific community. Defaults to None.

None
post_id int | None

Filter to comments on a specific post. Defaults to None.

None
parent_id int | None

Filter to replies to a specific comment. Defaults to None.

None
max_depth int | None

Max number of nested levels to return. Defaults to None.

None
depth_first bool | None

Guarantee parent comments are on the same page as any fetched comments. Defaults to None.

None

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
def list_comments(
    self,
    limit: int | None = None,
    page: int | None = None,
    sort: str | None = None,
    type_: str | None = None,
    liked_only: bool | None = None,
    saved_only: bool | None = None,
    person_id: int | None = None,
    community_id: int | None = None,
    post_id: int | None = None,
    parent_id: int | None = None,
    max_depth: int | None = None,
    depth_first: bool | None = None,
) -> dict | None:
    """Get list of comments.

    API endpoint: GET comment/list

    Args:
        limit (int | None, optional): Max number to return for a page of results. Defaults to None.
        page (int | None, optional): Page of results to request. Defaults to None.
        sort (str | None, optional): Sorting method for the returned comments. Defaults to None.
        type_ (str | None, optional): Type filter (Subscribed, Local, etc.). Defaults to None.
        liked_only (bool | None, optional): Only return liked comments. Defaults to None.
        saved_only (bool | None, optional): Only return saved comments. Defaults to None.
        person_id (int | None, optional): Filter to comments by a specific user. Defaults to None.
        community_id (int | None, optional): Filter to comments in a specific community. Defaults to None.
        post_id (int | None, optional): Filter to comments on a specific post. Defaults to None.
        parent_id (int | None, optional): Filter to replies to a specific comment. Defaults to None.
        max_depth (int | None, optional): Max number of nested levels to return. Defaults to None.
        depth_first (bool | None, optional): Guarantee parent comments are on the same page as any fetched comments.
            Defaults to None.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """

    params = {}

    if limit is not None:
        params["limit"] = limit
    if page is not None:
        params["page"] = page
    if sort is not None:
        params["sort"] = sort
    if type_ is not None:
        params["type_"] = type_
    if liked_only is not None:
        params["liked_only"] = liked_only
    if saved_only is not None:
        params["saved_only"] = saved_only
    if person_id is not None:
        params["person_id"] = person_id
    if community_id is not None:
        params["community_id"] = community_id
    if post_id is not None:
        params["post_id"] = post_id
    if parent_id is not None:
        params["parent_id"] = parent_id
    if max_depth is not None:
        params["max_depth"] = max_depth
    if depth_first is not None:
        params["depth_first"] = depth_first

    return self._client.request(method="GET", endpoint="comment/list", params=params)

list_likes(comment_id, page=None, limit=None)

List the votes on a comment.

API endpoint: GET comment/like/list

Parameters:

Name Type Description Default
comment_id int

Comment id of the comment votes being fetched.

required
page int | None

Page number of the results to fetch. Defaults to None.

None
limit int | None

Max number of votes on each page of results. Defaults to None.

None

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
def list_likes(self, comment_id: int, page: int | None = None, limit: int | None = None) -> dict | None:
    """List the votes on a comment.

    API endpoint: GET comment/like/list

    Args:
        comment_id (int): Comment id of the comment votes being fetched.
        page (int | None, optional): Page number of the results to fetch. Defaults to None.
        limit (int | None, optional): Max number of votes on each page of results. Defaults to None.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    params = {"comment_id": comment_id}

    if page is not None:
        params["page"] = page
    if limit is not None:
        params["limit"] = limit

    return self._client.request(method="GET", endpoint="comment/like/list", params=params)

list_reports(comment_id=None, community_id=None, limit=None, page=None, unresolved_only=None)

List comment reports.

API endpoint: GET comment/report/list

Parameters:

Name Type Description Default
comment_id int | None

Filter reports to a single comment by id. Defaults to None.

None
community_id int | None

Filter reports to a single community by id. Defaults to None.

None
limit int | None

Max number of reports per page. Defaults to None.

None
page int | None

Page number to request. Defaults to None.

None
unresolved_only bool | None

Only return unresolved reports. Defaults to None.

None

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
def list_reports(
    self,
    comment_id: int | None = None,
    community_id: int | None = None,
    limit: int | None = None,
    page: int | None = None,
    unresolved_only: bool | None = None,
) -> dict | None:
    """List comment reports.

    API endpoint: GET comment/report/list

    Args:
        comment_id (int | None, optional): Filter reports to a single comment by id. Defaults to None.
        community_id (int | None, optional): Filter reports to a single community by id. Defaults to None.
        limit (int | None, optional): Max number of reports per page. Defaults to None.
        page (int | None, optional): Page number to request. Defaults to None.
        unresolved_only (bool | None, optional): Only return unresolved reports. Defaults to None.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    params = {}

    if comment_id is not None:
        params["comment_id"] = comment_id
    if community_id is not None:
        params["community_id"] = community_id
    if limit is not None:
        params["limit"] = limit
    if page is not None:
        params["page"] = page
    if unresolved_only is not None:
        params["unresolved_only"] = unresolved_only

    return self._client.request(method="GET", endpoint="comment/report/list", params=params)

lock(comment_id, locked)

Lock a comment chain, preventing further replies.

API endpoint: POST comment/lock

Parameters:

Name Type Description Default
comment_id int

Comment id of comment being locked.

required
locked bool

True to lock the comment. False to unlock it.

required

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
def lock(self, comment_id: int, locked: bool) -> dict | None:
    """Lock a comment chain, preventing further replies.

    API endpoint: POST comment/lock

    Args:
        comment_id (int): Comment id of comment being locked.
        locked (bool): True to lock the comment. False to unlock it.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_id": comment_id, "locked": locked}

    return self._client.request(method="POST", endpoint="comment/lock", data=data)

mark_as_answer(comment_reply_id, answer)

Mark a comment as an answer in a question and answer community.

API endpoint: POST comment/mark_as_answer

Parameters:

Name Type Description Default
comment_reply_id int

Comment id being marked as an answer.

required
answer bool

True to mark it as an answer. False to unmark it.

required

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
def mark_as_answer(self, comment_reply_id: int, answer: bool) -> dict | None:
    """Mark a comment as an answer in a question and answer community.

    API endpoint: POST comment/mark_as_answer

    Args:
        comment_reply_id (int): Comment id being marked as an answer.
        answer (bool): True to mark it as an answer. False to unmark it.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_reply_id": comment_reply_id, "answer": answer}

    return self._client.request(method="POST", endpoint="comment/mark_as_answer", data=data)

mark_as_read(comment_reply_id, read)

Mark a comment as read or unread.

API endpoint: POST comment/mark_as_read

Parameters:

Name Type Description Default
comment_reply_id int

Comment id being marked as read or unread.

required
read bool

True to mark as read. False to mark as unread.

required

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
def mark_as_read(self, comment_reply_id: int, read: bool) -> dict | None:
    """Mark a comment as read or unread.

    API endpoint: POST comment/mark_as_read

    Args:
        comment_reply_id (int): Comment id being marked as read or unread.
        read (bool): True to mark as read. False to mark as unread.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_reply_id": comment_reply_id, "read": read}

    return self._client.request(method="POST", endpoint="comment/mark_as_read", data=data)

remove(comment_id, removed, reason=None)

Remove a comment as a moderator/admin.

API endpoint: POST comment/remove

Parameters:

Name Type Description Default
comment_id int

Comment id of the comment being removed.

required
removed bool

True to remove the comment. False to restore it.

required
reason str | None

Reason for removal. Defaults to None.

None

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
def remove(self, comment_id: int, removed: bool, reason: str | None = None) -> dict | None:
    """Remove a comment as a moderator/admin.

    API endpoint: POST comment/remove

    Args:
        comment_id (int): Comment id of the comment being removed.
        removed (bool): True to remove the comment. False to restore it.
        reason (str | None, optional): Reason for removal. Defaults to None.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_id": comment_id, "removed": removed}

    if reason is not None:
        data["reason"] = reason

    return self._client.request(method="POST", endpoint="comment/remove", data=data)

report(comment_id, reason, description=None, report_remote=None)

Report a comment to moderators/admins.

API endpoint: POST comment/report

Parameters:

Name Type Description Default
comment_id int

Comment id to report.

required
reason str

Reason for the report.

required
description str | None

Additional details to provide with the report. Defaults to None.

None
report_remote bool | None

Forward report to the author's remote admins if applicable. Defaults to None.

None

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
def report(
    self,
    comment_id: int,
    reason: str,
    description: str | None = None,
    report_remote: bool | None = None,
) -> dict | None:
    """Report a comment to moderators/admins.

    API endpoint: POST comment/report

    Args:
        comment_id (int): Comment id to report.
        reason (str): Reason for the report.
        description (str | None, optional): Additional details to provide with the report. Defaults to None.
        report_remote (bool | None, optional): Forward report to the author's remote admins if applicable. Defaults
            to None.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_id": comment_id, "reason": reason}

    if description is not None:
        data["description"] = description
    if report_remote is not None:
        data["report_remote"] = report_remote

    return self._client.request(method="POST", endpoint="comment/report", data=data)

resolve_report(report_id, resolved)

Resolve a report.

API endpoint: PUT comment/report/resolve

Parameters:

Name Type Description Default
report_id int

Report id that is being resolved (or unresolved).

required
resolved bool

True to resolve the report. False to unresolve it.

required

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
def resolve_report(self, report_id: int, resolved: bool) -> dict | None:
    """Resolve a report.

    API endpoint: PUT comment/report/resolve

    Args:
        report_id (int): Report id that is being resolved (or unresolved).
        resolved (bool): True to resolve the report. False to unresolve it.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"report_id": report_id, "resolved": resolved}

    return self._client.request(method="PUT", endpoint="comment/report/resolve", data=data)

save(comment_id, save)

Save a comment.

API endpoint: PUT comment/save

Parameters:

Name Type Description Default
comment_id int

Comment id being saved.

required
save bool

True to save. False to remove from saved.

required

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
def save(self, comment_id: int, save: bool) -> dict | None:
    """Save a comment.

    API endpoint: PUT comment/save

    Args:
        comment_id (int): Comment id being saved.
        save (bool): True to save. False to remove from saved.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_id": comment_id, "save": save}

    return self._client.request(method="PUT", endpoint="comment/save", data=data)

subscribe(comment_id, subscribe)

Get notified of new replies to a comment.

API endpoint: PUT comment/subscribe

Parameters:

Name Type Description Default
comment_id int

Comment id to subscribe to.

required
subscribe bool

True to subscribe. False to remove subscription.

required

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
def subscribe(self, comment_id: int, subscribe: bool) -> dict | None:
    """Get notified of new replies to a comment.

    API endpoint: PUT comment/subscribe

    Args:
        comment_id (int): Comment id to subscribe to.
        subscribe (bool): True to subscribe. False to remove subscription.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_id": comment_id, "subscribe": subscribe}

    return self._client.request(method="PUT", endpoint="comment/subscribe", data=data)

CommentAsync

Class to hold async Comment endpoints.

Source code in pieforhead/comment.py
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
class CommentAsync:
    """Class to hold async Comment endpoints."""

    def __init__(self, client: AsyncPieFedClient):
        self._client = client

    async def list_comments(
        self,
        limit: int | None = None,
        page: int | None = None,
        sort: str | None = None,
        type_: str | None = None,
        liked_only: bool | None = None,
        saved_only: bool | None = None,
        person_id: int | None = None,
        community_id: int | None = None,
        post_id: int | None = None,
        parent_id: int | None = None,
        max_depth: int | None = None,
        depth_first: bool | None = None,
    ) -> dict | None:
        """Get list of comments.

        API endpoint: GET comment/list

        Args:
            limit (int | None, optional): Max number to return for a page of results. Defaults to None.
            page (int | None, optional): Page of results to request. Defaults to None.
            sort (str | None, optional): Sorting method for the returned comments. Defaults to None.
            type_ (str | None, optional): Type filter (Subscribed, Local, etc.). Defaults to None.
            liked_only (bool | None, optional): Only return liked comments. Defaults to None.
            saved_only (bool | None, optional): Only return saved comments. Defaults to None.
            person_id (int | None, optional): Filter to comments by a specific user. Defaults to None.
            community_id (int | None, optional): Filter to comments in a specific community. Defaults to None.
            post_id (int | None, optional): Filter to comments on a specific post. Defaults to None.
            parent_id (int | None, optional): Filter to replies to a specific comment. Defaults to None.
            max_depth (int | None, optional): Max number of nested levels to return. Defaults to None.
            depth_first (bool | None, optional): Guarantee parent comments are on the same page as any fetched comments.
                Defaults to None.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        params = {}

        if limit is not None:
            params["limit"] = limit
        if page is not None:
            params["page"] = page
        if sort is not None:
            params["sort"] = sort
        if type_ is not None:
            params["type_"] = type_
        if liked_only is not None:
            params["liked_only"] = liked_only
        if saved_only is not None:
            params["saved_only"] = saved_only
        if person_id is not None:
            params["person_id"] = person_id
        if community_id is not None:
            params["community_id"] = community_id
        if post_id is not None:
            params["post_id"] = post_id
        if parent_id is not None:
            params["parent_id"] = parent_id
        if max_depth is not None:
            params["max_depth"] = max_depth
        if depth_first is not None:
            params["depth_first"] = depth_first

        return await self._client.request(method="GET", endpoint="comment/list", params=params)

    async def get(self, comment_id: int) -> dict | None:
        """Get info for a single comment.

        API endpoint: GET comment

        Args:
            comment_id (int): Comment id of the comment to retrieve.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        return await self._client.request(method="GET", endpoint="comment", params={"id": comment_id})

    async def create(
        self,
        body: str,
        post_id: int,
        parent_id: int | None = None,
        language_id: int | None = None,
    ) -> dict | None:
        """Create a comment.

        API endpoint: POST comment

        Args:
            body (str): Content of the comment in markdown.
            post_id (int): Post id that the comment is replying to.
            parent_id (int | None, optional): Parent comment id if the comment is a reply to another comment. Defaults
                to None.
            language_id (int | None, optional): Language id of the comment. Defaults to None.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"body": body, "post_id": post_id}

        if parent_id is not None:
            data["parent_id"] = parent_id
        if language_id is not None:
            data["language_id"] = language_id

        return await self._client.request(method="POST", endpoint="comment", data=data)

    async def edit(
        self,
        comment_id: int,
        body: str,
        language_id: int | None = None,
        distinguished: bool | None = None,
    ) -> dict | None:
        """Edit a comment

        API endpoint: PUT comment

        Args:
            comment_id (int): The comment id of the comment to edit.
            body (str): New, edited content of the body in markdown.
            language_id (int | None, optional): Language id of the comment. Defaults to None.
            distinguished (bool | None, optional): Distinguish the comment as written by a moderator. Defaults to None.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_id": comment_id, "body": body}

        if language_id is not None:
            data["language_id"] = language_id
        if distinguished is not None:
            data["distinguished"] = distinguished

        return await self._client.request(method="PUT", endpoint="comment", data=data)

    async def like(
        self, comment_id: int, score: int, private: bool | None = None, emoji: str | None = None
    ) -> dict | None:
        """Vote on a comment.

        API endpoint: POST comment/like

        Args:
            comment_id (int): Comment id being voted on.
            score (int): 1 and -1 for up/down vote respectively. 0 to undo a vote.
            private (bool | None, optional): Should this vote be federated? Defaults to None.
            emoji (str | None, optional): Emoji reaction to include with vote if desired. Defaults to None.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_id": comment_id, "score": score}

        if private is not None:
            data["private"] = private
        if emoji is not None:
            data["emoji"] = emoji

        return await self._client.request(method="POST", endpoint="comment/like", data=data)

    async def save(self, comment_id: int, save: bool) -> dict | None:
        """Save a comment.

        API endpoint: PUT comment/save

        Args:
            comment_id (int): Comment id being saved.
            save (bool): True to save. False to remove from saved.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_id": comment_id, "save": save}

        return await self._client.request(method="PUT", endpoint="comment/save", data=data)

    async def subscribe(self, comment_id: int, subscribe: bool) -> dict | None:
        """Get notified of new replies to a comment.

        API endpoint: PUT comment/subscribe

        Args:
            comment_id (int): Comment id to subscribe to.
            subscribe (bool): True to subscribe. False to remove subscription.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_id": comment_id, "subscribe": subscribe}

        return await self._client.request(method="PUT", endpoint="comment/subscribe", data=data)

    async def delete(self, comment_id: int, deleted: bool) -> dict | None:
        """Delete a comment.

        API endpoint: POST comment/delete

        Args:
            comment_id (int): Comment id of the comment being deleted.
            deleted (bool): True to delete the comment. False to restore it.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_id": comment_id, "deleted": deleted}

        return await self._client.request(method="POST", endpoint="comment/delete", data=data)

    async def report(
        self,
        comment_id: int,
        reason: str,
        description: str | None = None,
        report_remote: bool | None = None,
    ) -> dict | None:
        """Report a comment to moderators/admins.

        API endpoint: POST comment/report

        Args:
            comment_id (int): Comment id to report.
            reason (str): Reason for the report.
            description (str | None, optional): Additional details to provide with the report. Defaults to None.
            report_remote (bool | None, optional): Forward report to the author's remote admins if applicable. Defaults
                to None.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_id": comment_id, "reason": reason}

        if description is not None:
            data["description"] = description
        if report_remote is not None:
            data["report_remote"] = report_remote

        return await self._client.request(method="POST", endpoint="comment/report", data=data)

    async def list_reports(
        self,
        comment_id: int | None = None,
        community_id: int | None = None,
        limit: int | None = None,
        page: int | None = None,
        unresolved_only: bool | None = None,
    ) -> dict | None:
        """List comment reports.

        API endpoint: GET comment/report/list

        Args:
            comment_id (int | None, optional): Filter reports to a single comment by id. Defaults to None.
            community_id (int | None, optional): Filter reports to a single community by id. Defaults to None.
            limit (int | None, optional): Max number of reports per page. Defaults to None.
            page (int | None, optional): Page number to request. Defaults to None.
            unresolved_only (bool | None, optional): Only return unresolved reports. Defaults to None.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        params = {}

        if comment_id is not None:
            params["comment_id"] = comment_id
        if community_id is not None:
            params["community_id"] = community_id
        if limit is not None:
            params["limit"] = limit
        if page is not None:
            params["page"] = page
        if unresolved_only is not None:
            params["unresolved_only"] = unresolved_only

        return await self._client.request(method="GET", endpoint="comment/report/list", params=params)

    async def resolve_report(self, report_id: int, resolved: bool) -> dict | None:
        """Resolve a report.

        API endpoint: PUT comment/report/resolve

        Args:
            report_id (int): Report id that is being resolved (or unresolved).
            resolved (bool): True to resolve the report. False to unresolve it.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"report_id": report_id, "resolved": resolved}

        return await self._client.request(method="PUT", endpoint="comment/report/resolve", data=data)

    async def remove(self, comment_id: int, removed: bool, reason: str | None = None) -> dict | None:
        """Remove a comment as a moderator/admin.

        API endpoint: POST comment/remove

        Args:
            comment_id (int): Comment id of the comment being removed.
            removed (bool): True to remove the comment. False to restore it.
            reason (str | None, optional): Reason for removal. Defaults to None.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_id": comment_id, "removed": removed}

        if reason is not None:
            data["reason"] = reason

        return await self._client.request(method="POST", endpoint="comment/remove", data=data)

    async def mark_as_read(self, comment_reply_id: int, read: bool) -> dict | None:
        """Mark a comment as read or unread.

        API endpoint: POST comment/mark_as_read

        Args:
            comment_reply_id (int): Comment id being marked as read or unread.
            read (bool): True to mark as read. False to mark as unread.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_reply_id": comment_reply_id, "read": read}

        return await self._client.request(method="POST", endpoint="comment/mark_as_read", data=data)

    async def mark_as_answer(self, comment_reply_id: int, answer: bool) -> dict | None:
        """Mark a comment as an answer in a question and answer community.

        API endpoint: POST comment/mark_as_answer

        Args:
            comment_reply_id (int): Comment id being marked as an answer.
            answer (bool): True to mark it as an answer. False to unmark it.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_reply_id": comment_reply_id, "answer": answer}

        return await self._client.request(method="POST", endpoint="comment/mark_as_answer", data=data)

    async def distinguish(self, comment_reply_id: int, distinguished: bool) -> dict | None:
        """Mark or unmark a comment as being spoken by a moderator.

        API endpoint: POST comment/distinguish

        Args:
            comment_reply_id (int): Comment id being distinguished.
            distinguished (bool): True to distinguish the comment. False to undistinguish it.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_reply_id": comment_reply_id, "distinguished": distinguished}

        return await self._client.request(method="POST", endpoint="comment/distinguish", data=data)

    async def lock(self, comment_id: int, locked: bool) -> dict | None:
        """Lock a comment chain, preventing further replies.

        API endpoint: POST comment/lock

        Args:
            comment_id (int): Comment id of comment being locked.
            locked (bool): True to lock the comment. False to unlock it.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        data = {"comment_id": comment_id, "locked": locked}

        return await self._client.request(method="POST", endpoint="comment/lock", data=data)

    async def list_likes(self, comment_id: int, page: int | None = None, limit: int | None = None) -> dict | None:
        """List the votes on a comment.

        API endpoint: GET comment/like/list

        Args:
            comment_id (int): Comment id of the comment votes being fetched.
            page (int | None, optional): Page number of the results to fetch. Defaults to None.
            limit (int | None, optional): Max number of votes on each page of results. Defaults to None.

        Returns:
            dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
                was raised and then subsequently ignored.
        """
        params = {"comment_id": comment_id}

        if page is not None:
            params["page"] = page
        if limit is not None:
            params["limit"] = limit

        return await self._client.request(method="GET", endpoint="comment/like/list", params=params)

create(body, post_id, parent_id=None, language_id=None) async

Create a comment.

API endpoint: POST comment

Parameters:

Name Type Description Default
body str

Content of the comment in markdown.

required
post_id int

Post id that the comment is replying to.

required
parent_id int | None

Parent comment id if the comment is a reply to another comment. Defaults to None.

None
language_id int | None

Language id of the comment. Defaults to None.

None

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
async def create(
    self,
    body: str,
    post_id: int,
    parent_id: int | None = None,
    language_id: int | None = None,
) -> dict | None:
    """Create a comment.

    API endpoint: POST comment

    Args:
        body (str): Content of the comment in markdown.
        post_id (int): Post id that the comment is replying to.
        parent_id (int | None, optional): Parent comment id if the comment is a reply to another comment. Defaults
            to None.
        language_id (int | None, optional): Language id of the comment. Defaults to None.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"body": body, "post_id": post_id}

    if parent_id is not None:
        data["parent_id"] = parent_id
    if language_id is not None:
        data["language_id"] = language_id

    return await self._client.request(method="POST", endpoint="comment", data=data)

delete(comment_id, deleted) async

Delete a comment.

API endpoint: POST comment/delete

Parameters:

Name Type Description Default
comment_id int

Comment id of the comment being deleted.

required
deleted bool

True to delete the comment. False to restore it.

required

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
async def delete(self, comment_id: int, deleted: bool) -> dict | None:
    """Delete a comment.

    API endpoint: POST comment/delete

    Args:
        comment_id (int): Comment id of the comment being deleted.
        deleted (bool): True to delete the comment. False to restore it.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_id": comment_id, "deleted": deleted}

    return await self._client.request(method="POST", endpoint="comment/delete", data=data)

distinguish(comment_reply_id, distinguished) async

Mark or unmark a comment as being spoken by a moderator.

API endpoint: POST comment/distinguish

Parameters:

Name Type Description Default
comment_reply_id int

Comment id being distinguished.

required
distinguished bool

True to distinguish the comment. False to undistinguish it.

required

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
async def distinguish(self, comment_reply_id: int, distinguished: bool) -> dict | None:
    """Mark or unmark a comment as being spoken by a moderator.

    API endpoint: POST comment/distinguish

    Args:
        comment_reply_id (int): Comment id being distinguished.
        distinguished (bool): True to distinguish the comment. False to undistinguish it.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_reply_id": comment_reply_id, "distinguished": distinguished}

    return await self._client.request(method="POST", endpoint="comment/distinguish", data=data)

edit(comment_id, body, language_id=None, distinguished=None) async

Edit a comment

API endpoint: PUT comment

Parameters:

Name Type Description Default
comment_id int

The comment id of the comment to edit.

required
body str

New, edited content of the body in markdown.

required
language_id int | None

Language id of the comment. Defaults to None.

None
distinguished bool | None

Distinguish the comment as written by a moderator. Defaults to None.

None

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
async def edit(
    self,
    comment_id: int,
    body: str,
    language_id: int | None = None,
    distinguished: bool | None = None,
) -> dict | None:
    """Edit a comment

    API endpoint: PUT comment

    Args:
        comment_id (int): The comment id of the comment to edit.
        body (str): New, edited content of the body in markdown.
        language_id (int | None, optional): Language id of the comment. Defaults to None.
        distinguished (bool | None, optional): Distinguish the comment as written by a moderator. Defaults to None.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_id": comment_id, "body": body}

    if language_id is not None:
        data["language_id"] = language_id
    if distinguished is not None:
        data["distinguished"] = distinguished

    return await self._client.request(method="PUT", endpoint="comment", data=data)

get(comment_id) async

Get info for a single comment.

API endpoint: GET comment

Parameters:

Name Type Description Default
comment_id int

Comment id of the comment to retrieve.

required

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
async def get(self, comment_id: int) -> dict | None:
    """Get info for a single comment.

    API endpoint: GET comment

    Args:
        comment_id (int): Comment id of the comment to retrieve.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    return await self._client.request(method="GET", endpoint="comment", params={"id": comment_id})

like(comment_id, score, private=None, emoji=None) async

Vote on a comment.

API endpoint: POST comment/like

Parameters:

Name Type Description Default
comment_id int

Comment id being voted on.

required
score int

1 and -1 for up/down vote respectively. 0 to undo a vote.

required
private bool | None

Should this vote be federated? Defaults to None.

None
emoji str | None

Emoji reaction to include with vote if desired. Defaults to None.

None

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
async def like(
    self, comment_id: int, score: int, private: bool | None = None, emoji: str | None = None
) -> dict | None:
    """Vote on a comment.

    API endpoint: POST comment/like

    Args:
        comment_id (int): Comment id being voted on.
        score (int): 1 and -1 for up/down vote respectively. 0 to undo a vote.
        private (bool | None, optional): Should this vote be federated? Defaults to None.
        emoji (str | None, optional): Emoji reaction to include with vote if desired. Defaults to None.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_id": comment_id, "score": score}

    if private is not None:
        data["private"] = private
    if emoji is not None:
        data["emoji"] = emoji

    return await self._client.request(method="POST", endpoint="comment/like", data=data)

list_comments(limit=None, page=None, sort=None, type_=None, liked_only=None, saved_only=None, person_id=None, community_id=None, post_id=None, parent_id=None, max_depth=None, depth_first=None) async

Get list of comments.

API endpoint: GET comment/list

Parameters:

Name Type Description Default
limit int | None

Max number to return for a page of results. Defaults to None.

None
page int | None

Page of results to request. Defaults to None.

None
sort str | None

Sorting method for the returned comments. Defaults to None.

None
type_ str | None

Type filter (Subscribed, Local, etc.). Defaults to None.

None
liked_only bool | None

Only return liked comments. Defaults to None.

None
saved_only bool | None

Only return saved comments. Defaults to None.

None
person_id int | None

Filter to comments by a specific user. Defaults to None.

None
community_id int | None

Filter to comments in a specific community. Defaults to None.

None
post_id int | None

Filter to comments on a specific post. Defaults to None.

None
parent_id int | None

Filter to replies to a specific comment. Defaults to None.

None
max_depth int | None

Max number of nested levels to return. Defaults to None.

None
depth_first bool | None

Guarantee parent comments are on the same page as any fetched comments. Defaults to None.

None

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
async def list_comments(
    self,
    limit: int | None = None,
    page: int | None = None,
    sort: str | None = None,
    type_: str | None = None,
    liked_only: bool | None = None,
    saved_only: bool | None = None,
    person_id: int | None = None,
    community_id: int | None = None,
    post_id: int | None = None,
    parent_id: int | None = None,
    max_depth: int | None = None,
    depth_first: bool | None = None,
) -> dict | None:
    """Get list of comments.

    API endpoint: GET comment/list

    Args:
        limit (int | None, optional): Max number to return for a page of results. Defaults to None.
        page (int | None, optional): Page of results to request. Defaults to None.
        sort (str | None, optional): Sorting method for the returned comments. Defaults to None.
        type_ (str | None, optional): Type filter (Subscribed, Local, etc.). Defaults to None.
        liked_only (bool | None, optional): Only return liked comments. Defaults to None.
        saved_only (bool | None, optional): Only return saved comments. Defaults to None.
        person_id (int | None, optional): Filter to comments by a specific user. Defaults to None.
        community_id (int | None, optional): Filter to comments in a specific community. Defaults to None.
        post_id (int | None, optional): Filter to comments on a specific post. Defaults to None.
        parent_id (int | None, optional): Filter to replies to a specific comment. Defaults to None.
        max_depth (int | None, optional): Max number of nested levels to return. Defaults to None.
        depth_first (bool | None, optional): Guarantee parent comments are on the same page as any fetched comments.
            Defaults to None.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    params = {}

    if limit is not None:
        params["limit"] = limit
    if page is not None:
        params["page"] = page
    if sort is not None:
        params["sort"] = sort
    if type_ is not None:
        params["type_"] = type_
    if liked_only is not None:
        params["liked_only"] = liked_only
    if saved_only is not None:
        params["saved_only"] = saved_only
    if person_id is not None:
        params["person_id"] = person_id
    if community_id is not None:
        params["community_id"] = community_id
    if post_id is not None:
        params["post_id"] = post_id
    if parent_id is not None:
        params["parent_id"] = parent_id
    if max_depth is not None:
        params["max_depth"] = max_depth
    if depth_first is not None:
        params["depth_first"] = depth_first

    return await self._client.request(method="GET", endpoint="comment/list", params=params)

list_likes(comment_id, page=None, limit=None) async

List the votes on a comment.

API endpoint: GET comment/like/list

Parameters:

Name Type Description Default
comment_id int

Comment id of the comment votes being fetched.

required
page int | None

Page number of the results to fetch. Defaults to None.

None
limit int | None

Max number of votes on each page of results. Defaults to None.

None

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
async def list_likes(self, comment_id: int, page: int | None = None, limit: int | None = None) -> dict | None:
    """List the votes on a comment.

    API endpoint: GET comment/like/list

    Args:
        comment_id (int): Comment id of the comment votes being fetched.
        page (int | None, optional): Page number of the results to fetch. Defaults to None.
        limit (int | None, optional): Max number of votes on each page of results. Defaults to None.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    params = {"comment_id": comment_id}

    if page is not None:
        params["page"] = page
    if limit is not None:
        params["limit"] = limit

    return await self._client.request(method="GET", endpoint="comment/like/list", params=params)

list_reports(comment_id=None, community_id=None, limit=None, page=None, unresolved_only=None) async

List comment reports.

API endpoint: GET comment/report/list

Parameters:

Name Type Description Default
comment_id int | None

Filter reports to a single comment by id. Defaults to None.

None
community_id int | None

Filter reports to a single community by id. Defaults to None.

None
limit int | None

Max number of reports per page. Defaults to None.

None
page int | None

Page number to request. Defaults to None.

None
unresolved_only bool | None

Only return unresolved reports. Defaults to None.

None

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
async def list_reports(
    self,
    comment_id: int | None = None,
    community_id: int | None = None,
    limit: int | None = None,
    page: int | None = None,
    unresolved_only: bool | None = None,
) -> dict | None:
    """List comment reports.

    API endpoint: GET comment/report/list

    Args:
        comment_id (int | None, optional): Filter reports to a single comment by id. Defaults to None.
        community_id (int | None, optional): Filter reports to a single community by id. Defaults to None.
        limit (int | None, optional): Max number of reports per page. Defaults to None.
        page (int | None, optional): Page number to request. Defaults to None.
        unresolved_only (bool | None, optional): Only return unresolved reports. Defaults to None.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    params = {}

    if comment_id is not None:
        params["comment_id"] = comment_id
    if community_id is not None:
        params["community_id"] = community_id
    if limit is not None:
        params["limit"] = limit
    if page is not None:
        params["page"] = page
    if unresolved_only is not None:
        params["unresolved_only"] = unresolved_only

    return await self._client.request(method="GET", endpoint="comment/report/list", params=params)

lock(comment_id, locked) async

Lock a comment chain, preventing further replies.

API endpoint: POST comment/lock

Parameters:

Name Type Description Default
comment_id int

Comment id of comment being locked.

required
locked bool

True to lock the comment. False to unlock it.

required

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
async def lock(self, comment_id: int, locked: bool) -> dict | None:
    """Lock a comment chain, preventing further replies.

    API endpoint: POST comment/lock

    Args:
        comment_id (int): Comment id of comment being locked.
        locked (bool): True to lock the comment. False to unlock it.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_id": comment_id, "locked": locked}

    return await self._client.request(method="POST", endpoint="comment/lock", data=data)

mark_as_answer(comment_reply_id, answer) async

Mark a comment as an answer in a question and answer community.

API endpoint: POST comment/mark_as_answer

Parameters:

Name Type Description Default
comment_reply_id int

Comment id being marked as an answer.

required
answer bool

True to mark it as an answer. False to unmark it.

required

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
async def mark_as_answer(self, comment_reply_id: int, answer: bool) -> dict | None:
    """Mark a comment as an answer in a question and answer community.

    API endpoint: POST comment/mark_as_answer

    Args:
        comment_reply_id (int): Comment id being marked as an answer.
        answer (bool): True to mark it as an answer. False to unmark it.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_reply_id": comment_reply_id, "answer": answer}

    return await self._client.request(method="POST", endpoint="comment/mark_as_answer", data=data)

mark_as_read(comment_reply_id, read) async

Mark a comment as read or unread.

API endpoint: POST comment/mark_as_read

Parameters:

Name Type Description Default
comment_reply_id int

Comment id being marked as read or unread.

required
read bool

True to mark as read. False to mark as unread.

required

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
async def mark_as_read(self, comment_reply_id: int, read: bool) -> dict | None:
    """Mark a comment as read or unread.

    API endpoint: POST comment/mark_as_read

    Args:
        comment_reply_id (int): Comment id being marked as read or unread.
        read (bool): True to mark as read. False to mark as unread.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_reply_id": comment_reply_id, "read": read}

    return await self._client.request(method="POST", endpoint="comment/mark_as_read", data=data)

remove(comment_id, removed, reason=None) async

Remove a comment as a moderator/admin.

API endpoint: POST comment/remove

Parameters:

Name Type Description Default
comment_id int

Comment id of the comment being removed.

required
removed bool

True to remove the comment. False to restore it.

required
reason str | None

Reason for removal. Defaults to None.

None

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
async def remove(self, comment_id: int, removed: bool, reason: str | None = None) -> dict | None:
    """Remove a comment as a moderator/admin.

    API endpoint: POST comment/remove

    Args:
        comment_id (int): Comment id of the comment being removed.
        removed (bool): True to remove the comment. False to restore it.
        reason (str | None, optional): Reason for removal. Defaults to None.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_id": comment_id, "removed": removed}

    if reason is not None:
        data["reason"] = reason

    return await self._client.request(method="POST", endpoint="comment/remove", data=data)

report(comment_id, reason, description=None, report_remote=None) async

Report a comment to moderators/admins.

API endpoint: POST comment/report

Parameters:

Name Type Description Default
comment_id int

Comment id to report.

required
reason str

Reason for the report.

required
description str | None

Additional details to provide with the report. Defaults to None.

None
report_remote bool | None

Forward report to the author's remote admins if applicable. Defaults to None.

None

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
async def report(
    self,
    comment_id: int,
    reason: str,
    description: str | None = None,
    report_remote: bool | None = None,
) -> dict | None:
    """Report a comment to moderators/admins.

    API endpoint: POST comment/report

    Args:
        comment_id (int): Comment id to report.
        reason (str): Reason for the report.
        description (str | None, optional): Additional details to provide with the report. Defaults to None.
        report_remote (bool | None, optional): Forward report to the author's remote admins if applicable. Defaults
            to None.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_id": comment_id, "reason": reason}

    if description is not None:
        data["description"] = description
    if report_remote is not None:
        data["report_remote"] = report_remote

    return await self._client.request(method="POST", endpoint="comment/report", data=data)

resolve_report(report_id, resolved) async

Resolve a report.

API endpoint: PUT comment/report/resolve

Parameters:

Name Type Description Default
report_id int

Report id that is being resolved (or unresolved).

required
resolved bool

True to resolve the report. False to unresolve it.

required

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
async def resolve_report(self, report_id: int, resolved: bool) -> dict | None:
    """Resolve a report.

    API endpoint: PUT comment/report/resolve

    Args:
        report_id (int): Report id that is being resolved (or unresolved).
        resolved (bool): True to resolve the report. False to unresolve it.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"report_id": report_id, "resolved": resolved}

    return await self._client.request(method="PUT", endpoint="comment/report/resolve", data=data)

save(comment_id, save) async

Save a comment.

API endpoint: PUT comment/save

Parameters:

Name Type Description Default
comment_id int

Comment id being saved.

required
save bool

True to save. False to remove from saved.

required

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
async def save(self, comment_id: int, save: bool) -> dict | None:
    """Save a comment.

    API endpoint: PUT comment/save

    Args:
        comment_id (int): Comment id being saved.
        save (bool): True to save. False to remove from saved.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_id": comment_id, "save": save}

    return await self._client.request(method="PUT", endpoint="comment/save", data=data)

subscribe(comment_id, subscribe) async

Get notified of new replies to a comment.

API endpoint: PUT comment/subscribe

Parameters:

Name Type Description Default
comment_id int

Comment id to subscribe to.

required
subscribe bool

True to subscribe. False to remove subscription.

required

Returns:

Type Description
dict | None

dict | None: dict containing the deserialized json returned by the server. None is returned if an exception was raised and then subsequently ignored.

Source code in pieforhead/comment.py
async def subscribe(self, comment_id: int, subscribe: bool) -> dict | None:
    """Get notified of new replies to a comment.

    API endpoint: PUT comment/subscribe

    Args:
        comment_id (int): Comment id to subscribe to.
        subscribe (bool): True to subscribe. False to remove subscription.

    Returns:
        dict | None: dict containing the deserialized json returned by the server. None is returned if an exception
            was raised and then subsequently ignored.
    """
    data = {"comment_id": comment_id, "subscribe": subscribe}

    return await self._client.request(method="PUT", endpoint="comment/subscribe", data=data)