feat: adding playlist image endpoints (#78)

This commit is contained in:
paranarimasu
2023-03-08 23:42:54 -06:00
committed by Maniload
parent 10d30d6417
commit a2235918f3
7 changed files with 255 additions and 0 deletions
+12
View File
@@ -84,6 +84,7 @@ export default {
items: [
{ text: 'Index', link: '/list/' },
{ text: 'Playlist', link: '/list/playlist/' },
{ text: 'Playlist Image', link: '/list/playlistimage/' },
{ text: 'Playlist Track', link: '/list/playlist/track/' }
]
},
@@ -258,6 +259,17 @@ export default {
{ text: 'Update', link: '/list/playlist/update/' }
]
},
{
text: 'Playlist Image',
collapsed: true,
items: [
{ text: 'Resource', link: '/list/playlistimage/' },
{ text: 'Destroy', link: '/list/playlistimage/destroy/' },
{ text: 'Index', link: '/list/playlistimage/index/' },
{ text: 'Show', link: '/list/playlistimage/show/' },
{ text: 'Store', link: '/list/playlistimage/store/' }
]
},
{
text: 'Playlist Track',
collapsed: true,
+4
View File
@@ -14,6 +14,10 @@ List API resources pertain to user playlists.
A playlist API resource represents a list of ordered tracks intended for continuous playback.
**[Playlist Image](/wiki/playlistimage/)**
A playlist image API resource represents the association between a playlist and an image.
**[Playlist Track](/list/playlist/track/)**
A playlist track API resource represents an entry in a playlist.
+39
View File
@@ -0,0 +1,39 @@
---
title: Playlist Image Destroy
---
# Playlist Image Destroy Endpoint
The playlist image destroy endpoint deletes a playlist image and returns the deleted playlist image resource.
For example, the `/playlistimage/1/1` endpoint will delete the association between the playlist of id 1 and the large cover image of id 1.
## URL
```sh
DELETE /playlistimage/{playlist:id}/{image:id}
```
## Authentication
**Required Permission**: delete playlist, delete image
**Other Requirements**: User must own playlist & playlist must not be soft deleted
## Parameters
None
## Response
```json
{
message: "Image 'he3aw0eD3Gm7HKHJ5DRyCWOsK1QeIG91bmUXT2CX.png' has been detached from Playlist '/r/anime's Best OPs and EDs of 2022'.",
}
```
## Example
```bash
curl -X DELETE -H "Authorization: Bearer {token}" https://api.animethemes.moe/playlistimage/1/1
```
+39
View File
@@ -0,0 +1,39 @@
---
title: Playlist Image
---
# Playlist Image
---
A playlist image API resource represents the association between a playlist and an image.
## Fields
| Name | Type | Nullable | Default | Description |
| :--------: | :-----: | :------: | :-----: | :------------------------------------------- |
| created_at | Date | No | No | The date that the resource was created |
| updated_at | Date | No | No | The date that the resource was last modified |
## Allowed Include Paths
* playlist
* image
## Endpoints
**[Playlist Image Destroy](/list/playlistimage/destroy/)**
The playlist image destroy endpoint deletes a playlist image and returns the deleted playlist image resource.
**[Playlist Image Index](/list/playlistimage/index/)**
The playlist image index endpoint displays a listing of playlist image resources.
**[Playlist Image Show](/list/playlistimage/show/)**
The playlist image show endpoint returns a playlist image resource.
**[Playlist Image Store](/list/playlistimage/store/)**
The playlist image store endpoint creates a new playlist image and returns the new playlist image resource.
+76
View File
@@ -0,0 +1,76 @@
---
title: Playlist Image Index
---
# Playlist Image Index Endpoint
The playlist image index endpoint returns a listing of playlist image resources.
## URL
```sh
GET /playlistimage/
```
## Authentication
**Required Permission**: view playlist
## Parameters
| Name | Required | Description |
| :----------: | :------: | :------------------------------------------------------------------------------------- |
| fields | No | Sparse fieldsets for resource types |
| filter | No | Filters for playlist image resources & constraining the inclusion of related resources |
| include | No | Inclusion of related resources |
| page[number] | No | The page of playlist image resources to display |
| page[size] | No | The number of playlist image resources to display for the current page |
| sort | No | The list of fields to sort the resources |
## Allowed Sort Fields
| Name | Description |
| :--------: | :------------------------------------------------ |
| created_at | Sort resources on the resource creation date |
| updated_at | Sort resources on the resource last modified date |
## Filters
| Name | Description |
| :--------: | :--------------------------------------------------------- |
| created_at | Filter resources on the resource creation date |
| updated_at | Filter resources on the resource last modified date |
| has | Filter resources on relations within allowed include paths |
## Response
```json
{
playlistimages: [
{
created_at: "created_at",
updated_at: "updated_at"
},
...
],
links: {
first: "first",
last: "last",
prev: "prev",
next: "next"
},
meta: {
current_page: current_page,
from: from,
path: "path",
per_page: per_page,
to: to
}
}
```
## Example
```bash
curl https://api.animethemes.moe/playlistimage/
```
+42
View File
@@ -0,0 +1,42 @@
---
title: Playlist Image Show
---
# Playlist Image Show Endpoint
The playlist image show endpoint returns an playlist image resource.
For example, the `/playlistimage/1/1` endpoint will return the playlist image resource for the association between the playlist of id 1 and the large cover image of id 1.
## URL
```sh
GET /playlistimage/{playlist:id}/{image:id}
```
## Authentication
**Required Permission**: view playlist
**Other Requirements**: If the playlist is private, the user must own the playlist
## Parameters
None
## Response
```json
{
playlistimage: {
created_at: "created_at",
updated_at: "updated_at"
}
}
```
## Example
```bash
curl https://api.animethemes.moe/playlistimage/1/1
```
+43
View File
@@ -0,0 +1,43 @@
---
title: Playlist Image Store
---
# Playlist Image Store Endpoint
The playlist image store endpoint creates a new playlist image and returns the new playlist image resource.
For example, the `/playlistimage?playlist_id=1&image_id=1` endpoint will create a new association between the playlist of id 1 and the large cover image of id 1.
## URL
```sh
POST /playlistimage
```
## Authentication
**Required Permission**: create playlist, create image
## Parameters
| Name | Required | Rules |
| :---------: | :------: | :-------------------------- |
| playlist_id | Yes | integer, Playlist ID exists |
| image_id | Yes | integer, Image ID exists |
## Response
```json
{
playlistimage: {
created_at: "created_at",
updated_at: "updated_at"
}
}
```
## Example
```bash
curl -X POST -H "Authorization: Bearer {token}" https://api.animethemes.moe/playlistimage/
```