feat: adding anime resource endpoints (#65)

This commit is contained in:
paranarimasu
2023-03-04 12:52:57 -06:00
committed by Maniload
parent 1ea9fe214f
commit 2ecd2fbbdb
7 changed files with 308 additions and 0 deletions
+13
View File
@@ -93,6 +93,7 @@ export default {
{ text: 'Index', link: '/wiki/' },
{ text: 'Anime', link: '/wiki/anime/' },
{ text: 'Anime Image', link: '/wiki/animeimage/' },
{ text: 'Anime Resource', link: '/wiki/animeresource/' },
{ text: 'Anime Synonym', link: '/wiki/animesynonym/' },
{ text: 'Anime Theme', link: '/wiki/animetheme/' },
{ text: 'Anime Theme Entry', link: '/wiki/animethemeentry/' },
@@ -292,6 +293,18 @@ export default {
{ text: 'Store', link: '/wiki/animeimage/store/' }
]
},
{
text: 'Anime Resource',
collapsible: true,
items: [
{ text: 'Resource', link: '/wiki/animeresource/' },
{ text: 'Destroy', link: '/wiki/animeresource/destroy/' },
{ text: 'Index', link: '/wiki/animeresource/index/' },
{ text: 'Show', link: '/wiki/animeresource/show/' },
{ text: 'Store', link: '/wiki/animeresource/store/' },
{ text: 'Update', link: '/wiki/animeresource/update/' }
]
},
{
text: 'Anime Synonym',
collapsible: true,
+39
View File
@@ -0,0 +1,39 @@
---
title: Anime Resource Destroy
---
# Anime Resource Destroy Endpoint
The anime resource destroy endpoint deletes an anime resource and returns the deleted anime resource resource.
For example, the `/animeresource/bakemonogatari/1083` endpoint will delete the association between the Bakemonogatari anime and the external resource of id 1083.
## URL
```sh
DELETE /animeresource/{anime:slug}/{resource:id}
```
## Authentication
**Required Permission**: delete anime, delete external resource
**Roles with Permission**: Wiki Editor, Admin
## Parameters
None
## Response
```json
{
message: "Resource 'https://myanimelist.net/anime/5081' has been detached from Anime 'Bakemonogatari'.",
}
```
## Example
```bash
curl -X DELETE -H "Authorization: Bearer {token}" https://api.animethemes.moe/animeresource/bakemonogatari/1083
```
+44
View File
@@ -0,0 +1,44 @@
---
title: Anime Resource
---
# Anime Resource
---
An anime resource API resource represents the association between an anime and an external resource.
## Fields
| Name | Type | Nullable | Description |
| :--------: | :-----: | :------: | :------------------------------------------------------- |
| created_at | Date | No | The date that the resource was created |
| updated_at | Date | No | The date that the resource was last modified |
| as | String | No | Used to distinguish resources that map to the same anime |
## Allowed Include Paths
* anime
* resource
## Endpoints
**[Anime Resource Destroy](/wiki/animeresource/destroy/)**
The anime resource destroy endpoint deletes an anime resource and returns the deleted anime resource resource.
**[Anime Resource Index](/wiki/animeresource/index/)**
The anime resource index endpoint displays a listing of anime resource resources.
**[Anime Resource Show](/wiki/animeresource/show/)**
The anime resource show endpoint returns an anime resource resource.
**[Anime Resource Store](/wiki/animeresource/store/)**
The anime resource store endpoint creates a new anime resource and returns the new anime resource resource.
**[Anime Resource Update](/wiki/animeresource/update/)**
The anime update endpoint updates an anime resource and returns the updated anime resource resource.
+79
View File
@@ -0,0 +1,79 @@
---
title: Anime Resource Index
---
# Anime Resource Index Endpoint
The anime resource index endpoint returns a listing of anime resource resources.
## URL
```sh
GET /animeresource/
```
## Authentication
None
## Parameters
| Name | Required | Description |
| :----------: | :------: | :---------------------------------------------------------------------------- |
| fields | No | Sparse fieldsets for resource types |
| filter | No | Filters for anime resources & constraining the inclusion of related resources |
| include | No | Inclusion of related resources |
| page[number] | No | The page of anime resource resources to display |
| page[size] | No | The number of anime resource 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 |
| as | Sort resources on distinguishing label |
## Filters
| Name | Description |
| :--------: | :--------------------------------------------------------- |
| created_at | Filter resources on the resource creation date |
| updated_at | Filter resources on the resource last modified date |
| as | Filter resources on the resource distinguishing label |
| has | Filter resources on relations within allowed include paths |
## Response
```json
{
animeresources: [
{
created_at: "created_at",
updated_at: "updated_at",
as: "as"
},
...
],
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/animeresource/
```
+41
View File
@@ -0,0 +1,41 @@
---
title: Anime Resource Show
---
# Anime Resource Show Endpoint
The anime resource show endpoint returns an anime resource resource.
For example, the `/animeresource/bakemonogatari/1083` endpoint will return the anime resource resource for the association between the Bakemonogatari anime and the external resource of id 1083.
## URL
```sh
GET /animeresource/{anime:slug}/{resource:id}
```
## Authentication
None
## Parameters
None
## Response
```json
{
animeresource: {
created_at: "created_at",
updated_at: "updated_at",
as: "as"
}
}
```
## Example
```bash
curl https://api.animethemes.moe/animeresource/bakemonogatari/1083
```
+47
View File
@@ -0,0 +1,47 @@
---
title: Anime Resource Store
---
# Anime Resource Store Endpoint
The anime resource store endpoint creates a new anime resource and returns the new anime resource resource.
For example, the `/animeresource?anime_id=218&resource_id=1083` endpoint will create a new association between the Bakemonogatari anime and the external resource of id 1083.
## URL
```sh
POST /animeresource
```
## Authentication
**Required Permission**: create anime, create external resource
**Roles with Permission**: Wiki Editor, Admin
## Parameters
| Name | Required | Rules |
| :---------: | :------: | :-------------------------- |
| anime_id | Yes | integer, Anime ID exists |
| resource_id | Yes | integer, Resource ID exists |
| as | No | string, max:192 |
## Response
```json
{
animeresource: {
created_at: "created_at",
updated_at: "updated_at",
as: "as"
}
}
```
## Example
```bash
curl -X POST -H "Authorization: Bearer {token}" https://api.animethemes.moe/animeresource/
```
+45
View File
@@ -0,0 +1,45 @@
---
title: Anime Resource Update
---
# Anime Resource Update Endpoint
The anime resource store endpoint updates an anime resource and returns the updated anime resource resource.
For example, the `/animeresource/bakemonogatari/1083?as=updated+label` endpoint will update the association between the Bakemonogatari anime and the external resource of id 1083.
## URL
```sh
PUT|PATCH /animeresource/{anime:slug}/{resource:id}
```
## Authentication
**Required Permission**: update anime, update external resource
**Roles with Permission**: Wiki Editor, Admin
## Parameters
| Name | Required | Rules |
| :---------: | :------: | :-------------- |
| as | No | string, max:192 |
## Response
```json
{
animeresource: {
created_at: "created_at",
updated_at: "updated_at",
as: "as"
}
}
```
## Example
```bash
curl -X PATCH -H "Authorization: Bearer {token}" https://api.animethemes.moe/animeresource/
```