Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List /media endpoint #383

Merged
merged 5 commits into from
Nov 14, 2024
Merged

List /media endpoint #383

merged 5 commits into from
Nov 14, 2024

Conversation

oguzkocer
Copy link
Contributor

@oguzkocer oguzkocer commented Nov 14, 2024

This PR implements list /media endpoint by mostly following the established patterns. Here are a few things worth noting:

  • 0b8b06c implements FromStr for PluginStatus. 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 in wp_api/src/posts.rs but now moved to wp_api/src/media.rs.
  • A new JsonValue type is introduced. The media_details field in /media has a dynamic type without a clear set of fields. This new JsonValue 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.
  • The PR implements both MediaType & MediaTypeParam types. This is because the server accepts values such as image, video, text, application, audio to filter the media list, but it returns image or file.
  • There is likely an error in the status of /media documentation. The Schema section indicates status is One of: publish, future, draft, pending, private, however using status=publish will result in InvalidParam error saying status[0] is not one of inherit, private, and trash.. Our test site also returns inherit for every media object. That's why MediaStatus is only implemented to have inherit, private, trash variants - with the addition of Custom(String) variant for fallback.

Copy link
Contributor

@jkmassel jkmassel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks pretty straightforward – I tried it out from Swift (as usual) and it worked great as usual.

@oguzkocer oguzkocer merged commit 266c00e into trunk Nov 14, 2024
20 of 22 checks passed
@oguzkocer oguzkocer deleted the media-list branch November 14, 2024 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants