From b0c75d989f7f988919cf713f1a5b540baa3c7424 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Thu, 30 Jul 2020 15:16:24 -0400 Subject: [PATCH] Groundwork for some upcoming API updates --- app/views/manga/details.php | 2 +- .../GraphQL/Queries/AnimeDetails.graphql | 2 + .../GraphQL/Queries/AnimeDetailsById.graphql | 2 + .../GraphQL/Queries/MangaDetails.graphql | 4 + .../GraphQL/Queries/MangaDetailsById.graphql | 4 + .../Kitsu/GraphQL/Queries/UserDetails.graphql | 118 ++++++++++-------- .../Kitsu/Transformer/AnimeTransformer.php | 2 +- .../Kitsu/Transformer/MangaTransformer.php | 7 +- .../API/Kitsu/Transformer/UserTransformer.php | 12 +- src/AnimeClient/Types/MangaPage.php | 9 +- 10 files changed, 98 insertions(+), 64 deletions(-) diff --git a/app/views/manga/details.php b/app/views/manga/details.php index cff3ef19..ab419814 100644 --- a/app/views/manga/details.php +++ b/app/views/manga/details.php @@ -42,7 +42,7 @@

- +

diff --git a/src/AnimeClient/API/Kitsu/GraphQL/Queries/AnimeDetails.graphql b/src/AnimeClient/API/Kitsu/GraphQL/Queries/AnimeDetails.graphql index a61c3c0f..f8ba34e1 100644 --- a/src/AnimeClient/API/Kitsu/GraphQL/Queries/AnimeDetails.graphql +++ b/src/AnimeClient/API/Kitsu/GraphQL/Queries/AnimeDetails.graphql @@ -95,6 +95,7 @@ query ($slug: String!) { canonical localized } + #slug } role } @@ -106,6 +107,7 @@ query ($slug: String!) { } } status + #subType synopsis titles { canonical diff --git a/src/AnimeClient/API/Kitsu/GraphQL/Queries/AnimeDetailsById.graphql b/src/AnimeClient/API/Kitsu/GraphQL/Queries/AnimeDetailsById.graphql index 8469a4df..4e2a10e8 100644 --- a/src/AnimeClient/API/Kitsu/GraphQL/Queries/AnimeDetailsById.graphql +++ b/src/AnimeClient/API/Kitsu/GraphQL/Queries/AnimeDetailsById.graphql @@ -95,6 +95,7 @@ query ($id: ID!) { canonical localized } + #slug } role } @@ -106,6 +107,7 @@ query ($id: ID!) { } } status + #subType synopsis titles { canonical diff --git a/src/AnimeClient/API/Kitsu/GraphQL/Queries/MangaDetails.graphql b/src/AnimeClient/API/Kitsu/GraphQL/Queries/MangaDetails.graphql index 14a7a4ab..54602048 100644 --- a/src/AnimeClient/API/Kitsu/GraphQL/Queries/MangaDetails.graphql +++ b/src/AnimeClient/API/Kitsu/GraphQL/Queries/MangaDetails.graphql @@ -22,6 +22,8 @@ query ($slug: String!) { title } } + # chapterCount + # volumeCount characters { nodes { character { @@ -91,6 +93,7 @@ query ($slug: String!) { canonical localized } + #slug } role } @@ -102,6 +105,7 @@ query ($slug: String!) { } } status + #subType synopsis titles { canonical diff --git a/src/AnimeClient/API/Kitsu/GraphQL/Queries/MangaDetailsById.graphql b/src/AnimeClient/API/Kitsu/GraphQL/Queries/MangaDetailsById.graphql index 68bfb31b..1a14ebaa 100644 --- a/src/AnimeClient/API/Kitsu/GraphQL/Queries/MangaDetailsById.graphql +++ b/src/AnimeClient/API/Kitsu/GraphQL/Queries/MangaDetailsById.graphql @@ -22,6 +22,8 @@ query ($id: ID!) { title } } + # chapterCount + # volumeCount characters { nodes { character { @@ -91,6 +93,7 @@ query ($id: ID!) { canonical localized } + #slug } role } @@ -102,6 +105,7 @@ query ($id: ID!) { } } status + #subType synopsis titles { canonical diff --git a/src/AnimeClient/API/Kitsu/GraphQL/Queries/UserDetails.graphql b/src/AnimeClient/API/Kitsu/GraphQL/Queries/UserDetails.graphql index 21df0313..d4c748d5 100644 --- a/src/AnimeClient/API/Kitsu/GraphQL/Queries/UserDetails.graphql +++ b/src/AnimeClient/API/Kitsu/GraphQL/Queries/UserDetails.graphql @@ -1,64 +1,80 @@ -# Requires authentication to select associated user -query { - session { - account { - email - id - proSubscription { - billingService - tier +query ($slug: String!) { + findProfileBySlug(slug: $slug) { + about + avatarImage { + original { + name + url + width + height } } - profile { - about - avatarImage { - original { - name - url - width - height - } + bannerImage { + original { + name + url + width + height } - bannerImage { - original { - name - url - width - height - } - } - id - name - proMessage - proTier - slug - url - waifu { + } + id + name + proMessage + proTier + slug + stats { + animeAmountConsumed { + completed id - image { - original { - name - url - width - height - } + media + recalculatedAt + time + units + } + animeCategoryBreakdown { + categories + recalculatedAt + total + } + mangaAmountConsumed { + completed + id + media + recalculatedAt + units + } + mangaCategoryBreakdown { + categories + recalculatedAt + total + } + } + url + waifu { + id + image { + original { + name + url + width + height } - names { + } + names { + canonical + alternatives + localized + } + primaryMedia { + slug + titles { canonical alternatives localized } - primaryMedia { - slug - titles { - canonical - alternatives - localized - } - } - slug } - waifuOrHusbando + slug } + # waifuOrHusbando } } diff --git a/src/AnimeClient/API/Kitsu/Transformer/AnimeTransformer.php b/src/AnimeClient/API/Kitsu/Transformer/AnimeTransformer.php index 4d3ba420..fbf737ac 100644 --- a/src/AnimeClient/API/Kitsu/Transformer/AnimeTransformer.php +++ b/src/AnimeClient/API/Kitsu/Transformer/AnimeTransformer.php @@ -114,7 +114,7 @@ final class AnimeTransformer extends AbstractTransformer { 'id' => $base['id'], 'slug' => $base['slug'], 'staff' => $staff, - 'show_type' => 'TV', // TODO: get show type + 'show_type' => 'TV', // $base['showType'] 'status' => Kitsu::getAiringStatus($base['startDate'], $base['endDate']), 'streaming_links' => [], // Kitsu::parseStreamingLinks($item['included']), 'synopsis' => $base['synopsis']['en'], diff --git a/src/AnimeClient/API/Kitsu/Transformer/MangaTransformer.php b/src/AnimeClient/API/Kitsu/Transformer/MangaTransformer.php index 9882abb8..c5741f75 100644 --- a/src/AnimeClient/API/Kitsu/Transformer/MangaTransformer.php +++ b/src/AnimeClient/API/Kitsu/Transformer/MangaTransformer.php @@ -49,7 +49,8 @@ final class MangaTransformer extends AbstractTransformer { sort($genres); $title = $base['titles']['canonical']; - $titles = Kitsu::filterLocalizedTitles($base['titles']); + $titles = Kitsu::getTitles($base['titles']); + $titles_more = Kitsu::filterLocalizedTitles($base['titles']); if (count($base['characters']['nodes']) > 0) { @@ -107,14 +108,18 @@ final class MangaTransformer extends AbstractTransformer { 'age_rating' => $base['ageRating'], 'age_rating_guide' => $base['ageRatingGuide'], 'characters' => $characters, + // 'chapter_count' => $base['chapterCount'], + // 'volume_count' => $base['volumeCount'], 'cover_image' => $base['posterImage']['views'][1]['url'], 'genres' => $genres, + // 'manga_type' => $base['subType'], 'id' => $base['id'], 'staff' => $staff, 'status' => Kitsu::getPublishingStatus($base['status'], $base['startDate'], $base['endDate']), 'synopsis' => $base['synopsis']['en'], 'title' => $title, 'titles' => $titles, + 'titles_more' => $titles_more, 'url' => "https://kitsu.io/manga/{$base['slug']}", ]; diff --git a/src/AnimeClient/API/Kitsu/Transformer/UserTransformer.php b/src/AnimeClient/API/Kitsu/Transformer/UserTransformer.php index 44424413..673cd9fe 100644 --- a/src/AnimeClient/API/Kitsu/Transformer/UserTransformer.php +++ b/src/AnimeClient/API/Kitsu/Transformer/UserTransformer.php @@ -46,14 +46,10 @@ final class UserTransformer extends AbstractTransformer { } unset($item); - $waifu = []; - if (array_key_exists('waifu', $rels)) - { - $waifu = [ - 'label' => $attributes['waifuOrHusbando'], - 'character' => $rels['waifu']['attributes'], - ]; - } + $waifu = (array_key_exists('waifu', $rels)) ? [ + 'label' => $attributes['waifuOrHusbando'], + 'character' => $rels['waifu']['attributes'], + ] : []; return User::from([ 'about' => $attributes['about'], diff --git a/src/AnimeClient/Types/MangaPage.php b/src/AnimeClient/Types/MangaPage.php index 18eb2d2f..c00616fd 100644 --- a/src/AnimeClient/Types/MangaPage.php +++ b/src/AnimeClient/Types/MangaPage.php @@ -35,7 +35,7 @@ final class MangaPage extends AbstractType { /** * @var array */ - public $characters; + public array $characters; /** * @var int @@ -50,7 +50,7 @@ final class MangaPage extends AbstractType { /** * @var array */ - public $genres; + public array $genres; /** * @var string @@ -87,6 +87,11 @@ final class MangaPage extends AbstractType { */ public array $titles; + /** + * A potentially longer list of titles for the details page + */ + public array $titles_more; + /** * @var string */