add full endpoints for resources

This commit is contained in:
Irfan 2022-05-22 13:58:34 +05:00
parent dce0260b57
commit dd43f05fb9
12 changed files with 2538 additions and 0 deletions

View File

@ -50,6 +50,93 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class AnimeController extends Controller
{
/**
* @OA\Get(
* path="/anime/{id}/full",
* operationId="getAnimeFullById",
* tags={"anime"},
*
* @OA\Parameter(
* name="id",
* in="path",
* required=true,
* @OA\Schema(type="integer")
* ),
*
* @OA\Response(
* response="200",
* description="Returns complete anime resource data",
* @OA\JsonContent(
* @OA\Property(
* property="data",
* ref="#/components/schemas/anime_full"
* )
* )
* ),
* @OA\Response(
* response="400",
* description="Error: Bad request. When required parameters were not supplied.",
* ),
* )
*/
public function full(Request $request, int $id)
{
$results = Anime::query()
->where('mal_id', $id)
->get();
if (
$results->isEmpty()
|| $this->isExpired($request, $results)
) {
$response = Anime::scrape($id);
if (HttpHelper::hasError($response)) {
return HttpResponse::notFound($request);
}
if ($results->isEmpty()) {
$meta = [
'createdAt' => new UTCDateTime(),
'modifiedAt' => new UTCDateTime(),
'request_hash' => $this->fingerprint
];
}
$meta['modifiedAt'] = new UTCDateTime();
$response = $meta + $response;
if ($results->isEmpty()) {
Anime::query()
->insert($response);
}
if ($this->isExpired($request, $results)) {
Anime::query()
->where('mal_id', $id)
->update($response);
}
$results = Anime::query()
->where('mal_id', $id)
->get();
}
if ($results->isEmpty()) {
return HttpResponse::notFound($request);
}
$response = (new \App\Http\Resources\V4\AnimeFullResource(
$results->first()
))->response();
return $this->prepareResponse(
$response,
$results,
$request
);
}
/**
* @OA\Get(
* path="/anime/{id}",

View File

@ -22,6 +22,89 @@ use MongoDB\BSON\UTCDateTime;
class CharacterController extends Controller
{
/**
* @OA\Get(
* path="/characters/{id}/full",
* operationId="getCharacterFullById",
* tags={"characters"},
*
* @OA\Parameter(
* name="id",
* in="path",
* required=true,
* @OA\Schema(type="integer")
* ),
*
* @OA\Response(
* response="200",
* description="Returns complete character resource data",
* @OA\JsonContent(
* ref="#/components/schemas/character_full"
* )
* ),
* @OA\Response(
* response="400",
* description="Error: Bad request. When required parameters were not supplied.",
* ),
* )
*/
public function full(Request $request, int $id)
{
$results = Character::query()
->where('mal_id', $id)
->get();
if (
$results->isEmpty()
|| $this->isExpired($request, $results)
) {
$response = Character::scrape($id);
if (HttpHelper::hasError($response)) {
return HttpResponse::notFound($request);
}
if ($results->isEmpty()) {
$meta = [
'createdAt' => new UTCDateTime(),
'modifiedAt' => new UTCDateTime(),
'request_hash' => $this->fingerprint
];
}
$meta['modifiedAt'] = new UTCDateTime();
$response = $meta + $response;
if ($results->isEmpty()) {
Character::query()
->insert($response);
}
if ($this->isExpired($request, $results)) {
Character::query()
->where('mal_id', $id)
->update($response);
}
$results = Character::query()
->where('mal_id', $id)
->get();
}
if ($results->isEmpty()) {
return HttpResponse::notFound($request);
}
$response = (new \App\Http\Resources\V4\CharacterFullResource(
$results->first()
))->response();
return $this->prepareResponse(
$response,
$results,
$request
);
}
/**
* @OA\Get(

View File

@ -49,6 +49,92 @@ use mysql_xdevapi\Result;
class MangaController extends Controller
{
/**
* @OA\Get(
* path="/manga/{id}/full",
* operationId="getMangaFullById",
* tags={"manga"},
*
* @OA\Parameter(
* name="id",
* in="path",
* required=true,
* @OA\Schema(type="integer")
* ),
*
* @OA\Response(
* response="200",
* description="Returns complete anime resource data",
* @OA\JsonContent(
* ref="#/components/schemas/manga_full"
* )
* ),
*
* @OA\Response(
* response="400",
* description="Error: Bad request. When required parameters were not supplied.",
* ),
* )
*/
public function full(Request $request, int $id)
{
$results = Manga::query()
->where('mal_id', $id)
->get();
if (
$results->isEmpty()
|| $this->isExpired($request, $results)
) {
$response = Manga::scrape($id);
if (HttpHelper::hasError($response)) {
return HttpResponse::notFound($request);
}
if ($results->isEmpty()) {
$meta = [
'createdAt' => new UTCDateTime(),
'modifiedAt' => new UTCDateTime(),
'request_hash' => $this->fingerprint
];
}
$meta['modifiedAt'] = new UTCDateTime();
$response = $meta + $response;
if ($results->isEmpty()) {
Manga::query()
->insert($response);
}
if ($this->isExpired($request, $results)) {
Manga::query()
->where('mal_id', $id)
->update($response);
}
$results = Manga::query()
->where('mal_id', $id)
->get();
}
if ($results->isEmpty()) {
return HttpResponse::notFound($request);
}
$response = (new \App\Http\Resources\V4\MangaFullResource(
$results->first()
))->response();
return $this->prepareResponse(
$response,
$results,
$request
);
}
/**
* @OA\Get(
* path="/manga/{id}",

View File

@ -21,6 +21,91 @@ use MongoDB\BSON\UTCDateTime;
class PersonController extends Controller
{
/**
* @OA\Get(
* path="/people/{id}/full",
* operationId="getPersonFullById",
* tags={"people"},
*
* @OA\Parameter(
* name="id",
* in="path",
* required=true,
* @OA\Schema(type="integer")
* ),
*
* @OA\Response(
* response="200",
* description="Returns complete character resource data",
* @OA\JsonContent(
* ref="#/components/schemas/person_full"
* )
* ),
*
* @OA\Response(
* response="400",
* description="Error: Bad request. When required parameters were not supplied.",
* ),
* )
*/
public function full(Request $request, int $id)
{
$results = Person::query()
->where('mal_id', $id)
->get();
if (
$results->isEmpty()
|| $this->isExpired($request, $results)
) {
$response = Person::scrape($id);
if (HttpHelper::hasError($response)) {
return HttpResponse::notFound($request);
}
if ($results->isEmpty()) {
$meta = [
'createdAt' => new UTCDateTime(),
'modifiedAt' => new UTCDateTime(),
'request_hash' => $this->fingerprint
];
}
$meta['modifiedAt'] = new UTCDateTime();
$response = $meta + $response;
if ($results->isEmpty()) {
Person::query()
->insert($response);
}
if ($this->isExpired($request, $results)) {
Person::query()
->where('mal_id', $id)
->update($response);
}
$results = Person::query()
->where('mal_id', $id)
->get();
}
if ($results->isEmpty()) {
return HttpResponse::notFound($request);
}
$response = (new \App\Http\Resources\V4\PersonFullResource(
$results->first()
))->response();
return $this->prepareResponse(
$response,
$results,
$request
);
}
/**
* @OA\Get(
* path="/people/{id}",

View File

@ -34,6 +34,89 @@ use MongoDB\BSON\UTCDateTime;
class UserController extends Controller
{
/**
* @OA\Get(
* path="/users/{username}/full",
* operationId="getUserFullProfile",
* tags={"users"},
*
* @OA\Parameter(
* name="username",
* in="path",
* required=true,
* @OA\Schema(type="string")
* ),
*
* @OA\Response(
* response="200",
* description="Returns complete user resource data",
* @OA\JsonContent(
* ref="#/components/schemas/user_profile_full"
* )
* ),
* @OA\Response(
* response="400",
* description="Error: Bad request. When required parameters were not supplied.",
* ),
* ),
*/
public function full(Request $request, string $username)
{
$username = strtolower($username);
$results = Profile::query()
->where('internal_username', $username)
->get();
if (
$results->isEmpty()
|| $this->isExpired($request, $results)
) {
$response = Profile::scrape($username);
if ($results->isEmpty()) {
$meta = [
'createdAt' => new UTCDateTime(),
'modifiedAt' => new UTCDateTime(),
'request_hash' => $this->fingerprint,
'internal_username' => $username
];
}
$meta['modifiedAt'] = new UTCDateTime();
$response = $meta + $response;
if ($results->isEmpty()) {
Profile::query()
->insert($response);
}
if ($this->isExpired($request, $results)) {
Profile::query()
->where('internal_username', $username)
->update($response);
}
$results = Profile::query()
->where('internal_username', $username)
->get();
}
if ($results->isEmpty()) {
return HttpResponse::notFound($request);
}
$response = (new \App\Http\Resources\V4\ProfileFullResource(
$results->first()
))->response();
return $this->prepareResponse(
$response,
$results,
$request
);
}
/**
* @OA\Get(
* path="/users/{username}",

View File

@ -0,0 +1,340 @@
<?php
namespace App\Http\Resources\V4;
use Illuminate\Http\Resources\Json\JsonResource;
class AnimeFullResource extends JsonResource
{
/**
* @OA\Schema(
* schema="anime_full",
* description="Full anime Resource",
*
* @OA\Property(
* property="mal_id",
* type="integer",
* description="MyAnimeList ID"
* ),
* @OA\Property(
* property="url",
* type="string",
* description="MyAnimeList URL"
* ),
* @OA\Property(
* property="images",
* ref="#/components/schemas/anime_images"
* ),
* @OA\Property(
* property="trailer",
* ref="#/components/schemas/trailer_base"
* ),
* @OA\Property(
* property="title",
* type="string",
* description="Title"
* ),
* @OA\Property(
* property="title_english",
* type="string",
* description="English Title",
* nullable=true
* ),
* @OA\Property(
* property="title_japanese",
* type="string",
* description="Japanese Title",
* nullable=true
* ),
* @OA\Property(
* property="title_synonyms",
* type="array",
* description="Other Titles",
* @OA\Items(
* type="string"
* )
* ),
* @OA\Property(
* property="type",
* type="string",
* enum={"TV","OVA","Movie","Special","ONA","Music"},
* description="Anime Type",
* nullable=true
* ),
* @OA\Property(
* property="source",
* type="string",
* description="Original Material/Source adapted from",
* nullable=true
* ),
* @OA\Property(
* property="episodes",
* type="integer",
* description="Episode count",
* nullable=true
* ),
* @OA\Property(
* property="status",
* type="string",
* enum={"Finished Airing", "Currently Airing", "Not yet aired"},
* description="Airing status",
* nullable=true
* ),
* @OA\Property(
* property="airing",
* type="boolean",
* description="Airing boolean"
* ),
* @OA\Property(
* property="aired",
* ref="#/components/schemas/daterange"
* ),
* @OA\Property(
* property="duration",
* type="string",
* description="Parsed raw duration",
* nullable=true
* ),
* @OA\Property(
* property="rating",
* type="string",
* enum={"G - All Ages", "PG - Children", "PG-13 - Teens 13 or older", "R - 17+ (violence & profanity)", "R+ - Mild Nudity", "Rx - Hentai" },
* description="Anime audience rating",
* nullable=true
* ),
* @OA\Property(
* property="score",
* type="number",
* format="float",
* description="Score",
* nullable=true
* ),
* @OA\Property(
* property="scored_by",
* type="integer",
* description="Number of users",
* nullable=true
* ),
* @OA\Property(
* property="rank",
* type="integer",
* description="Ranking",
* nullable=true
* ),
* @OA\Property(
* property="popularity",
* type="integer",
* description="Popularity",
* nullable=true
* ),
* @OA\Property(
* property="members",
* type="integer",
* description="Number of users who have added this entry to their list",
* nullable=true
* ),
* @OA\Property(
* property="favorites",
* type="integer",
* description="Number of users who have favorited this entry",
* nullable=true
* ),
* @OA\Property(
* property="synopsis",
* type="string",
* description="Synopsis",
* nullable=true
* ),
* @OA\Property(
* property="background",
* type="string",
* description="Background",
* nullable=true
* ),
* @OA\Property(
* property="season",
* type="string",
* enum={"Summer", "Winter", "Spring", "Fall"},
* description="Season",
* nullable=true
* ),
* @OA\Property(
* property="year",
* type="integer",
* description="Year",
* nullable=true
* ),
* @OA\Property(
* property="broadcast",
* ref="#/components/schemas/broadcast"
* ),
* @OA\Property(
* property="producers",
* type="array",
* @OA\Items(
* type="object",
* ref="#/components/schemas/mal_url"
* ),
* ),
* @OA\Property(
* property="licensors",
* type="array",
* @OA\Items(
* type="object",
* ref="#/components/schemas/mal_url"
* ),
* ),
* @OA\Property(
* property="studios",
* type="array",
* @OA\Items(
* type="object",
* ref="#/components/schemas/mal_url"
* ),
* ),
* @OA\Property(
* property="genres",
* type="array",
* @OA\Items(
* type="object",
* ref="#/components/schemas/mal_url"
* ),
* ),
* @OA\Property(
* property="explicit_genres",
* type="array",
* @OA\Items(
* type="object",
* ref="#/components/schemas/mal_url"
* ),
* ),
* @OA\Property(
* property="themes",
* type="array",
* @OA\Items(
* type="object",
* ref="#/components/schemas/mal_url"
* ),
* ),
* @OA\Property(
* property="demographics",
* type="array",
* @OA\Items(
* type="object",
* ref="#/components/schemas/mal_url"
* ),
* ),
*
* @OA\Property(
* property="relations",
* type="array",
* @OA\Items(
* type="object",
*
* @OA\Property(
* property="relation",
* type="string",
* description="Relation type"
* ),
* @OA\Property(
* property="entry",
* type="array",
* @OA\Items(
* type="object",
* ref="#/components/schemas/mal_url"
* ),
* )
* )
* ),
*
* @OA\Property(
* property="theme",
* type="object",
* @OA\Property(
* property="openings",
* type="array",
* @OA\Items(
* type="string",
* ),
* ),
* @OA\Property(
* property="endings",
* type="array",
* @OA\Items(
* type="string",
* ),
* ),
* ),
*
* @OA\Property(
* property="external",
* type="array",
*
* @OA\Items(
* type="object",
*
* @OA\Property(
* property="name",
* type="string",
* ),
* @OA\Property(
* property="url",
* type="string",
* ),
* ),
* ),
* )
*/
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'mal_id' => $this->mal_id,
'url' => $this->url,
'images' => $this->images,
'trailer' => $this->trailer,
'title' => $this->title,
'title_english' => $this->title_english,
'title_japanese' => $this->title_japanese,
'title_synonyms' => $this->title_synonyms,
'type' => $this->type,
'source' => $this->source,
'episodes' => $this->episodes,
'status' => $this->status,
'airing' => $this->airing,
'aired' => $this->aired,
'duration' => $this->duration,
'rating' => $this->rating,
'score' => $this->score,
'scored_by' => $this->scored_by,
'rank' => $this->rank,
'popularity' => $this->popularity,
'members' => $this->members,
'favorites' => $this->favorites,
'synopsis' => $this->synopsis,
'background' => $this->background,
'season' => $this->season,
'year' => $this->year,
'broadcast' => $this->broadcast,
'producers' => $this->producers,
'licensors' => $this->licensors,
'studios' => $this->studios,
'genres' => $this->genres,
'explicit_genres' => $this->explicit_genres,
'themes' => $this->themes,
'demographics' => $this->demographics,
'relations' => $this->related,
'theme' => [
'openings' => $this->opening_themes,
'endings' => $this->ending_themes
],
'external' => $this->external_links,
];
}
}

