From 2ecd2fbbdb3c874868667854808f06f4510bc892 Mon Sep 17 00:00:00 2001 From: paranarimasu <33796518+paranarimasu@users.noreply.github.com> Date: Sat, 4 Mar 2023 12:52:57 -0600 Subject: [PATCH] feat: adding anime resource endpoints (#65) --- docs/.vitepress/config.js | 13 ++++ docs/wiki/animeresource/destroy/index.md | 39 ++++++++++++ docs/wiki/animeresource/index.md | 44 +++++++++++++ docs/wiki/animeresource/index/index.md | 79 ++++++++++++++++++++++++ docs/wiki/animeresource/show/index.md | 41 ++++++++++++ docs/wiki/animeresource/store/index.md | 47 ++++++++++++++ docs/wiki/animeresource/update/index.md | 45 ++++++++++++++ 7 files changed, 308 insertions(+) create mode 100644 docs/wiki/animeresource/destroy/index.md create mode 100644 docs/wiki/animeresource/index.md create mode 100644 docs/wiki/animeresource/index/index.md create mode 100644 docs/wiki/animeresource/show/index.md create mode 100644 docs/wiki/animeresource/store/index.md create mode 100644 docs/wiki/animeresource/update/index.md diff --git a/docs/.vitepress/config.js b/docs/.vitepress/config.js index bdfd6d7..fac1292 100644 --- a/docs/.vitepress/config.js +++ b/docs/.vitepress/config.js @@ -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, diff --git a/docs/wiki/animeresource/destroy/index.md b/docs/wiki/animeresource/destroy/index.md new file mode 100644 index 0000000..4ac1dee --- /dev/null +++ b/docs/wiki/animeresource/destroy/index.md @@ -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 +``` diff --git a/docs/wiki/animeresource/index.md b/docs/wiki/animeresource/index.md new file mode 100644 index 0000000..59bb400 --- /dev/null +++ b/docs/wiki/animeresource/index.md @@ -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. \ No newline at end of file diff --git a/docs/wiki/animeresource/index/index.md b/docs/wiki/animeresource/index/index.md new file mode 100644 index 0000000..4ed685e --- /dev/null +++ b/docs/wiki/animeresource/index/index.md @@ -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/ +``` diff --git a/docs/wiki/animeresource/show/index.md b/docs/wiki/animeresource/show/index.md new file mode 100644 index 0000000..4bb8ab6 --- /dev/null +++ b/docs/wiki/animeresource/show/index.md @@ -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 +``` diff --git a/docs/wiki/animeresource/store/index.md b/docs/wiki/animeresource/store/index.md new file mode 100644 index 0000000..eea795b --- /dev/null +++ b/docs/wiki/animeresource/store/index.md @@ -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/ +``` diff --git a/docs/wiki/animeresource/update/index.md b/docs/wiki/animeresource/update/index.md new file mode 100644 index 0000000..e700de5 --- /dev/null +++ b/docs/wiki/animeresource/update/index.md @@ -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/ +```