Class CommentApiClientModule

java.lang.Object
io.github.evisentin.wordpress.client.adapter.apache.modules.CommentApiClientModule
All Implemented Interfaces:
CommentAPIs

public class CommentApiClientModule extends Object implements CommentAPIs
Apache HttpClient implementation of CommentAPIs.

Provides access to WordPress comment resources through the /wp/v2/comments endpoint, including support for password-protected content and comment trashing.

  • Constructor Details

    • CommentApiClientModule

      public CommentApiClientModule(@NonNull @NonNull String apiUrl, @NonNull @NonNull org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient, @NonNull @NonNull com.fasterxml.jackson.databind.ObjectMapper mapper)
  • Method Details

    • create

      public WpComment create(@NonNull @NonNull WpCommentCreateUpdateRequest creationRequest)
      Description copied from interface: CommentAPIs
      Creates a new comment.

      Creates a comment in WordPress using the provided request payload.

      Specified by:
      create in interface CommentAPIs
      Parameters:
      creationRequest - the comment creation request; must not be null
      Returns:
      the created WpComment
    • delete

      public WpCommentDeletionResponse delete(long id)
      Description copied from interface: CommentAPIs
      Permanently deletes a comment by its unique identifier.
      Specified by:
      delete in interface CommentAPIs
      Parameters:
      id - the ID of the comment to delete
      Returns:
      the comment deletion response
    • get

      public WpComment get(long id, WpContext context)
      Description copied from interface: CommentAPIs
      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, or WpContext.EMBED.

      Specified by:
      get in interface CommentAPIs
      Parameters:
      id - the ID of the comment to retrieve
      context - the retrieval context; may be null, in which case WpContext.VIEW is used
      Returns:
      the matching WpComment
    • get

      public WpComment get(long id, WpContext context, String password)
      Description copied from interface: CommentAPIs
      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, or WpContext.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.

      Specified by:
      get in interface CommentAPIs
      Parameters:
      id - the ID of the comment to retrieve
      context - the retrieval context; may be null, in which case WpContext.VIEW is used
      password - the password for protected content; may be null when not required
      Returns:
      the matching WpComment
    • list

      public WpPagedResponse<WpComment> list(@NonNull @NonNull WpPagingQuery pageQuery, WpCommentQuery commentQuery)
      Description copied from interface: CommentAPIs
      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.

      Specified by:
      list in interface CommentAPIs
      Parameters:
      pageQuery - the pagination settings, including page number and page size; must not be null
      commentQuery - additional comment query parameters; may be null when no extra filtering is needed
      Returns:
      a paginated response containing WpComment items
    • trash

      public WpComment trash(long id)
      Description copied from interface: CommentAPIs
      Moves a comment to the trash by its unique identifier.
      Specified by:
      trash in interface CommentAPIs
      Parameters:
      id - the ID of the comment to trash
      Returns:
      the trashed WpComment
    • update

      public WpComment update(long id, @NonNull @NonNull WpCommentCreateUpdateRequest updateRequest)
      Description copied from interface: CommentAPIs
      Updates an existing comment.

      Updates a comment in WordPress using the provided request payload.

      Specified by:
      update in interface CommentAPIs
      Parameters:
      id - the ID of the comment to update
      updateRequest - the comment update request; must not be null
      Returns:
      the updated WpComment