Interface CommentOperations
- All Known Subinterfaces:
WpRestClient
- All Known Implementing Classes:
ApacheWpRestClient,WpBaseRestClient
This interface provides methods for creating, retrieving, updating, listing, trashing, and deleting
WpComment resources.
Operations support standard WordPress REST API features such as pagination, filtering, retrieval contexts, password-protected content, and partial querying.
Implementations are expected to communicate with the /wp-json/wp/v2/comments endpoint or compatible
APIs.
-
Method Summary
Modifier and TypeMethodDescriptioncreateComment(@NonNull WpCommentCreateUpdateRequest creationRequest) Creates a new comment.deleteComment(long id) Permanently deletes a comment by its unique identifier.getComment(long id, WpContext context) Retrieves a comment by its unique identifier using the given context.getComment(long id, WpContext context, String password) Retrieves a comment by its unique identifier using the given context and optional password.listComments(@NonNull WpPagingQuery pageQuery, WpCommentQuery commentQuery) Retrieves a paginated list of comments using optional filtering and sorting criteria.trashComment(long id) Moves a comment to the trash by its unique identifier.updateComment(long id, @NonNull WpCommentCreateUpdateRequest updateRequest) Updates an existing comment.
-
Method Details
-
createComment
Creates a new comment.Creates a comment in WordPress using the provided request payload.
- Parameters:
creationRequest- the comment creation request; must not benull- Returns:
- the created
WpComment
-
deleteComment
Permanently deletes a comment by its unique identifier.- Parameters:
id- the ID of the comment to delete- Returns:
- the comment deletion response
-
getComment
Retrieves a comment by its unique identifier using the given context.The context determines which fields are included in the response, for example
WpContext.VIEW,WpContext.EDIT, orWpContext.EMBED.- Parameters:
id- the ID of the comment to retrievecontext- the retrieval context; may benull, in which caseWpContext.VIEWis used- Returns:
- the matching
WpComment
-
getComment
Retrieves a comment by its unique identifier using the given context and optional password.The context determines which fields are included in the response, for example
WpContext.VIEW,WpContext.EDIT, orWpContext.EMBED.If the comment is password protected, the provided password is used to access protected content. If the password is missing or incorrect, protected fields such as content may be omitted or flagged as protected in the response.
- Parameters:
id- the ID of the comment to retrievecontext- the retrieval context; may benull, in which caseWpContext.VIEWis usedpassword- the password for protected content; may benullwhen not required- Returns:
- the matching
WpComment
-
listComments
WpPagedResponse<WpComment> listComments(@NonNull @NonNull WpPagingQuery pageQuery, WpCommentQuery commentQuery) Retrieves a paginated list of comments using optional filtering and sorting criteria.The result set can be refined using
WpCommentQuery, for example by filtering on search criteria, include or exclude lists, or sort order.- Parameters:
pageQuery- the pagination settings, including page number and page size; must not benullcommentQuery- additional comment query parameters; may benullwhen no extra filtering is needed- Returns:
- a paginated response containing
WpCommentitems
-
trashComment
Moves a comment to the trash by its unique identifier.- Parameters:
id- the ID of the comment to trash- Returns:
- the trashed
WpComment
-
updateComment
Updates an existing comment.Updates a comment in WordPress using the provided request payload.
- Parameters:
id- the ID of the comment to updateupdateRequest- the post update request; must not benull- Returns:
- the updated
WpComment
-