Skip to content

Commit 8b781ce

Browse files
committed
Added functionality to get custom post types
1 parent b65cdd8 commit 8b781ce

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/main/java/com/afrozaar/wordpress/wpapi/v2/Client.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,18 @@ public PostMeta getPostMeta(Long postId, Long metaId) {
347347
return exchange.getBody();
348348
}
349349

350+
@Override
351+
public List<PostMeta> getCustomPostMetas(Long postId, String customPostType) {
352+
final ResponseEntity<PostMeta[]> exchange = doExchange1(Request.CUSTOM_POST_METAS, HttpMethod.GET, PostMeta[].class, forExpand(customPostType, postId), null, null);
353+
return Arrays.asList(exchange.getBody());
354+
}
355+
356+
@Override
357+
public PostMeta getCustomPostMeta(Long postId, Long metaId, String customPostType) {
358+
final ResponseEntity<PostMeta> exchange = doExchange1(Request.CUSTOM_POST_META, HttpMethod.GET, PostMeta.class, forExpand(customPostType, postId, metaId), null, null);
359+
return exchange.getBody();
360+
}
361+
350362
@Override
351363
public PostMeta updatePostMetaValue(Long postId, Long metaId, String value) {
352364
return updatePostMeta(postId, metaId, null, value);

src/main/java/com/afrozaar/wordpress/wpapi/v2/api/PostMetas.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ public interface PostMetas {
1515

1616
PostMeta getPostMeta(Long postId, Long metaId);
1717

18+
List<PostMeta> getCustomPostMetas(Long postId, String customPostType);
19+
20+
PostMeta getCustomPostMeta(Long postId, Long metaId, String customPostType);
21+
1822
PostMeta updatePostMetaValue(Long postId, Long metaId, String value);
1923

2024
PostMeta updatePostMeta(Long postId, Long metaId, String key, String value);

src/main/java/com/afrozaar/wordpress/wpapi/v2/request/Request.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public abstract class Request {
2323

2424
public static final String METAS = "/posts/{postId}/meta";
2525
public static final String META = "/posts/{postId}/meta/{metaId}";
26+
public static final String CUSTOM_POST_METAS = "/{postType}/{postId}/meta";
27+
public static final String CUSTOM_POST_META = "/{postType}/{postId}/meta/{metaId}";
2628
public static final String META_POST_DELETE = "/posts/{postId}/meta/{metaId}/delete";
2729
public static final String TAXONOMIES = "/taxonomies";
2830
public static final String TAXONOMY = "/taxonomies/{slug}";

0 commit comments

Comments
 (0)