Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
7 changed files with 38 additions and 45 deletions
Showing only changes of commit 5c382db49c - Show all commits

View File

@ -14,14 +14,14 @@
* @link https://github.com/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\API\Kitsu\Enum;
namespace Aviat\AnimeClient\API\Enum\AnimeWatchingStatus;
use Aviat\Ion\Enum as BaseEnum;
use Aviat\Ion\Enum;
/**
* Possible values for watching status for the current anime
*/
class AnimeWatchingStatus extends BaseEnum {
class Kitsu extends Enum {
const WATCHING = 'current';
const PLAN_TO_WATCH = 'planned';
const COMPLETED = 'completed';

View File

@ -14,14 +14,14 @@
* @link https://github.com/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\API\MAL\Enum;
namespace Aviat\AnimeClient\API\Enum\AnimeWatchingStatus;
use Aviat\Ion\Enum as BaseEnum;
use Aviat\Ion\Enum;
/**
* Possible values for watching status for the current anime
*/
class AnimeWatchingStatus extends BaseEnum {
class MAL extends Enum {
const WATCHING = 1;
const COMPLETED = 2;
const ON_HOLD = 3;

View File

@ -14,18 +14,17 @@
* @link https://github.com/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\API\Kitsu\Enum;
namespace Aviat\AnimeClient\API\Enum\MangaReadingStatus;
use Aviat\Ion\Enum as BaseEnum;
use Aviat\Ion\Enum;
/**
* Possible values for current reading status of manga
*/
class MangaReadingStatus extends BaseEnum {
class Kitsu extends Enum {
const READING = 'current';
const PLAN_TO_READ = 'planned';
const DROPPED = 'dropped';
const ON_HOLD = 'on_hold';
const COMPLETED = 'completed';
}
// End of MangaReadingStatus.php
}

View File

@ -14,14 +14,14 @@
* @link https://github.com/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\API\MAL\Enum;
namespace Aviat\AnimeClient\API\Enum\MangaReadingStatus;
use Aviat\Ion\Enum as BaseEnum;
use Aviat\Ion\Enum;
/**
* Possible values for watching status for the current anime
*/
class MangaReadingStatus extends BaseEnum {
class MAL extends Enum {
const READING = 'reading';
const COMPLETED = 'completed';
const ON_HOLD = 'onhold';

View File

@ -16,22 +16,13 @@
namespace Aviat\AnimeClient\API\MAL\Transformer;
use Aviat\AnimeClient\API\Kitsu\Enum\AnimeWatchingStatus;
use Aviat\AnimeClient\API\Mapping\AnimeWatchingStatus;
use Aviat\Ion\Transformer\AbstractTransformer;
/**
* Transformer for updating MAL List
*/
class AnimeListTransformer extends AbstractTransformer {
const STATUS_MAP = [
AnimeWatchingStatus::WATCHING => '1',
AnimeWatchingStatus::COMPLETED => '2',
AnimeWatchingStatus::ON_HOLD => '3',
AnimeWatchingStatus::DROPPED => '4',
AnimeWatchingStatus::PLAN_TO_WATCH => '6'
];
/**
* Transform MAL episode data to Kitsu episode data
*
@ -45,7 +36,7 @@ class AnimeListTransformer extends AbstractTransformer {
return [
'id' => $item['mal_id'],
'data' => [
'status' => self::STATUS_MAP[$item['watching_status']],
'status' => AnimeWatchingStatus::KITSU_TO_MAL[$item['watching_status']],
'rating' => $item['user_rating'],
'rewatch_value' => (int) $rewatching,
'times_rewatched' => $item['rewatched'],
@ -54,12 +45,12 @@ class AnimeListTransformer extends AbstractTransformer {
]
];
}
/**
* Transform Kitsu episode data to MAL episode data
*
* @param array $item
* @return array
* @param array $item
* @return array
*/
public function untransform(array $item): array
{
@ -69,33 +60,33 @@ class AnimeListTransformer extends AbstractTransformer {
'episode' => $item['data']['progress']
]
];
$data =& $item['data'];
foreach($item['data'] as $key => $value)
{
switch($key)
switch($key)
{
case 'notes':
$map['data']['comments'] = $value;
break;
case 'rating':
$map['data']['score'] = $value * 2;
break;
case 'reconsuming':
$map['data']['enable_rewatching'] = (bool) $value;
break;
case 'reconsumeCount':
$map['data']['times_rewatched'] = $value;
break;
case 'status':
$map['data']['status'] = self::STATUS_MAP[$value];
$map['data']['status'] = AnimeWatchingStatus::KITSU_TO_MAL[$value];
break;
default:
break;
}

View File

@ -15,10 +15,12 @@
*/
namespace Aviat\AnimeClient\API\Mapping;
use Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\{Route, Title};
use Aviat\AnimeClient\API\{
Kitsu\Enum\AnimeWatchingStatus as Kitsu,
MAL\Enum\AnimeWatchingStatus as MAL
use Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\{
Kitsu,
MAL,
Route,
Title
};
use Aviat\Ion\Enum;

View File

@ -16,11 +16,12 @@
namespace Aviat\AnimeClient\API\Mapping;
use Aviat\AnimeClient\API\{
Kitsu\Enum\MangaReadingStatus as Kitsu,
MAL\Enum\MangaReadingStatus as MAL
use Aviat\AnimeClient\API\Enum\MangaReadingStatus\{
Kitsu,
MAL,
Title,
Route
};
use Aviat\AnimeClient\API\Enum\MangaReadingStatus\{Title, Route};
use Aviat\Ion\Enum;
class MangaReadingStatus extends Enum {