All Known Implementing Classes:
PostApiClientModule

public interface PostAPIs
Defines operations for managing WordPress posts through the WordPress REST API.

This interface provides methods for creating, retrieving, updating, listing, trashing, and deleting WpPost 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/posts endpoint or compatible APIs.

  • Method Details

    • create

      WpPost create(WpPostCreateUpdateRequest creationRequest)
      Creates a new post.

      Creates a post in WordPress using the provided request payload.

      Parameters:
      creationRequest - the post creation request; must not be null
      Returns:
      the created WpPost
    • delete

      WpPostDeletionResponse delete(long id)
      Permanently deletes a post by its unique identifier.
      Parameters:
      id - the ID of the post to delete
      Returns:
      the post deletion response
    • get

      WpPost get(long id, WpContext context)
      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.

      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

      WpPost get(long id, WpContext context, String password)
      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.

      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

      WpPagedResponse<WpPost> list(WpPagingQuery pageQuery, WpPostQuery postQuery)
      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.

      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

      WpPost trash(long id)
      Moves a post to the trash by its unique identifier.
      Parameters:
      id - the ID of the post to trash
      Returns:
      the trashed WpPost
    • update

      WpPost update(long id, WpPostCreateUpdateRequest updateRequest)
      Updates an existing post.

      Updates a post in WordPress using the provided request payload.

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