|
2 | 2 |
|
3 | 3 | import static com.afrozaar.wordpress.wpapi.v2.util.FieldExtractor.extractField; |
4 | 4 | import static com.afrozaar.wordpress.wpapi.v2.util.Tuples.tuple; |
5 | | - |
6 | 5 | import static java.lang.String.format; |
7 | 6 | import static java.net.URLDecoder.decode; |
8 | 7 | import static java.util.Objects.isNull; |
|
71 | 70 | import com.fasterxml.jackson.databind.DeserializationFeature; |
72 | 71 | import com.fasterxml.jackson.databind.JsonMappingException; |
73 | 72 | import com.fasterxml.jackson.databind.ObjectMapper; |
74 | | - |
75 | 73 | import org.apache.commons.beanutils.BeanUtils; |
76 | 74 | import org.assertj.core.util.VisibleForTesting; |
77 | 75 | import org.slf4j.Logger; |
@@ -188,15 +186,24 @@ public Post createPost(Post post, PostStatus status) throws PostCreateException |
188 | 186 | return createPost(fieldsFrom(post), status); |
189 | 187 | } |
190 | 188 |
|
| 189 | + @Override |
| 190 | + public Post getCustomPost(Long id, String postTypeName) throws PostNotFoundException { |
| 191 | + return getPost(id, postTypeName, Contexts.VIEW); |
| 192 | + } |
| 193 | + |
191 | 194 | @Override |
192 | 195 | public Post getPost(Long id) throws PostNotFoundException { |
193 | 196 | return getPost(id, Contexts.VIEW); |
194 | 197 | } |
195 | 198 |
|
196 | 199 | @Override |
197 | 200 | public Post getPost(Long id, String context) throws PostNotFoundException { |
| 201 | + return getPost(id, Request.POST, context); |
| 202 | + } |
| 203 | + |
| 204 | + public Post getPost(Long id, String postTypeName, String context) throws PostNotFoundException { |
198 | 205 | try { |
199 | | - return doExchange1(Request.POST, HttpMethod.GET, Post.class, forExpand(id), ImmutableMap.of(CONTEXT_, context), null).getBody(); |
| 206 | + return doExchange1(postTypeName, HttpMethod.GET, Post.class, forExpand(id), ImmutableMap.of(CONTEXT_, context), null).getBody(); |
200 | 207 | } catch (HttpClientErrorException e) { |
201 | 208 | if (e.getStatusCode().is4xxClientError() && e.getStatusCode().value() == 404) { |
202 | 209 | throw new PostNotFoundException(e); |
|
0 commit comments