Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
16 changed files with 39 additions and 46 deletions
Showing only changes of commit 65a8da755a - Show all commits

View File

@ -19,12 +19,7 @@ namespace Aviat\AnimeClient;
use Aura\Html\HelperLocatorFactory;
use Aura\Router\RouterContainer;
use Aura\Session\SessionFactory;
use Aviat\AnimeClient\API\{
Anilist,
Anilist\AnilistRequestBuilder,
Kitsu,
Kitsu\KitsuRequestBuilder
};
use Aviat\AnimeClient\API\{Anilist, Kitsu};
use Aviat\AnimeClient\Model;
use Aviat\Banker\Teller;
use Aviat\Ion\Config;
@ -114,7 +109,7 @@ return static function (array $configArray = []): Container {
// Models
$container->set('kitsu-model', static function(ContainerInterface $container): Kitsu\Model {
$requestBuilder = new KitsuRequestBuilder($container);
$requestBuilder = new Kitsu\RequestBuilder($container);
$requestBuilder->setLogger($container->getLogger('kitsu-request'));
$listItem = new Kitsu\ListItem();
@ -130,7 +125,7 @@ return static function (array $configArray = []): Container {
return $model;
});
$container->set('anilist-model', static function(ContainerInterface $container): Anilist\Model {
$requestBuilder = new AnilistRequestBuilder($container);
$requestBuilder = new Anilist\RequestBuilder($container);
$requestBuilder->setLogger($container->getLogger('anilist-request'));
$listItem = new Anilist\ListItem();

View File

@ -34,7 +34,7 @@ use function Aviat\AnimeClient\getLocalImg;
</tr>
<?php endif ?>
<?php if (isset($data['total_length'], $data['episode_count'])): ?>
<?php if (isset($data['total_length'], $data['episode_count']) && ! empty($data['total_length'])): ?>
<tr>
<td>Total Length</td>
<td><?= Kitsu::friendlyTime($data['total_length']) ?></td>

View File

@ -32,6 +32,14 @@ abstract class AbstractListItem {
*/
abstract public function create(array $data): Request;
/**
* Create a full list item for syncing
*
* @param array $data
* @return Request
*/
abstract public function createFull(array $data): Request;
/**
* Retrieve a list item
*

View File

@ -27,7 +27,7 @@ use Aviat\AnimeClient\Types\FormItemData;
* CRUD operations for MAL list items
*/
final class ListItem extends AbstractListItem {
use AnilistTrait;
use RequestBuilderTrait;
/**
* Create a minimal list item

View File

@ -35,7 +35,7 @@ use Throwable;
*/
final class Model
{
use AnilistTrait;
use RequestBuilderTrait;
/**
* @var ListItem
*/

View File

@ -30,7 +30,7 @@ use const Aviat\AnimeClient\USER_AGENT;
use Aviat\AnimeClient\API\APIRequestBuilder;
final class AnilistRequestBuilder extends APIRequestBuilder {
final class RequestBuilder extends APIRequestBuilder {
use ContainerAware;
/**

View File

@ -18,19 +18,19 @@ namespace Aviat\AnimeClient\API\Anilist;
use Aviat\Ion\Di\ContainerAware;
trait AnilistTrait {
trait RequestBuilderTrait {
use ContainerAware;
/**
* The request builder for the Anilist API
* @var AnilistRequestBuilder
* @var RequestBuilder
*/
protected AnilistRequestBuilder $requestBuilder;
protected RequestBuilder $requestBuilder;
/**
* Set the request builder object
*
* @param AnilistRequestBuilder $requestBuilder
* @param RequestBuilder $requestBuilder
* @return self
*/
public function setRequestBuilder($requestBuilder): self

View File

@ -33,7 +33,7 @@ use Aviat\Ion\Json;
/**
* Anime-related list methods
*/
trait KitsuAnimeTrait {
trait AnimeTrait {
/**
* Class to map anime list items
* to a common format used by

View File

@ -35,7 +35,7 @@ use Throwable;
*/
final class ListItem extends AbstractListItem {
use ContainerAware;
use KitsuTrait;
use RequestBuilderTrait;
/**
* @param array $data

View File

@ -33,7 +33,7 @@ use Aviat\Ion\Json;
/**
* Manga-related list methods
*/
trait KitsuMangaTrait {
trait MangaTrait {
/**
* @var MangaTransformer
*/

View File

@ -43,10 +43,10 @@ use Throwable;
final class Model {
use CacheTrait;
use ContainerAware;
use KitsuTrait;
use KitsuAnimeTrait;
use KitsuMangaTrait;
use KitsuMutationTrait;
use RequestBuilderTrait;
use AnimeTrait;
use MangaTrait;
use MutationTrait;
protected const LIST_PAGE_SIZE = 100;

View File

@ -23,7 +23,7 @@ use Aviat\Banker\Exception\InvalidArgumentException;
/**
* Kitsu API calls that mutate data, C/U/D parts of CRUD
*/
trait KitsuMutationTrait {
trait MutationTrait {
// -------------------------------------------------------------------------
// ! Generic API calls
// -------------------------------------------------------------------------

View File

@ -34,7 +34,7 @@ use Aviat\Ion\Event;
use Aviat\Ion\Json;
use Aviat\Ion\JsonException;
final class KitsuRequestBuilder extends APIRequestBuilder {
final class RequestBuilder extends APIRequestBuilder {
use ContainerAware;
/**
@ -397,20 +397,11 @@ final class KitsuRequestBuilder extends APIRequestBuilder {
{
$logger->warning('Non 2xx response for api call', (array)$response);
}
throw new FailedResponseException('Failed to get the proper response from the API');
dump($rawBody);
die();
// throw new FailedResponseException('Failed to get the proper response from the API');
}
try
{
return Json::decode(wait($response->getBody()->buffer()));
}
catch (JsonException $e)
{
print_r($e);
die();
}
return Json::decode($rawBody);
}
}

View File

@ -16,20 +16,20 @@
namespace Aviat\AnimeClient\API\Kitsu;
trait KitsuTrait {
trait RequestBuilderTrait {
/**
* The request builder for the Kitsu API
* @var KitsuRequestBuilder
* @var RequestBuilder
*/
protected KitsuRequestBuilder $requestBuilder;
protected RequestBuilder $requestBuilder;
/**
* Set the request builder object
*
* @param KitsuRequestBuilder $requestBuilder
* @param RequestBuilder $requestBuilder
* @return $this
*/
public function setRequestBuilder(KitsuRequestBuilder $requestBuilder): self
public function setRequestBuilder(RequestBuilder $requestBuilder): self
{
$this->requestBuilder = $requestBuilder;
return $this;

View File

@ -23,7 +23,6 @@ use Aura\Router\RouterContainer;
use Aura\Session\SessionFactory;
use Aviat\AnimeClient\{Model, UrlGenerator, Util};
use Aviat\AnimeClient\API\{Anilist, CacheTrait, Kitsu};
use Aviat\AnimeClient\API\Kitsu\KitsuRequestBuilder;
use Aviat\Banker\Teller;
use Aviat\Ion\Config;
use Aviat\Ion\Di\{Container, ContainerInterface, ContainerAware};
@ -187,7 +186,7 @@ abstract class BaseCommand extends Command {
// Models
$container->set('kitsu-model', static function($container): Kitsu\Model {
$requestBuilder = new KitsuRequestBuilder($container);
$requestBuilder = new Kitsu\RequestBuilder($container);
$requestBuilder->setLogger($container->getLogger('kitsu-request'));
$listItem = new Kitsu\ListItem();
@ -203,7 +202,7 @@ abstract class BaseCommand extends Command {
return $model;
});
$container->set('anilist-model', static function ($container): Anilist\Model {
$requestBuilder = new Anilist\AnilistRequestBuilder($container);
$requestBuilder = new Anilist\RequestBuilder($container);
$requestBuilder->setLogger($container->getLogger('anilist-request'));
$listItem = new Anilist\ListItem();