Version 5.1 - All the GraphQL #32
@ -14,14 +14,14 @@
|
|||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @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
|
* Possible values for watching status for the current anime
|
||||||
*/
|
*/
|
||||||
class AnimeWatchingStatus extends BaseEnum {
|
class Kitsu extends Enum {
|
||||||
const WATCHING = 'current';
|
const WATCHING = 'current';
|
||||||
const PLAN_TO_WATCH = 'planned';
|
const PLAN_TO_WATCH = 'planned';
|
||||||
const COMPLETED = 'completed';
|
const COMPLETED = 'completed';
|
@ -14,14 +14,14 @@
|
|||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @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
|
* Possible values for watching status for the current anime
|
||||||
*/
|
*/
|
||||||
class AnimeWatchingStatus extends BaseEnum {
|
class MAL extends Enum {
|
||||||
const WATCHING = 1;
|
const WATCHING = 1;
|
||||||
const COMPLETED = 2;
|
const COMPLETED = 2;
|
||||||
const ON_HOLD = 3;
|
const ON_HOLD = 3;
|
@ -14,18 +14,17 @@
|
|||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @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
|
* Possible values for current reading status of manga
|
||||||
*/
|
*/
|
||||||
class MangaReadingStatus extends BaseEnum {
|
class Kitsu extends Enum {
|
||||||
const READING = 'current';
|
const READING = 'current';
|
||||||
const PLAN_TO_READ = 'planned';
|
const PLAN_TO_READ = 'planned';
|
||||||
const DROPPED = 'dropped';
|
const DROPPED = 'dropped';
|
||||||
const ON_HOLD = 'on_hold';
|
const ON_HOLD = 'on_hold';
|
||||||
const COMPLETED = 'completed';
|
const COMPLETED = 'completed';
|
||||||
}
|
}
|
||||||
// End of MangaReadingStatus.php
|
|
@ -14,14 +14,14 @@
|
|||||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
* @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
|
* Possible values for watching status for the current anime
|
||||||
*/
|
*/
|
||||||
class MangaReadingStatus extends BaseEnum {
|
class MAL extends Enum {
|
||||||
const READING = 'reading';
|
const READING = 'reading';
|
||||||
const COMPLETED = 'completed';
|
const COMPLETED = 'completed';
|
||||||
const ON_HOLD = 'onhold';
|
const ON_HOLD = 'onhold';
|
@ -16,22 +16,13 @@
|
|||||||
|
|
||||||
namespace Aviat\AnimeClient\API\MAL\Transformer;
|
namespace Aviat\AnimeClient\API\MAL\Transformer;
|
||||||
|
|
||||||
use Aviat\AnimeClient\API\Kitsu\Enum\AnimeWatchingStatus;
|
use Aviat\AnimeClient\API\Mapping\AnimeWatchingStatus;
|
||||||
use Aviat\Ion\Transformer\AbstractTransformer;
|
use Aviat\Ion\Transformer\AbstractTransformer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transformer for updating MAL List
|
* Transformer for updating MAL List
|
||||||
*/
|
*/
|
||||||
class AnimeListTransformer extends AbstractTransformer {
|
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
|
* Transform MAL episode data to Kitsu episode data
|
||||||
*
|
*
|
||||||
@ -45,7 +36,7 @@ class AnimeListTransformer extends AbstractTransformer {
|
|||||||
return [
|
return [
|
||||||
'id' => $item['mal_id'],
|
'id' => $item['mal_id'],
|
||||||
'data' => [
|
'data' => [
|
||||||
'status' => self::STATUS_MAP[$item['watching_status']],
|
'status' => AnimeWatchingStatus::KITSU_TO_MAL[$item['watching_status']],
|
||||||
'rating' => $item['user_rating'],
|
'rating' => $item['user_rating'],
|
||||||
'rewatch_value' => (int) $rewatching,
|
'rewatch_value' => (int) $rewatching,
|
||||||
'times_rewatched' => $item['rewatched'],
|
'times_rewatched' => $item['rewatched'],
|
||||||
@ -54,12 +45,12 @@ class AnimeListTransformer extends AbstractTransformer {
|
|||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform Kitsu episode data to MAL episode data
|
* Transform Kitsu episode data to MAL episode data
|
||||||
*
|
*
|
||||||
* @param array $item
|
* @param array $item
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function untransform(array $item): array
|
public function untransform(array $item): array
|
||||||
{
|
{
|
||||||
@ -69,33 +60,33 @@ class AnimeListTransformer extends AbstractTransformer {
|
|||||||
'episode' => $item['data']['progress']
|
'episode' => $item['data']['progress']
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
$data =& $item['data'];
|
$data =& $item['data'];
|
||||||
|
|
||||||
foreach($item['data'] as $key => $value)
|
foreach($item['data'] as $key => $value)
|
||||||
{
|
{
|
||||||
switch($key)
|
switch($key)
|
||||||
{
|
{
|
||||||
case 'notes':
|
case 'notes':
|
||||||
$map['data']['comments'] = $value;
|
$map['data']['comments'] = $value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'rating':
|
case 'rating':
|
||||||
$map['data']['score'] = $value * 2;
|
$map['data']['score'] = $value * 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'reconsuming':
|
case 'reconsuming':
|
||||||
$map['data']['enable_rewatching'] = (bool) $value;
|
$map['data']['enable_rewatching'] = (bool) $value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'reconsumeCount':
|
case 'reconsumeCount':
|
||||||
$map['data']['times_rewatched'] = $value;
|
$map['data']['times_rewatched'] = $value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'status':
|
case 'status':
|
||||||
$map['data']['status'] = self::STATUS_MAP[$value];
|
$map['data']['status'] = AnimeWatchingStatus::KITSU_TO_MAL[$value];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Aviat\AnimeClient\API\Mapping;
|
namespace Aviat\AnimeClient\API\Mapping;
|
||||||
use Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\{Route, Title};
|
|
||||||
use Aviat\AnimeClient\API\{
|
use Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\{
|
||||||
Kitsu\Enum\AnimeWatchingStatus as Kitsu,
|
Kitsu,
|
||||||
MAL\Enum\AnimeWatchingStatus as MAL
|
MAL,
|
||||||
|
Route,
|
||||||
|
Title
|
||||||
};
|
};
|
||||||
use Aviat\Ion\Enum;
|
use Aviat\Ion\Enum;
|
||||||
|
|
||||||
|
@ -16,11 +16,12 @@
|
|||||||
|
|
||||||
namespace Aviat\AnimeClient\API\Mapping;
|
namespace Aviat\AnimeClient\API\Mapping;
|
||||||
|
|
||||||
use Aviat\AnimeClient\API\{
|
use Aviat\AnimeClient\API\Enum\MangaReadingStatus\{
|
||||||
Kitsu\Enum\MangaReadingStatus as Kitsu,
|
Kitsu,
|
||||||
MAL\Enum\MangaReadingStatus as MAL
|
MAL,
|
||||||
|
Title,
|
||||||
|
Route
|
||||||
};
|
};
|
||||||
use Aviat\AnimeClient\API\Enum\MangaReadingStatus\{Title, Route};
|
|
||||||
use Aviat\Ion\Enum;
|
use Aviat\Ion\Enum;
|
||||||
|
|
||||||
class MangaReadingStatus extends Enum {
|
class MangaReadingStatus extends Enum {
|
||||||
|
Loading…
Reference in New Issue
Block a user