Class PostApiClientModule
- All Implemented Interfaces:
PostAPIs
PostAPIs.
Provides access to WordPress post resources through the /wp/v2/posts endpoint, including support for
password-protected content and trash operations.
-
Constructor Summary
ConstructorsConstructorDescriptionPostApiClientModule(@NonNull String apiUrl, @NonNull org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient, @NonNull com.fasterxml.jackson.databind.ObjectMapper mapper) -
Method Summary
Modifier and TypeMethodDescriptioncreate(@NonNull WpPostCreateUpdateRequest creationRequest) Creates a new post.delete(long id) Permanently deletes a post by its unique identifier.Retrieves a post by its unique identifier using the given context.Retrieves a post by its unique identifier using the given context and optional password.list(@NonNull WpPagingQuery pageQuery, WpPostQuery postQuery) Retrieves a paginated list of posts using optional filtering and sorting criteria.trash(long id) Moves a post to the trash by its unique identifier.update(long id, @NonNull WpPostCreateUpdateRequest updateRequest) Updates an existing post.
-
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
Description copied from interface:PostAPIsCreates a new post.Creates a post in WordPress using the provided request payload.
-
delete
Description copied from interface:PostAPIsPermanently deletes a post by its unique identifier. -
get
Description copied from interface:PostAPIsRetrieves 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, orWpContext.EMBED.- Specified by:
getin interfacePostAPIs- Parameters:
id- the ID of the post to retrievecontext- the retrieval context; may benull, in which caseWpContext.VIEWis used- Returns:
- the matching
WpPost
-
get
Description copied from interface:PostAPIsRetrieves 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, orWpContext.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:
getin interfacePostAPIs- Parameters:
id- the ID of the post to retrievecontext- the retrieval context; may benull, in which caseWpContext.VIEWis usedpassword- the password for protected content; may benullwhen not required- Returns:
- the matching
WpPost
-
list
public WpPagedResponse<WpPost> list(@NonNull @NonNull WpPagingQuery pageQuery, WpPostQuery postQuery) Description copied from interface:PostAPIsRetrieves 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. -
trash
Description copied from interface:PostAPIsMoves a post to the trash by its unique identifier. -
update
Description copied from interface:PostAPIsUpdates an existing post.Updates a post in WordPress using the provided request payload.
-