View File

@ -0,0 +1,144 @@
<?php
namespace App\Http\Resources\V4;
use Illuminate\Http\Resources\Json\JsonResource;
class CharacterFullResource extends JsonResource
{
/**
* @OA\Schema(
* schema="character_full",
* description="Character Resource",
*
* @OA\Property(
* property="mal_id",
* type="integer",
* description="MyAnimeList ID"
* ),
* @OA\Property(
* property="url",
* type="string",
* description="MyAnimeList URL"
* ),
* @OA\Property(
* property="images",
* ref="#/components/schemas/character_images"
* ),
* @OA\Property(
* property="name",
* type="string",
* description="Name"
* ),
* @OA\Property(
* property="name_kanji",
* type="string",
* description="Name",
* nullable=true
* ),
* @OA\Property(
* property="nicknames",
* type="array",
* description="Other Names",
* @OA\Items(
* type="string"
* )
* ),
* @OA\Property(
* property="favorites",
* type="integer",
* description="Number of users who have favorited this entry"
* ),
* @OA\Property(
* property="about",
* type="string",
* description="Biography",
* nullable=true
* ),
*
* @OA\Property(
* property="anime",
* type="array",
*
* @OA\Items(
* type="object",
*
* @OA\Property(
* property="role",
* type="string",
* description="Character's Role"
* ),
* @OA\Property(
* property="anime",
* type="object",
* ref="#/components/schemas/anime_meta"
* ),
* ),
* ),
*
* @OA\Property(
* property="manga",
* type="array",
*
* @OA\Items(
* type="object",
*
* @OA\Property(
* property="role",
* type="string",
* description="Character's Role"
* ),
* @OA\Property(
* property="manga",
* type="object",
* ref="#/components/schemas/manga_meta"
* ),
* ),
* ),
*
* @OA\Property(
* property="voices",
* type="array",
*
* @OA\Items(
* type="object",
*
* @OA\Property(
* property="language",
* type="string",
* description="Character's Role"
* ),
* @OA\Property(
* property="person",
* type="object",
* ref="#/components/schemas/person_meta"
* ),
* ),
* ),
*
* )
*/
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'mal_id' => $this->mal_id,
'url' => $this->url,
'images' => $this->images,
'name' => $this->name,
'name_kanji' => $this->name_kanji,
'nicknames' => $this->nicknames,
'favorites' => $this->favorites,
'about' => $this->about,
'anime' => $this->animeography,
'manga' => $this->mangaography,
'voices' => $this->voice_actors,
];
}
}

View File

@ -0,0 +1,266 @@
<?php
namespace App\Http\Resources\V4;
use Illuminate\Http\Resources\Json\JsonResource;
class MangaFullResource extends JsonResource
{
/**
* @OA\Schema(
* schema="manga_full",
* description="Manga Resource",
*
* @OA\Property(
* property="mal_id",
* type="integer",
* description="MyAnimeList ID"
* ),
* @OA\Property(
* property="url",
* type="string",
* description="MyAnimeList URL"
* ),
* @OA\Property(
* property="images",
* ref="#/components/schemas/manga_images"
* ),
* @OA\Property(
* property="title",
* type="string",
* description="Title"
* ),
* @OA\Property(
* property="title_english",
* type="string",
* description="English Title",
* nullable=true
* ),
* @OA\Property(
* property="title_japanese",
* type="string",
* description="Japanese Title",
* nullable=true
* ),
* @OA\Property(
* property="title_synonyms",
* type="array",
* description="Other Titles",
* @OA\Items(
* type="string"
* )
* ),
* @OA\Property(
* property="type",
* type="string",
* enum={"Manga", "Novel", "One-shot", "Doujinshi", "Manhua", "Manhwa", "OEL"},
* description="Manga Type",
* nullable=true
* ),
* @OA\Property(
* property="chapters",
* type="integer",
* description="Chapter count",
* nullable=true
* ),
* @OA\Property(
* property="volumes",
* type="integer",
* description="Volume count",
* nullable=true
* ),
* @OA\Property(
* property="status",
* type="string",
* enum={"Finished", "Publishing", "On Hiatus", "Discontinued", "Not yet published"},
* description="Publishing status"
* ),
* @OA\Property(
* property="publishing",
* type="boolean",
* description="Publishing boolean"
* ),
* @OA\Property(
* property="published",
* ref="#/components/schemas/daterange"
* ),
* @OA\Property(
* property="score",
* type="number",
* format="float",
* description="Score"
* ),
* @OA\Property(
* property="scored_by",
* type="integer",
* description="Number of users"
* ),
* @OA\Property(
* property="rank",
* type="integer",
* description="Ranking",
* nullable=true
* ),
* @OA\Property(
* property="popularity",
* type="integer",
* description="Popularity",
* nullable=true
* ),
* @OA\Property(
* property="members",
* type="integer",
* description="Number of users who have added this entry to their list",
* nullable=true
* ),
* @OA\Property(
* property="favorites",
* type="integer",
* description="Number of users who have favorited this entry",
* nullable=true
* ),
* @OA\Property(
* property="synopsis",
* type="string",
* description="Synopsis",
* nullable=true
* ),
* @OA\Property(
* property="background",
* type="string",
* description="Background",
* nullable=true
* ),
* @OA\Property(
* property="authors",
* type="array",
* @OA\Items(
* type="object",
* ref="#/components/schemas/mal_url"
* ),
* ),
* @OA\Property(
* property="serializations",
* type="array",
* @OA\Items(
* type="object",
* ref="#/components/schemas/mal_url"
* ),
* ),
* @OA\Property(
* property="genres",
* type="array",
* @OA\Items(
* type="object",
* ref="#/components/schemas/mal_url"
* ),
* ),
* @OA\Property(
* property="explicit_genres",
* type="array",
* @OA\Items(
* type="object",
* ref="#/components/schemas/mal_url"
* ),
* ),
* @OA\Property(
* property="themes",
* type="array",
* @OA\Items(
* type="object",
* ref="#/components/schemas/mal_url"
* ),
* ),
* @OA\Property(
* property="demographics",
* type="array",
* @OA\Items(
* type="object",
* ref="#/components/schemas/mal_url"
* ),
* ),
*
* @OA\Property(
* property="relations",
* type="array",
* @OA\Items(
* type="object",
*
* @OA\Property(
* property="relation",
* type="string",
* description="Relation type"
* ),
* @OA\Property(
* property="entry",
* type="array",
* @OA\Items(
* type="object",
* ref="#/components/schemas/mal_url"
* ),
* )
* )
* ),
*
* @OA\Property(
* property="external",
* type="array",
*
* @OA\Items(
* type="object",
*
* @OA\Property(
* property="name",
* type="string",
* ),
* @OA\Property(
* property="url",
* type="string",
* ),
* ),
* ),
* )
*/
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'mal_id' => $this->mal_id,
'url' => $this->url,
'images' => $this->images,
'title' => $this->title,
'title_english' => $this->title_english,
'title_japanese' => $this->title_japanese,
'title_synonyms' => $this->title_synonyms,
'type' => $this->type,
'chapters' => $this->chapters,
'volumes' => $this->volumes,
'status' => $this->status,
'publishing' => $this->publishing,
'published' => $this->published,
'score' => $this->score,
'scored' => $this->score, // @todo remove in 4.1
'scored_by' => $this->scored_by,
'rank' => $this->rank,
'popularity' => $this->popularity,
'members' => $this->members,
'favorites' => $this->favorites,
'synopsis' => $this->synopsis,
'background' => $this->background,
'authors' => $this->authors,
'serializations' => $this->serializations,
'genres' => $this->genres,
'explicit_genres' => $this->explicit_genres,
'themes' => $this->themes,
'demographics' => $this->demographics,
'relations' => $this->related,
'external' => $this->external_links,
];
}
}

View File

@ -0,0 +1,173 @@
<?php
namespace App\Http\Resources\V4;
use Illuminate\Http\Resources\Json\JsonResource;
class PersonFullResource extends JsonResource
{
/**
* @OA\Schema(
* schema="person_full",
* description="Person Resource",
*
* @OA\Property(
* property="mal_id",
* type="integer",
* description="MyAnimeList ID"
* ),
* @OA\Property(
* property="url",
* type="string",
* description="MyAnimeList URL"
* ),
* @OA\Property(
* property="website_url",
* type="string",
* description="Person's website URL",
* nullable=true
* ),
* @OA\Property(
* property="images",
* type="object",
* ref="#/components/schemas/people_images",
* ),
* @OA\Property(
* property="name",
* type="string",
* description="Name"
* ),
* @OA\Property(
* property="given_name",
* type="string",
* description="Given Name",
* nullable=true
* ),
* @OA\Property(
* property="family_name",
* type="string",
* description="Family Name",
* nullable=true
* ),
* @OA\Property(
* property="alternate_names",
* type="array",
* description="Other Names",
* @OA\Items(
* type="string"
* )
* ),
* @OA\Property(
* property="birthday",
* type="string",
* description="Birthday Date ISO8601",
* nullable=true
* ),
* @OA\Property(
* property="favorites",
* type="integer",
* description="Number of users who have favorited this entry"
* ),
* @OA\Property(
* property="about",
* type="string",
* description="Biography",
* nullable=true
* ),
*
* @OA\Property(
* property="anime",
* type="array",
*
* @OA\Items(
* type="object",
*
* @OA\Property(
* property="position",
* type="string",
* description="Person's position"
* ),
* @OA\Property(
* property="anime",
* type="object",
* ref="#/components/schemas/anime_meta"
* ),
* ),
* ),
*
* @OA\Property(
* property="manga",
* type="array",
*
* @OA\Items(
* type="object",
*
* @OA\Property(
* property="position",
* type="string",
* description="Person's position"
* ),
* @OA\Property(
* property="manga",
* type="object",
* ref="#/components/schemas/manga_meta"
* ),
* ),
* ),
*
* @OA\Property(
* property="voices",
* type="array",
*
* @OA\Items(
* type="object",
*
* @OA\Property(
* property="role",
* type="string",
* description="Person's Character's role in the anime"
* ),
* @OA\Property(
* property="anime",
* type="object",
* description="The anime in which the person is voice acting in",
* ref="#/components/schemas/anime_meta"
* ),
* @OA\Property(
* property="character",
* type="object",
* description="The character the person is voice acting for",
* ref="#/components/schemas/character_meta"
* ),
* ),
* ),
* )
*/
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'mal_id' => $this->mal_id,
'url' => $this->url,
'website_url' => $this->website_url,
'images' => $this->images,
'name' => $this->name,
'given_name' => $this->given_name,
'family_name' => $this->family_name,
'alternate_names' => $this->alternate_names,
'birthday' => $this->birthday,
'favorites' => $this->favorites,
'about' => $this->about,
'anime' => $this->anime_staff_positions,
'manga' => $this->published_manga,
'voices' => $this->voice_acting_roles,
];
}
}

View File

@ -0,0 +1,220 @@
<?php
namespace App\Http\Resources\V4;
use Illuminate\Http\Resources\Json\JsonResource;
class ProfileFullResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*
*
* @OA\Schema(
* schema="user_profile_full",
* type="object",
*
* @OA\Property(
* property="mal_id",
* type="integer",
* description="MyAnimeList ID",
* nullable=true
* ),
* @OA\Property(
* property="username",
* type="string",
* description="MyAnimeList Username"
* ),
* @OA\Property(
* property="url",
* type="string",
* description="MyAnimeList URL"
* ),
* @OA\Property(
* property="images",
* type="object",
* ref="#/components/schemas/user_images"
* ),
* @OA\Property(
* property="last_online",
* type="string",
* description="Last Online Date ISO8601",
* nullable=true
* ),
* @OA\Property(
* property="gender",
* type="string",
* description="User Gender",
* nullable=true
* ),
* @OA\Property(
* property="birthday",
* type="string",
* description="Birthday Date ISO8601",
* nullable=true
* ),
* @OA\Property(
* property="location",
* type="string",
* description="Location",
* nullable=true
* ),
* @OA\Property(
* property="joined",
* type="string",
* description="Joined Date ISO8601",
* nullable=true
* ),
*
* @OA\Property(
* property="statistics",
* type="object",
* @OA\Property(
* property="anime",
* type="object",
* description="Anime Statistics",
* @OA\Property(
* property="days_watched",
* type="number",
* format="float",
* description="Number of days spent watching Anime"
* ),
* @OA\Property(
* property="mean_score",
* type="number",
* format="float",
* description="Mean Score"
* ),
* @OA\Property(
* property="watching",
* type="integer",
* description="Anime Watching"
* ),
* @OA\Property(
* property="completed",
* type="integer",
* description="Anime Completed"
* ),
* @OA\Property(
* property="on_hold",
* type="integer",
* description="Anime On-Hold"
* ),
* @OA\Property(
* property="dropped",
* type="integer",
* description="Anime Dropped"
* ),
* @OA\Property(
* property="plan_to_watch",
* type="integer",
* description="Anime Planned to Watch"
* ),
* @OA\Property(
* property="total_entries",
* type="integer",
* description="Total Anime entries on User list"
* ),
* @OA\Property(
* property="rewatched",
* type="integer",
* description="Anime re-watched"
* ),
* @OA\Property(
* property="episodes_watched",
* type="integer",
* description="Number of Anime Episodes Watched"
* ),
* ),
* @OA\Property(
* property="manga",
* type="object",
* description="Manga Statistics",
* @OA\Property(
* property="days_read",
* type="number",
* format="float",
* description="Number of days spent reading Manga"
* ),
* @OA\Property(
* property="mean_score",
* type="number",
* format="float",
* description="Mean Score"
* ),
* @OA\Property(
* property="reading",
* type="integer",
* description="Manga Reading"
* ),
* @OA\Property(
* property="completed",
* type="integer",
* description="Manga Completed"
* ),
* @OA\Property(
* property="on_hold",
* type="integer",
* description="Manga On-Hold"
* ),
* @OA\Property(
* property="dropped",
* type="integer",
* description="Manga Dropped"
* ),
* @OA\Property(
* property="plan_to_read",
* type="integer",
* description="Manga Planned to Read"
* ),
* @OA\Property(
* property="total_entries",
* type="integer",
* description="Total Manga entries on User list"
* ),
* @OA\Property(
* property="reread",
* type="integer",
* description="Manga re-read"
* ),
* @OA\Property(
* property="chapters_read",
* type="integer",
* description="Number of Manga Chapters Read"
* ),
* @OA\Property(
* property="volumes_read",
* type="integer",
* description="Number of Manga Volumes Read"
* ),
* ),
* ),
* ),
*
* ),
*/
public function toArray($request)
{
return [
'mal_id' => $this->mal_id,
'username' => $this->username,
'url' => $this->url,
'images' => $this->images,
'last_online' => $this->last_online,
'gender' => $this->gender,
'birthday' => $this->birthday,
'location' => $this->location,
'joined' => $this->joined,
'statistics' => [
'anime'=> $this->anime_stats,
'manga'=> $this->manga_stats,
],
'favorites' => $this->favorites,
'updates' => $this->last_updates,
'about' => $this->about,
];
}
}

View File

@ -35,6 +35,10 @@ $router->group(
'uses' => 'AnimeController@main'
]);
$router->get('/full', [
'uses' => 'AnimeController@full'
]);
$router->get('/characters', [
'uses' => 'AnimeController@characters'
]);
@ -114,6 +118,10 @@ $router->group(
'uses' => 'MangaController@main'
]);
$router->get('/full', [
'uses' => 'MangaController@full'
]);
$router->get('/characters', [
'uses' => 'MangaController@characters'
]);
@ -173,6 +181,10 @@ $router->group(
'uses' => 'CharacterController@main'
]);
$router->get('/full', [
'uses' => 'CharacterController@full'
]);
$router->get('/anime', [
'uses' => 'CharacterController@anime'
]);
@ -203,6 +215,10 @@ $router->group(
'uses' => 'PersonController@main'
]);
$router->get('/full', [
'uses' => 'PersonController@full'
]);
$router->get('/anime', [
'uses' => 'PersonController@anime'
]);
@ -298,6 +314,10 @@ $router->group(
'uses' => 'UserController@profile'
]);
$router->get('/full', [
'uses' => 'UserController@full'
]);
$router->get('/statistics', [
'uses' => 'UserController@statistics'
]);

File diff suppressed because it is too large Load Diff