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

public class PostApiClientModule extends Object implements PostAPIs
Apache HttpClient implementation of PostAPIs.

Provides access to WordPress post resources through the /wp/v2/posts endpoint, including support for password-protected content and trash operations.

  • Constructor Details

    • PostApiClientModule

      public PostApiClientModule(@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 WpPost create(@NonNull @NonNull WpPostCreateUpdateRequest creationRequest)
      Description copied from interface: PostAPIs
      Creates a new post.

      Creates a post in WordPress using the provided request payload.

      Specified by:
      create in interface PostAPIs
      Parameters:
      creationRequest - the post creation request; must not be null
      Returns:
      the created WpPost
    • delete

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

      public WpPost get(long id, WpContext context)
      Description copied from interface: PostAPIs
      Retrieves a post 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 PostAPIs
      Parameters:
      id - the ID of the post to retrieve
      context - the retrieval context; may be null, in which case WpContext.VIEW is used
      Returns:
      the matching WpPost
    • get

      public WpPost get(long id, WpContext context, String password)
      Description copied from interface: PostAPIs
      Retrieves a post 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 post is password protected, the provided password is used to access protected content. If the password is missing or incorrect, protected fields such as content or excerpt may be omitted or flagged as protected in the response.

      Specified by:
      get in interface PostAPIs
      Parameters:
      id - the ID of the post 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 WpPost
    • list

      public WpPagedResponse<WpPost> list(@NonNull @NonNull WpPagingQuery pageQuery, WpPostQuery postQuery)
      Description copied from interface: PostAPIs
      Retrieves a paginated list of posts using optional filtering and sorting criteria.

      The result set can be refined using WpPostQuery, for example by filtering on search criteria, include or exclude lists, or sort order.

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

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

      public WpPost update(long id, @NonNull @NonNull WpPostCreateUpdateRequest updateRequest)
      Description copied from interface: PostAPIs
      Updates an existing post.

      Updates a post in WordPress using the provided request payload.

      Specified by:
      update in interface PostAPIs
      Parameters:
      id - the ID of the post to update
      updateRequest - the post update request; must not be null
      Returns:
      the updated WpPost