Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
23 changed files with 34 additions and 1246 deletions
Showing only changes of commit 348fe6e724 - Show all commits

View File

@ -22,9 +22,7 @@ use Aura\Session\SessionFactory;
use Aviat\AnimeClient\API\{ use Aviat\AnimeClient\API\{
Anilist, Anilist,
Kitsu, Kitsu,
MAL, Kitsu\KitsuRequestBuilder
Kitsu\KitsuRequestBuilder,
MAL\MALRequestBuilder
}; };
use Aviat\AnimeClient\Model; use Aviat\AnimeClient\Model;
use Aviat\Banker\Pool; use Aviat\Banker\Pool;
@ -50,12 +48,9 @@ return function (array $configArray = []) {
$anilistRequestLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/anilist_request.log', Logger::NOTICE)); $anilistRequestLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/anilist_request.log', Logger::NOTICE));
$kitsuRequestLogger = new Logger('kitsu-request'); $kitsuRequestLogger = new Logger('kitsu-request');
$kitsuRequestLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/kitsu_request.log', Logger::NOTICE)); $kitsuRequestLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/kitsu_request.log', Logger::NOTICE));
$malRequestLogger = new Logger('mal-request');
$malRequestLogger->pushHandler(new RotatingFileHandler(__DIR__ . '/logs/mal_request.log', Logger::NOTICE));
$container->setLogger($appLogger); $container->setLogger($appLogger);
$container->setLogger($anilistRequestLogger, 'anilist-request'); $container->setLogger($anilistRequestLogger, 'anilist-request');
$container->setLogger($kitsuRequestLogger, 'kitsu-request'); $container->setLogger($kitsuRequestLogger, 'kitsu-request');
$container->setLogger($malRequestLogger, 'mal-request');
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Injected Objects // Injected Objects
@ -131,19 +126,6 @@ return function (array $configArray = []) {
$model->setCache($cache); $model->setCache($cache);
return $model; return $model;
}); });
$container->set('mal-model', function($container) {
$requestBuilder = new MALRequestBuilder();
$requestBuilder->setLogger($container->getLogger('mal-request'));
$listItem = new MAL\ListItem();
$listItem->setContainer($container);
$listItem->setRequestBuilder($requestBuilder);
$model = new MAL\Model($listItem);
$model->setContainer($container);
$model->setRequestBuilder($requestBuilder);
return $model;
});
$container->set('anilist-model', function($container) { $container->set('anilist-model', function($container) {
$requestBuilder = new Anilist\AnilistRequestBuilder(); $requestBuilder = new Anilist\AnilistRequestBuilder();
$requestBuilder->setLogger($container->getLogger('anilist-request')); $requestBuilder->setLogger($container->getLogger('anilist-request'));

View File

@ -1,30 +0,0 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\API\Enum\AnimeWatchingStatus;
use Aviat\Ion\Enum;
/**
* Possible values for watching status for the current anime
*/
final class MAL extends Enum {
const WATCHING = 1;
const COMPLETED = 2;
const ON_HOLD = 3;
const DROPPED = 4;
const PLAN_TO_WATCH = 6;
}

View File

@ -1,30 +0,0 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\API\Enum\MangaReadingStatus;
use Aviat\Ion\Enum;
/**
* Possible values for watching status for the current anime
*/
final class MAL extends Enum {
const READING = 'reading';
const COMPLETED = 'completed';
const ON_HOLD = 'onhold';
const DROPPED = 'dropped';
const PLAN_TO_READ = 'plantoread';
}

View File

@ -33,7 +33,7 @@ use Aviat\Ion\JsonException;
trait KitsuTrait { trait KitsuTrait {
/** /**
* The request builder for the MAL API * The request builder for the Kitsu API
* @var KitsuRequestBuilder * @var KitsuRequestBuilder
*/ */
protected $requestBuilder; protected $requestBuilder;

View File

@ -1,82 +0,0 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\API;
use Aviat\AnimeClient\API\Enum\{
AnimeWatchingStatus\Kitsu as KAWS,
MangaReadingStatus\Kitsu as KMRS
};
use Aviat\AnimeClient\API\Enum\{
AnimeWatchingStatus\MAL as AnimeWatchingStatus,
MangaReadingStatus\MAL as MangaReadingStatus
};
/**
* Constants and mappings for the My Anime List API
*/
final class MAL {
const AUTH_URL = 'https://myanimelist.net/api/account/verify_credentials.xml';
const BASE_URL = 'https://myanimelist.net/api/';
const KITSU_MAL_WATCHING_STATUS_MAP = [
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
];
const MAL_KITSU_WATCHING_STATUS_MAP = [
1 => KAWS::WATCHING,
2 => KAWS::COMPLETED,
3 => KAWS::ON_HOLD,
4 => KAWS::DROPPED,
6 => KAWS::PLAN_TO_WATCH
];
public static function getIdToWatchingStatusMap()
{
return [
1 => AnimeWatchingStatus::WATCHING,
2 => AnimeWatchingStatus::COMPLETED,
3 => AnimeWatchingStatus::ON_HOLD,
4 => AnimeWatchingStatus::DROPPED,
6 => AnimeWatchingStatus::PLAN_TO_WATCH,
'watching' => AnimeWatchingStatus::WATCHING,
'completed' => AnimeWatchingStatus::COMPLETED,
'onhold' => AnimeWatchingStatus::ON_HOLD,
'dropped' => AnimeWatchingStatus::DROPPED,
'plantowatch' => AnimeWatchingStatus::PLAN_TO_WATCH
];
}
public static function getIdToReadingStatusMap()
{
return [
1 => MangaReadingStatus::READING,
2 => MangaReadingStatus::COMPLETED,
3 => MangaReadingStatus::ON_HOLD,
4 => MangaReadingStatus::DROPPED,
6 => MangaReadingStatus::PLAN_TO_READ,
'reading' => MangaReadingStatus::READING,
'completed' => MangaReadingStatus::COMPLETED,
'onhold' => MangaReadingStatus::ON_HOLD,
'dropped' => MangaReadingStatus::DROPPED,
'plantoread' => MangaReadingStatus::PLAN_TO_READ
];
}
}

View File

@ -1,109 +0,0 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\API\MAL;
use Amp\Artax\{FormBody, Request};
use Aviat\AnimeClient\API\{
XML
};
use Aviat\AnimeClient\Types\AbstractType;
use Aviat\Ion\Di\ContainerAware;
/**
* CRUD operations for MAL list items
*/
final class ListItem {
use ContainerAware;
use MALTrait;
/**
* Create a list item
*
* @param array $data
* @param string $type
* @return Request
*/
public function create(array $data, string $type = 'anime'): Request
{
$id = $data['id'];
$createData = [
'id' => $id,
'data' => XML::toXML([
'entry' => $data['data']
])
];
$config = $this->container->get('config');
return $this->requestBuilder->newRequest('POST', "{$type}list/add/{$id}.xml")
->setFormFields($createData)
->setBasicAuth($config->get(['mal','username']), $config->get(['mal', 'password']))
->getFullRequest();
}
/**
* Delete a list item
*
* @param string $id
* @param string $type
* @return Request
*/
public function delete(string $id, string $type = 'anime'): Request
{
$config = $this->container->get('config');
return $this->requestBuilder->newRequest('DELETE', "{$type}list/delete/{$id}.xml")
->setFormFields([
'id' => $id
])
->setBasicAuth($config->get(['mal','username']), $config->get(['mal', 'password']))
->getFullRequest();
// return $response->getBody() === 'Deleted'
}
public function get(string $id): array
{
return [];
}
/**
* Update a list item
*
* @param string $id
* @param array $data
* @param string $type
* @return Request
*/
public function update(string $id, array $data, string $type = 'anime'): Request
{
$config = $this->container->get('config');
$xml = XML::toXML(['entry' => $data]);
$body = new FormBody();
$body->addField('id', $id);
$body->addField('data', $xml);
return $this->requestBuilder->newRequest('POST', "{$type}list/update/{$id}.xml")
->setFormFields([
'id' => $id,
'data' => $xml
])
->setBasicAuth($config->get(['mal','username']), $config->get(['mal', 'password']))
->getFullRequest();
}
}

View File

@ -1,51 +0,0 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\API\MAL;
use const Aviat\AnimeClient\USER_AGENT;
use Aviat\AnimeClient\API\{
APIRequestBuilder,
MAL as M
};
final class MALRequestBuilder extends APIRequestBuilder {
/**
* The base url for api requests
* @var string $base_url
*/
protected $baseUrl = M::BASE_URL;
/**
* HTTP headers to send with every request
*
* @var array
*/
protected $defaultHeaders = [
'Accept' => 'text/xml',
'Accept-Encoding' => 'gzip',
'Content-type' => 'application/x-www-form-urlencoded',
'User-Agent' => USER_AGENT,
];
/**
* Valid HTTP request methos
* @var array
*/
protected $validMethods = ['GET', 'POST', 'DELETE'];
}

View File

@ -1,191 +0,0 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\API\MAL;
use function Amp\Promise\wait;
use Aviat\AnimeClient\API\{
HummingbirdClient,
MAL as M,
XML
};
trait MALTrait {
/**
* The request builder for the MAL API
* @var MALRequestBuilder
*/
protected $requestBuilder;
/**
* The base url for api requests
* @var string $base_url
*/
protected $baseUrl = M::BASE_URL;
/**
* HTTP headers to send with every request
*
* @var array
*/
protected $defaultHeaders = [
'Accept' => 'text/xml',
'Accept-Encoding' => 'gzip',
'Content-type' => 'application/x-www-form-urlencoded',
'User-Agent' => "Tim's Anime Client/4.0"
];
/**
* Set the request builder object
*
* @param MALRequestBuilder $requestBuilder
* @return self
*/
public function setRequestBuilder($requestBuilder): self
{
$this->requestBuilder = $requestBuilder;
return $this;
}
/**
* Create a request object
*
* @param string $type
* @param string $url
* @param array $options
* @return \Amp\Artax\Response
*/
public function setUpRequest(string $type, string $url, array $options = [])
{
$config = $this->container->get('config');
$request = $this->requestBuilder
->newRequest($type, $url)
->setBasicAuth($config->get(['mal','username']), $config->get(['mal','password']));
if (array_key_exists('query', $options))
{
$request = $request->setQuery($options['query']);
}
if (array_key_exists('body', $options))
{
$request = $request->setBody($options['body']);
}
return $request->getFullRequest();
}
/**
* Make a request
*
* @param string $type
* @param string $url
* @param array $options
* @return \Amp\Artax\Response
*/
private function getResponse(string $type, string $url, array $options = [])
{
$logger = NULL;
if ($this->getContainer())
{
$logger = $this->container->getLogger('mal-request');
}
$request = $this->setUpRequest($type, $url, $options);
$response = wait((new HummingbirdClient)->request($request));
$logger->debug('MAL api response', [
'status' => $response->getStatus(),
'reason' => $response->getReason(),
'body' => $response->getBody(),
'headers' => $response->getHeaders(),
'requestHeaders' => $request->getHeaders(),
]);
return $response;
}
/**
* Make a request
*
* @param string $type
* @param string $url
* @param array $options
* @return array
*/
private function request(string $type, string $url, array $options = []): array
{
$logger = NULL;
if ($this->getContainer())
{
$logger = $this->container->getLogger('mal-request');
}
$response = $this->getResponse($type, $url, $options);
if ((int) $response->getStatus() > 299 OR (int) $response->getStatus() < 200)
{
if ($logger)
{
$logger->warning('Non 200 response for api call', (array)$response->getBody());
}
}
return XML::toArray(wait($response->getBody()));
}
/**
* Remove some boilerplate for get requests
*
* @param mixed ...$args
* @return array
*/
protected function getRequest(...$args): array
{
return $this->request('GET', ...$args);
}
/**
* Remove some boilerplate for post requests
*
* @param mixed ...$args
* @return array
*/
protected function postRequest(...$args): array
{
$logger = NULL;
if ($this->getContainer())
{
$logger = $this->container->getLogger('mal-request');
}
$response = $this->getResponse('POST', ...$args);
$validResponseCodes = [200, 201];
if ( ! \in_array((int) $response->getStatus(), $validResponseCodes, TRUE))
{
if ($logger)
{
$logger->warning('Non 201 response for POST api call', (array)$response->getBody());
}
}
return XML::toArray($response->getBody());
}
}

View File

@ -1,182 +0,0 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\API\MAL;
use Amp\Artax\Request;
use Aviat\AnimeClient\API\MAL\{
ListItem,
Transformer\AnimeListTransformer,
Transformer\MangaListTransformer
};
use Aviat\AnimeClient\API\XML;
use Aviat\AnimeClient\API\Mapping\{AnimeWatchingStatus, MangaReadingStatus};
use Aviat\AnimeClient\Types\{Anime, FormItem};
use Aviat\Ion\Di\ContainerAware;
/**
* MyAnimeList API Model
*/
final class Model {
use ContainerAware;
use MALTrait;
/**
* @var AnimeListTransformer
*/
protected $animeListTransformer;
/**
* @var MangaListTransformer
*/
protected $mangaListTransformer;
/**
* @var ListItem
*/
protected $listItem;
/**
* MAL Model constructor.
*
* @param ListItem $listItem
*/
public function __construct(ListItem $listItem)
{
$this->animeListTransformer = new AnimeListTransformer();
$this->mangaListTransformer = new MangaListTransformer();
$this->listItem = $listItem;
}
/**
* Create a list item on MAL
*
* @param array $data
* @param string $type "anime" or "manga"
* @return Request
*/
public function createFullListItem(array $data, string $type = 'anime'): Request
{
return $this->listItem->create($data, $type);
}
/**
* Create a list item on MAL from a Kitsu list item
*
* @param array $data
* @param string $type "anime" or "manga"
* @return Request
*/
public function createListItem(array $data, string $type = 'anime'): Request
{
$createData = [];
if ($type === 'anime')
{
$createData = [
'id' => $data['id'],
'data' => [
'status' => AnimeWatchingStatus::KITSU_TO_MAL[$data['status']]
]
];
}
elseif ($type === 'manga')
{
$createData = [
'id' => $data['id'],
'data' => [
'status' => MangaReadingStatus::KITSU_TO_MAL[$data['status']]
]
];
}
return $this->listItem->create($createData, $type);
}
/**
* Get list info
*
* @param string $type "anime" or "manga"
* @return array
*/
public function getList(string $type = "anime"): array
{
$config = $this->container->get('config');
$userName = $config->get(['mal', 'username']);
$list = $this->getRequest('https://myanimelist.net/malappinfo.php', [
'headers' => [
'Accept' => 'text/xml'
],
'query' => [
'u' => $userName,
'status' => 'all',
'type' => $type
]
]);
return array_key_exists($type, $list['myanimelist'])
? $list['myanimelist'][$type]
: [];
}
/**
* Retrieve a list item
*
* Does not apply to MAL
*
* @param string $listId
* @return array
*/
public function getListItem(string $listId): array
{
return [];
}
/**
* Update a list item
*
* @param array $data
* @param string $type "anime" or "manga"
* @return Request
*/
public function updateListItem($data, string $type = 'anime'): Request
{
$updateData = [];
if ($type === 'anime')
{
$updateData = $this->animeListTransformer->untransform($data);
}
else if ($type === 'manga')
{
$updateData = $this->mangaListTransformer->untransform($data);
}
return $this->listItem->update($updateData['id'], $updateData['data'], $type);
}
/**
* Delete a list item
*
* @param string $id
* @param string $type "anime" or "manga"
* @return Request
*/
public function deleteListItem(string $id, string $type = 'anime'): Request
{
return $this->listItem->delete($id, $type);
}
}

View File

@ -1,86 +0,0 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\API\MAL\Transformer;
use Aviat\AnimeClient\API\Mapping\AnimeWatchingStatus;
use Aviat\AnimeClient\Types\AnimeFormItem;
use Aviat\Ion\Transformer\AbstractTransformer;
/**
* Transformer for updating MAL List
*/
final class AnimeListTransformer extends AbstractTransformer {
/**
* Identity transformation
*
* @param array $item
* @return array
*/
public function transform($item)
{
return $item;
}
/**
* Transform Kitsu episode data to MAL episode data
*
* @param mixed $item
* @return array
*/
public function untransform($item): array
{
$map = [
'id' => $item['mal_id'],
'data' => [],
];
foreach($item['data'] as $key => $value)
{
switch($key)
{
case 'progress':
$map['data']['episode'] = $value;
break;
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'] = AnimeWatchingStatus::KITSU_TO_MAL[$value];
break;
default:
break;
}
}
return $map;
}
}

View File

@ -1,85 +0,0 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\API\MAL\Transformer;
use Aviat\AnimeClient\API\Mapping\MangaReadingStatus;
use Aviat\Ion\Transformer\AbstractTransformer;
/**
* Transformer for updating MAL List
*/
final class MangaListTransformer extends AbstractTransformer {
/**
* Identity transformation
*
* @param array $item
* @return array
*/
public function transform($item)
{
return $item;
}
/**
* Transform Kitsu data to MAL data
*
* @param mixed $item
* @return
*/
public function untransform($item): array
{
$map = [
'id' => $item['mal_id'] ?? $item['malId'],
'data' => []
];
foreach($item['data'] as $key => $value)
{
switch($key)
{
case 'progress':
$map['data']['chapter'] = $value;
break;
case 'notes':
$map['data']['comments'] = $value;
break;
case 'rating':
$map['data']['score'] = $value * 2;
break;
case 'reconsuming':
$map['data']['enable_rereading'] = (bool) $value;
break;
case 'reconsumeCount':
$map['data']['times_reread'] = $value;
break;
case 'status':
$map['data']['status'] = MangaReadingStatus::KITSU_TO_MAL[$value];
break;
default:
break;
}
}
return $map;
}
}

View File

@ -16,7 +16,7 @@
namespace Aviat\AnimeClient\API\Mapping; namespace Aviat\AnimeClient\API\Mapping;
use Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\{Anilist, Kitsu, MAL, Route, Title}; use Aviat\AnimeClient\API\Enum\AnimeWatchingStatus\{Anilist, Kitsu, Route, Title};
use Aviat\Ion\Enum; use Aviat\Ion\Enum;
/** /**
@ -29,9 +29,9 @@ final class AnimeWatchingStatus extends Enum {
Anilist::PLAN_TO_WATCH => Kitsu::PLAN_TO_WATCH, Anilist::PLAN_TO_WATCH => Kitsu::PLAN_TO_WATCH,
Anilist::COMPLETED => Kitsu::COMPLETED, Anilist::COMPLETED => Kitsu::COMPLETED,
Anilist::ON_HOLD => Kitsu::ON_HOLD, Anilist::ON_HOLD => Kitsu::ON_HOLD,
Anilist::DROPPED => Kitsu::DROPPED Anilist::DROPPED => Kitsu::DROPPED
]; ];
const KITSU_TO_ANILIST = [ const KITSU_TO_ANILIST = [
Kitsu::WATCHING => Anilist::WATCHING, Kitsu::WATCHING => Anilist::WATCHING,
Kitsu::PLAN_TO_WATCH => Anilist::PLAN_TO_WATCH, Kitsu::PLAN_TO_WATCH => Anilist::PLAN_TO_WATCH,
@ -39,14 +39,6 @@ final class AnimeWatchingStatus extends Enum {
Kitsu::ON_HOLD => Anilist::ON_HOLD, Kitsu::ON_HOLD => Anilist::ON_HOLD,
Kitsu::DROPPED => Anilist::DROPPED Kitsu::DROPPED => Anilist::DROPPED
]; ];
const KITSU_TO_MAL = [
Kitsu::WATCHING => MAL::WATCHING,
Kitsu::PLAN_TO_WATCH => MAL::PLAN_TO_WATCH,
Kitsu::COMPLETED => MAL::COMPLETED,
Kitsu::ON_HOLD => MAL::ON_HOLD,
Kitsu::DROPPED => MAL::DROPPED
];
const KITSU_TO_TITLE = [ const KITSU_TO_TITLE = [
Kitsu::WATCHING => Title::WATCHING, Kitsu::WATCHING => Title::WATCHING,
@ -56,14 +48,6 @@ final class AnimeWatchingStatus extends Enum {
Kitsu::COMPLETED => Title::COMPLETED Kitsu::COMPLETED => Title::COMPLETED
]; ];
const MAL_TO_KITSU = [
MAL::WATCHING => Kitsu::WATCHING,
MAL::PLAN_TO_WATCH => Kitsu::PLAN_TO_WATCH,
MAL::COMPLETED => Kitsu::COMPLETED,
MAL::ON_HOLD => Kitsu::ON_HOLD,
MAL::DROPPED => Kitsu::DROPPED
];
const ROUTE_TO_KITSU = [ const ROUTE_TO_KITSU = [
Route::WATCHING => Kitsu::WATCHING, Route::WATCHING => Kitsu::WATCHING,
Route::PLAN_TO_WATCH => Kitsu::PLAN_TO_WATCH, Route::PLAN_TO_WATCH => Kitsu::PLAN_TO_WATCH,

View File

@ -16,7 +16,7 @@
namespace Aviat\AnimeClient\API\Mapping; namespace Aviat\AnimeClient\API\Mapping;
use Aviat\AnimeClient\API\Enum\MangaReadingStatus\{Anilist, Kitsu, MAL, Title, Route}; use Aviat\AnimeClient\API\Enum\MangaReadingStatus\{Anilist, Kitsu, Title, Route};
use Aviat\Ion\Enum; use Aviat\Ion\Enum;
/** /**
@ -29,9 +29,9 @@ final class MangaReadingStatus extends Enum {
Anilist::PLAN_TO_READ => Kitsu::PLAN_TO_READ, Anilist::PLAN_TO_READ => Kitsu::PLAN_TO_READ,
Anilist::COMPLETED => Kitsu::COMPLETED, Anilist::COMPLETED => Kitsu::COMPLETED,
Anilist::ON_HOLD => Kitsu::ON_HOLD, Anilist::ON_HOLD => Kitsu::ON_HOLD,
Anilist::DROPPED => Kitsu::DROPPED Anilist::DROPPED => Kitsu::DROPPED
]; ];
const KITSU_TO_ANILIST = [ const KITSU_TO_ANILIST = [
Kitsu::READING => Anilist::READING, Kitsu::READING => Anilist::READING,
Kitsu::PLAN_TO_READ => Anilist::PLAN_TO_READ, Kitsu::PLAN_TO_READ => Anilist::PLAN_TO_READ,
@ -39,28 +39,6 @@ final class MangaReadingStatus extends Enum {
Kitsu::ON_HOLD => Anilist::ON_HOLD, Kitsu::ON_HOLD => Anilist::ON_HOLD,
Kitsu::DROPPED => Anilist::DROPPED Kitsu::DROPPED => Anilist::DROPPED
]; ];
const KITSU_TO_MAL = [
Kitsu::READING => MAL::READING,
Kitsu::PLAN_TO_READ => MAL::PLAN_TO_READ,
Kitsu::COMPLETED => MAL::COMPLETED,
Kitsu::ON_HOLD => MAL::ON_HOLD,
Kitsu::DROPPED => MAL::DROPPED
];
const MAL_TO_KITSU = [
'1' => Kitsu::READING,
'2' => Kitsu::COMPLETED,
'3' => Kitsu::ON_HOLD,
'4' => Kitsu::DROPPED,
'6' => Kitsu::PLAN_TO_READ,
MAL::READING => Kitsu::READING,
MAL::COMPLETED => Kitsu::COMPLETED,
MAL::ON_HOLD => Kitsu::ON_HOLD,
MAL::DROPPED => Kitsu::DROPPED,
MAL::PLAN_TO_READ => Kitsu::PLAN_TO_READ,
];
const KITSU_TO_TITLE = [ const KITSU_TO_TITLE = [
Kitsu::READING => Title::READING, Kitsu::READING => Title::READING,

View File

@ -21,9 +21,8 @@ use function Aviat\AnimeClient\loadToml;
use Aura\Session\SessionFactory; use Aura\Session\SessionFactory;
use Aviat\AnimeClient\Util; use Aviat\AnimeClient\Util;
use Aviat\AnimeClient\API\CacheTrait; use Aviat\AnimeClient\API\CacheTrait;
use Aviat\AnimeClient\API\{Kitsu, MAL}; use Aviat\AnimeClient\API\Kitsu;
use Aviat\AnimeClient\API\Kitsu\KitsuRequestBuilder; use Aviat\AnimeClient\API\Kitsu\KitsuRequestBuilder;
use Aviat\AnimeClient\API\MAL\MALRequestBuilder;
use Aviat\Banker\Pool; use Aviat\Banker\Pool;
use Aviat\Ion\Config; use Aviat\Ion\Config;
use Aviat\Ion\Di\{Container, ContainerAware}; use Aviat\Ion\Di\{Container, ContainerAware};
@ -86,11 +85,8 @@ class BaseCommand extends Command {
$app_logger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/app-cli.log', Logger::NOTICE)); $app_logger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/app-cli.log', Logger::NOTICE));
$kitsu_request_logger = new Logger('kitsu-request'); $kitsu_request_logger = new Logger('kitsu-request');
$kitsu_request_logger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/kitsu_request-cli.log', Logger::NOTICE)); $kitsu_request_logger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/kitsu_request-cli.log', Logger::NOTICE));
$mal_request_logger = new Logger('mal-request');
$mal_request_logger->pushHandler(new RotatingFileHandler($APP_DIR . '/logs/mal_request-cli.log', Logger::NOTICE));
$container->setLogger($app_logger); $container->setLogger($app_logger);
$container->setLogger($kitsu_request_logger, 'kitsu-request'); $container->setLogger($kitsu_request_logger, 'kitsu-request');
$container->setLogger($mal_request_logger, 'mal-request');
// Create Config Object // Create Config Object
$container->set('config', function() use ($config_array) { $container->set('config', function() use ($config_array) {
@ -126,19 +122,6 @@ class BaseCommand extends Command {
$model->setCache($cache); $model->setCache($cache);
return $model; return $model;
}); });
$container->set('mal-model', function($container) {
$requestBuilder = new MALRequestBuilder();
$requestBuilder->setLogger($container->getLogger('mal-request'));
$listItem = new MAL\ListItem();
$listItem->setContainer($container);
$listItem->setRequestBuilder($requestBuilder);
$model = new MAL\Model($listItem);
$model->setContainer($container);
$model->setRequestBuilder($requestBuilder);
return $model;
});
$container->set('util', function($container) { $container->set('util', function($container) {
return new Util($container); return new Util($container);

View File

@ -19,12 +19,7 @@ namespace Aviat\AnimeClient\Command;
use Aviat\AnimeClient\API\{ use Aviat\AnimeClient\API\{
FailedResponseException, FailedResponseException,
JsonAPI, JsonAPI,
ParallelAPIRequest, ParallelAPIRequest
Mapping\AnimeWatchingStatus,
Mapping\MangaReadingStatus
};
use Aviat\AnimeClient\API\MAL\Transformer\{
AnimeListTransformer as ALT
}; };
use Aviat\Ion\Json; use Aviat\Ion\Json;
use DateTime; use DateTime;
@ -40,12 +35,6 @@ final class SyncLists extends BaseCommand {
*/ */
protected $kitsuModel; protected $kitsuModel;
/**
* Model for making requests to MAL API
* @var \Aviat\AnimeClient\API\MAL\Model
*/
protected $malModel;
/** /**
* Run the Kitsu <=> MAL sync script * Run the Kitsu <=> MAL sync script
* *
@ -60,7 +49,6 @@ final class SyncLists extends BaseCommand {
$this->setContainer($this->setupContainer()); $this->setContainer($this->setupContainer());
$this->setCache($this->container->get('cache')); $this->setCache($this->container->get('cache'));
$this->kitsuModel = $this->container->get('kitsu-model'); $this->kitsuModel = $this->container->get('kitsu-model');
$this->malModel = $this->container->get('mal-model');
$this->sync('anime'); $this->sync('anime');
$this->sync('manga'); $this->sync('manga');
@ -78,7 +66,7 @@ final class SyncLists extends BaseCommand {
// Do a little check to make sure you don't have immediate issues // Do a little check to make sure you don't have immediate issues
// if you have 0 or 1 items in a list on MAL. // if you have 0 or 1 items in a list on MAL.
$malList = $this->malModel->getList($type); /* $malList = $this->malModel->getList($type);
$malCount = 0; $malCount = 0;
if ( ! empty($malList)) if ( ! empty($malList))
{ {
@ -86,7 +74,7 @@ final class SyncLists extends BaseCommand {
? $malList ? $malList
: [$malList] : [$malList]
); );
} } */
$kitsuCount = 0; $kitsuCount = 0;
try try
@ -99,12 +87,12 @@ final class SyncLists extends BaseCommand {
} }
$this->echoBox("Number of MAL {$type} list items: {$malCount}"); // $this->echoBox("Number of MAL {$type} list items: {$malCount}");
$this->echoBox("Number of Kitsu {$type} list items: {$kitsuCount}"); $this->echoBox("Number of Kitsu {$type} list items: {$kitsuCount}");
$data = $this->diffLists($type); $data = $this->diffLists($type);
if ( ! empty($data['addToMAL'])) /* if ( ! empty($data['addToMAL']))
{ {
$count = count($data['addToMAL']); $count = count($data['addToMAL']);
$this->echoBox("Adding {$count} missing {$type} list items to MAL"); $this->echoBox("Adding {$count} missing {$type} list items to MAL");
@ -116,7 +104,7 @@ final class SyncLists extends BaseCommand {
$count = count($data['updateMAL']); $count = count($data['updateMAL']);
$this->echoBox("Updating {$count} outdated MAL {$type} list items"); $this->echoBox("Updating {$count} outdated MAL {$type} list items");
$this->updateMALListItems($data['updateMAL'], 'update', $type); $this->updateMALListItems($data['updateMAL'], 'update', $type);
} } */
if ( ! empty($data['addToKitsu'])) if ( ! empty($data['addToKitsu']))
{ {
@ -161,19 +149,19 @@ final class SyncLists extends BaseCommand {
* @param string $type * @param string $type
* @return array * @return array
*/ */
protected function formatMALList(string $type): array /* protected function formatMALList(string $type): array
{ {
$type = ucfirst($type); $type = ucfirst($type);
$method = "formatMAL{$type}List"; $method = "formatMAL{$type}List";
return $this->$method(); return $this->$method();
} } */
/** /**
* Format a MAL anime list for comparison * Format a MAL anime list for comparison
* *
* @return array * @return array
*/ */
protected function formatMALAnimeList(): array /* protected function formatMALAnimeList(): array
{ {
$orig = $this->malModel->getList('anime'); $orig = $this->malModel->getList('anime');
$output = []; $output = [];
@ -210,14 +198,14 @@ final class SyncLists extends BaseCommand {
} }
return $output; return $output;
} } */
/** /**
* Format a MAL manga list for comparison * Format a MAL manga list for comparison
* *
* @return array * @return array
*/ */
protected function formatMALMangaList(): array /* protected function formatMALMangaList(): array
{ {
$orig = $this->malModel->getList('manga'); $orig = $this->malModel->getList('manga');
$output = []; $output = [];
@ -256,7 +244,7 @@ final class SyncLists extends BaseCommand {
} }
return $output; return $output;
} } */
/** /**
* Format a kitsu list for the sake of comparision * Format a kitsu list for the sake of comparision
@ -322,26 +310,26 @@ final class SyncLists extends BaseCommand {
$kitsuList = $this->formatKitsuList($type); $kitsuList = $this->formatKitsuList($type);
// Get MAL list data // Get MAL list data
$malList = $this->formatMALList($type); // $malList = $this->formatMALList($type);
$itemsToAddToMAL = []; $itemsToAddToMAL = [];
$itemsToAddToKitsu = []; $itemsToAddToKitsu = [];
$malUpdateItems = []; $malUpdateItems = [];
$kitsuUpdateItems = []; $kitsuUpdateItems = [];
$malIds = array_column($malList, 'id'); // $malIds = array_column($malList, 'id');
$kitsuMalIds = array_column($kitsuList, 'malId'); // $kitsuMalIds = array_column($kitsuList, 'malId');
$missingMalIds = array_diff($malIds, $kitsuMalIds); // $missingMalIds = array_diff($malIds, $kitsuMalIds);
foreach($missingMalIds as $mid) /* foreach($missingMalIds as $mid)
{ {
$itemsToAddToKitsu[] = array_merge($malList[$mid]['data'], [ $itemsToAddToKitsu[] = array_merge($malList[$mid]['data'], [
'id' => $this->kitsuModel->getKitsuIdFromMALId($mid, $type), 'id' => $this->kitsuModel->getKitsuIdFromMALId($mid, $type),
'type' => $type 'type' => $type
]); ]);
} } */
foreach($kitsuList as $kitsuItem) /* foreach($kitsuList as $kitsuItem)
{ {
if (\in_array($kitsuItem['malId'], $malIds, TRUE)) if (\in_array($kitsuItem['malId'], $malIds, TRUE))
{ {
@ -371,11 +359,11 @@ final class SyncLists extends BaseCommand {
'data' => $kitsuItem['data'] 'data' => $kitsuItem['data']
]; ];
} } */
return [ return [
'addToMAL' => $itemsToAddToMAL, // 'addToMAL' => $itemsToAddToMAL,
'updateMAL' => $malUpdateItems, // 'updateMAL' => $malUpdateItems,
'addToKitsu' => $itemsToAddToKitsu, 'addToKitsu' => $itemsToAddToKitsu,
'updateKitsu' => $kitsuUpdateItems 'updateKitsu' => $kitsuUpdateItems
]; ];
@ -555,7 +543,7 @@ final class SyncLists extends BaseCommand {
* @param string $action * @param string $action
* @param string $type * @param string $type
*/ */
protected function updateMALListItems(array$itemsToUpdate, string $action = 'update', string $type = 'anime'): void /* protected function updateMALListItems(array$itemsToUpdate, string $action = 'update', string $type = 'anime'): void
{ {
$transformer = new ALT(); $transformer = new ALT();
$requester = new ParallelAPIRequest(); $requester = new ParallelAPIRequest();
@ -593,5 +581,5 @@ final class SyncLists extends BaseCommand {
$this->echoBox("Failed to {$verb} MAL {$type} list item with id: {$id}"); $this->echoBox("Failed to {$verb} MAL {$type} list item with id: {$id}");
} }
} }
} } */
} }

View File

@ -24,13 +24,6 @@ use Aviat\Ion\StringWrapper;
class API { class API {
use StringWrapper; use StringWrapper;
/**
* Whether to use the MAL api
*
* @var boolean
*/
protected $useMALAPI;
/** /**
* Sort the list entries by their title * Sort the list entries by their title
* *

View File

@ -37,13 +37,6 @@ class Anime extends API {
*/ */
protected $kitsuModel; protected $kitsuModel;
/**
* Model for making requests to MAL API
*
* @var \Aviat\AnimeClient\API\MAL\Model
*/
protected $malModel;
/** /**
* Anime constructor. * Anime constructor.
* *
@ -52,10 +45,6 @@ class Anime extends API {
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
$this->kitsuModel = $container->get('kitsu-model'); $this->kitsuModel = $container->get('kitsu-model');
$this->malModel = $container->get('mal-model');
$config = $container->get('config');
$this->useMALAPI = $config->get(['use_mal_api']) === TRUE;
} }
/** /**
@ -148,19 +137,6 @@ class Anime extends API {
public function createLibraryItem(array $data): bool public function createLibraryItem(array $data): bool
{ {
$requester = new ParallelAPIRequest(); $requester = new ParallelAPIRequest();
if ($this->useMALAPI)
{
$malData = $data;
$malId = $this->kitsuModel->getMalIdForAnime($malData['id']);
if ($malId !== NULL)
{
$malData['id'] = $malId;
$requester->addRequest($this->malModel->createListItem($malData), 'mal');
}
}
$requester->addRequest($this->kitsuModel->createListItem($data), 'kitsu'); $requester->addRequest($this->kitsuModel->createListItem($data), 'kitsu');
$results = $requester->makeRequests(); $results = $requester->makeRequests();
@ -177,12 +153,6 @@ class Anime extends API {
public function updateLibraryItem(AnimeFormItem $data): array public function updateLibraryItem(AnimeFormItem $data): array
{ {
$requester = new ParallelAPIRequest(); $requester = new ParallelAPIRequest();
if ($this->useMALAPI)
{
$requester->addRequest($this->malModel->updateListItem($data), 'mal');
}
$requester->addRequest($this->kitsuModel->updateListItem($data), 'kitsu'); $requester->addRequest($this->kitsuModel->updateListItem($data), 'kitsu');
$results = $requester->makeRequests(); $results = $requester->makeRequests();
@ -205,12 +175,6 @@ class Anime extends API {
public function deleteLibraryItem(string $id, string $malId = NULL): bool public function deleteLibraryItem(string $id, string $malId = NULL): bool
{ {
$requester = new ParallelAPIRequest(); $requester = new ParallelAPIRequest();
if ($this->useMALAPI && $malId !== NULL)
{
$requester->addRequest($this->malModel->deleteListItem($malId), 'MAL');
}
$requester->addRequest($this->kitsuModel->deleteListItem($id), 'kitsu'); $requester->addRequest($this->kitsuModel->deleteListItem($id), 'kitsu');
$results = $requester->makeRequests(); $results = $requester->makeRequests();

View File

@ -39,12 +39,6 @@ class Manga extends API {
*/ */
protected $kitsuModel; protected $kitsuModel;
/**
* Model for making requests to MAL API
* @var \Aviat\AnimeClient\API\MAL\Model
*/
protected $malModel;
/** /**
* Constructor * Constructor
* *
@ -55,10 +49,6 @@ class Manga extends API {
public function __construct(ContainerInterface $container) public function __construct(ContainerInterface $container)
{ {
$this->kitsuModel = $container->get('kitsu-model'); $this->kitsuModel = $container->get('kitsu-model');
$this->malModel = $container->get('mal-model');
$config = $container->get('config');
$this->useMALAPI = $config->get(['use_mal_api']) === TRUE;
} }
/** /**
@ -76,7 +66,7 @@ class Manga extends API {
{ {
$this->sortByName($section, 'manga'); $this->sortByName($section, 'manga');
} }
return $data; return $data;
} }
@ -129,19 +119,6 @@ class Manga extends API {
public function createLibraryItem(array $data): bool public function createLibraryItem(array $data): bool
{ {
$requester = new ParallelAPIRequest(); $requester = new ParallelAPIRequest();
if ($this->useMALAPI)
{
$malData = $data;
$malId = $this->kitsuModel->getMalIdForManga($malData['id']);
if ($malId !== NULL)
{
$malData['id'] = $malId;
$requester->addRequest($this->malModel->createListItem($malData, 'manga'), 'mal');
}
}
$requester->addRequest($this->kitsuModel->createListItem($data), 'kitsu'); $requester->addRequest($this->kitsuModel->createListItem($data), 'kitsu');
$results = $requester->makeRequests(); $results = $requester->makeRequests();
@ -158,12 +135,6 @@ class Manga extends API {
public function updateLibraryItem(MangaFormItem $data): array public function updateLibraryItem(MangaFormItem $data): array
{ {
$requester = new ParallelAPIRequest(); $requester = new ParallelAPIRequest();
if ($this->useMALAPI)
{
$requester->addRequest($this->malModel->updateListItem($data, 'manga'), 'mal');
}
$requester->addRequest($this->kitsuModel->updateListItem($data), 'kitsu'); $requester->addRequest($this->kitsuModel->updateListItem($data), 'kitsu');
$results = $requester->makeRequests(); $results = $requester->makeRequests();
@ -186,12 +157,6 @@ class Manga extends API {
public function deleteLibraryItem(string $id, string $malId = NULL): bool public function deleteLibraryItem(string $id, string $malId = NULL): bool
{ {
$requester = new ParallelAPIRequest(); $requester = new ParallelAPIRequest();
if ($this->useMALAPI && $malId !== NULL)
{
$requester->addRequest($this->malModel->deleteListItem($malId, 'manga'), 'MAL');
}
$requester->addRequest($this->kitsuModel->deleteListItem($id), 'kitsu'); $requester->addRequest($this->kitsuModel->deleteListItem($id), 'kitsu');
$results = $requester->makeRequests(); $results = $requester->makeRequests();

View File

@ -1,40 +0,0 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\Tests\API\MAL;
use Aviat\AnimeClient\API\MAL\ListItem;
use Aviat\AnimeClient\API\MAL\MALRequestBuilder;
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
use Aviat\Ion\Di\ContainerAware;
class ListItemTest extends AnimeClientTestCase {
protected $listItem;
public function setUp()
{
parent::setUp();
$this->listItem = new ListItem();
$this->listItem->setContainer($this->container);
$this->listItem->setRequestBuilder(new MALRequestBuilder());
}
public function testGet()
{
$this->assertEquals([], $this->listItem->get('foo'));
}
}

View File

@ -1,50 +0,0 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\Tests\API\MAL;
use Aviat\AnimeClient\API\MAL\MALRequestBuilder;
use Aviat\AnimeClient\API\MAL\MALTrait;
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
use Aviat\Ion\Di\ContainerAware;
class MALTraitTest extends AnimeClientTestCase {
protected $obj;
public function setUp()
{
parent::setUp();
$this->obj = new class {
use ContainerAware;
use MALTrait;
};
$this->obj->setContainer($this->container);
$this->obj->setRequestBuilder(new MALRequestBuilder());
}
public function testSetupRequest()
{
$request = $this->obj->setUpRequest('GET', 'foo', [
'query' => [
'foo' => 'bar'
],
'body' => ''
]);
$this->assertInstanceOf(\Amp\Artax\Request::class, $request);
$this->assertEquals($request->getUri(), 'https://myanimelist.net/api/foo?foo=bar');
}
}

View File

@ -1,35 +0,0 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\Tests\API\MAL;
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
class ModelTest extends AnimeClientTestCase {
protected $model;
public function setUp()
{
parent::setUp();
$this->model = $this->container->get('mal-model');
}
public function testGetListItem()
{
$this->assertEquals([], $this->model->getListItem('foo'));
}
}

View File

@ -1,39 +0,0 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\Tests\API\MAL\Transformer;
use Aviat\AnimeClient\API\MAL\Transformer\AnimeListTransformer;
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
use Aviat\Ion\Friend;
use Aviat\Ion\Json;
class AnimeListTransformerTest extends AnimeClientTestCase {
protected $transformer;
public function setUp()
{
parent::setUp();
$this->transformer = new AnimeListTransformer();
}
public function testTransform()
{
$this->assertEquals([], $this->transformer->transform([]));
}
}

View File

@ -1,39 +0,0 @@
<?php declare(strict_types=1);
/**
* Hummingbird Anime List Client
*
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
*
* PHP version 7
*
* @package HummingbirdAnimeClient
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2018 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 4.0
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
*/
namespace Aviat\AnimeClient\Tests\API\MAL\Transformer;
use Aviat\AnimeClient\API\MAL\Transformer\MangaListTransformer;
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
use Aviat\Ion\Friend;
use Aviat\Ion\Json;
class MangaListTransformerTest extends AnimeClientTestCase {
protected $transformer;
public function setUp()
{
parent::setUp();
$this->transformer = new MangaListTransformer();
}
public function testTransform()
{
$this->assertEquals([], $this->transformer->transform([]));
}
}