Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements list
/media
endpoint by mostly following the established patterns. Here are a few things worth noting:FromStr
forPluginStatus
. I was planning to work on/plugins
pagination and later realized that the endpoint doesn't support pagination. Since this is a useful addition, I didn't want to throw it away and decided to include in this PR.MediaId
was temporarily implemented inwp_api/src/posts.rs
but now moved towp_api/src/media.rs
.JsonValue
type is introduced. Themedia_details
field in/media
has a dynamic type without a clear set of fields. This newJsonValue
type will be used in such cases. @jkmassel mentioned that he had to implement something similar while working in Add initial OAuth 2 support #287 and we agreed that this generic version is a reasonable addition.MediaType
&MediaTypeParam
types. This is because the server accepts values such asimage, video, text, application, audio
to filter the media list, but it returnsimage
orfile
.status
of/media
documentation. TheSchema
section indicatesstatus
isOne of: publish, future, draft, pending, private
, however usingstatus=publish
will result inInvalidParam
error sayingstatus[0] is not one of inherit, private, and trash.
. Our test site also returnsinherit
for every media object. That's whyMediaStatus
is only implemented to haveinherit, private, trash
variants - with the addition ofCustom(String)
variant for fallback.