2018-08-10 20:10:19 -04:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
/**
|
|
|
|
* Hummingbird Anime List Client
|
|
|
|
*
|
2018-08-22 13:48:27 -04:00
|
|
|
* An API client for Kitsu to manage anime and manga watch lists
|
2018-08-10 20:10:19 -04:00
|
|
|
*
|
2021-02-04 11:57:01 -05:00
|
|
|
* PHP version 8
|
2018-08-10 20:10:19 -04:00
|
|
|
*
|
2022-03-04 15:50:35 -05:00
|
|
|
* @copyright 2015 - 2022 Timothy J. Warren <tim@timshome.page>
|
2018-08-10 20:10:19 -04:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
2020-12-10 17:06:50 -05:00
|
|
|
* @version 5.2
|
2022-03-04 15:50:35 -05:00
|
|
|
* @link https://git.timshome.page/timw4mail/HummingBirdAnimeClient
|
2018-08-10 20:10:19 -04:00
|
|
|
*/
|
|
|
|
|
2020-12-10 15:59:37 -05:00
|
|
|
namespace Aviat\AnimeClient;
|
2018-08-10 20:10:19 -04:00
|
|
|
|
|
|
|
use Aviat\AnimeClient\API\Enum\{
|
|
|
|
AnimeWatchingStatus\Anilist as AnimeWatchingStatus,
|
|
|
|
MangaReadingStatus\Anilist as MangaReadingStatus
|
|
|
|
};
|
2022-03-03 17:26:09 -05:00
|
|
|
use Aviat\AnimeClient\API\Enum\{
|
|
|
|
AnimeWatchingStatus\Kitsu as KAWS,
|
|
|
|
MangaReadingStatus\Kitsu as KMRS
|
|
|
|
};
|
2018-08-10 20:10:19 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constants and mappings for the Anilist API
|
|
|
|
*/
|
2022-03-03 17:26:09 -05:00
|
|
|
final class Anilist
|
|
|
|
{
|
2018-08-20 13:01:16 -04:00
|
|
|
public const AUTH_URL = 'https://anilist.co/api/v2/oauth/authorize';
|
2018-10-09 18:10:20 -04:00
|
|
|
public const TOKEN_URL = 'https://anilist.co/api/v2/oauth/token';
|
2018-08-20 13:01:16 -04:00
|
|
|
public const BASE_URL = 'https://graphql.anilist.co';
|
|
|
|
public const KITSU_ANILIST_WATCHING_STATUS_MAP = [
|
2018-08-10 20:10:19 -04:00
|
|
|
KAWS::WATCHING => AnimeWatchingStatus::WATCHING,
|
|
|
|
KAWS::COMPLETED => AnimeWatchingStatus::COMPLETED,
|
|
|
|
KAWS::ON_HOLD => AnimeWatchingStatus::ON_HOLD,
|
|
|
|
KAWS::DROPPED => AnimeWatchingStatus::DROPPED,
|
|
|
|
KAWS::PLAN_TO_WATCH => AnimeWatchingStatus::PLAN_TO_WATCH,
|
|
|
|
];
|
2018-08-20 13:01:16 -04:00
|
|
|
public const ANILIST_KITSU_WATCHING_STATUS_MAP = [
|
2018-08-15 14:05:28 -04:00
|
|
|
AnimeWatchingStatus::WATCHING => KAWS::WATCHING,
|
|
|
|
AnimeWatchingStatus::COMPLETED => KAWS::COMPLETED,
|
|
|
|
AnimeWatchingStatus::ON_HOLD => KAWS::ON_HOLD,
|
|
|
|
AnimeWatchingStatus::DROPPED => KAWS::DROPPED,
|
|
|
|
AnimeWatchingStatus::PLAN_TO_WATCH => KAWS::PLAN_TO_WATCH,
|
|
|
|
];
|
2018-08-20 13:01:16 -04:00
|
|
|
public const KITSU_ANILIST_READING_STATUS_MAP = [
|
2018-08-15 14:05:28 -04:00
|
|
|
KMRS::READING => MangaReadingStatus::READING,
|
|
|
|
KMRS::COMPLETED => MangaReadingStatus::COMPLETED,
|
|
|
|
KMRS::ON_HOLD => MangaReadingStatus::ON_HOLD,
|
|
|
|
KMRS::DROPPED => MangaReadingStatus::DROPPED,
|
|
|
|
KMRS::PLAN_TO_READ => MangaReadingStatus::PLAN_TO_READ,
|
|
|
|
];
|
2018-08-20 13:01:16 -04:00
|
|
|
public const ANILIST_KITSU_READING_STATUS_MAP = [
|
2018-08-15 14:05:28 -04:00
|
|
|
MangaReadingStatus::READING => KMRS::READING,
|
|
|
|
MangaReadingStatus::COMPLETED => KMRS::COMPLETED,
|
|
|
|
MangaReadingStatus::ON_HOLD => KMRS::ON_HOLD,
|
|
|
|
MangaReadingStatus::DROPPED => KMRS::DROPPED,
|
|
|
|
MangaReadingStatus::PLAN_TO_READ => KMRS::PLAN_TO_READ,
|
2018-08-10 20:10:19 -04:00
|
|
|
];
|
2022-03-03 17:26:09 -05:00
|
|
|
}
|