diff --git a/app/bootstrap.php b/app/bootstrap.php
index dc3233d6..d68ead0c 100644
--- a/app/bootstrap.php
+++ b/app/bootstrap.php
@@ -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();
diff --git a/app/views/anime/details.php b/app/views/anime/details.php
index 7a450785..75a71eea 100644
--- a/app/views/anime/details.php
+++ b/app/views/anime/details.php
@@ -34,7 +34,7 @@ use function Aviat\AnimeClient\getLocalImg;
-
+
Total Length |
= Kitsu::friendlyTime($data['total_length']) ?> |
diff --git a/src/AnimeClient/API/AbstractListItem.php b/src/AnimeClient/API/AbstractListItem.php
index 0181caa4..2b92ed51 100644
--- a/src/AnimeClient/API/AbstractListItem.php
+++ b/src/AnimeClient/API/AbstractListItem.php
@@ -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
*
diff --git a/src/AnimeClient/API/Anilist/ListItem.php b/src/AnimeClient/API/Anilist/ListItem.php
index d17b897e..15aa3653 100644
--- a/src/AnimeClient/API/Anilist/ListItem.php
+++ b/src/AnimeClient/API/Anilist/ListItem.php
@@ -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
diff --git a/src/AnimeClient/API/Anilist/Model.php b/src/AnimeClient/API/Anilist/Model.php
index 9a7ddded..5c14aa77 100644
--- a/src/AnimeClient/API/Anilist/Model.php
+++ b/src/AnimeClient/API/Anilist/Model.php
@@ -35,7 +35,7 @@ use Throwable;
*/
final class Model
{
- use AnilistTrait;
+ use RequestBuilderTrait;
/**
* @var ListItem
*/
diff --git a/src/AnimeClient/API/Anilist/AnilistRequestBuilder.php b/src/AnimeClient/API/Anilist/RequestBuilder.php
similarity index 99%
rename from src/AnimeClient/API/Anilist/AnilistRequestBuilder.php
rename to src/AnimeClient/API/Anilist/RequestBuilder.php
index 9f0e86cf..8ffee378 100644
--- a/src/AnimeClient/API/Anilist/AnilistRequestBuilder.php
+++ b/src/AnimeClient/API/Anilist/RequestBuilder.php
@@ -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;
/**
diff --git a/src/AnimeClient/API/Anilist/AnilistTrait.php b/src/AnimeClient/API/Anilist/RequestBuilderTrait.php
similarity index 84%
rename from src/AnimeClient/API/Anilist/AnilistTrait.php
rename to src/AnimeClient/API/Anilist/RequestBuilderTrait.php
index a5990f0d..5c696597 100644
--- a/src/AnimeClient/API/Anilist/AnilistTrait.php
+++ b/src/AnimeClient/API/Anilist/RequestBuilderTrait.php
@@ -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
diff --git a/src/AnimeClient/API/Kitsu/KitsuAnimeTrait.php b/src/AnimeClient/API/Kitsu/AnimeTrait.php
similarity index 99%
rename from src/AnimeClient/API/Kitsu/KitsuAnimeTrait.php
rename to src/AnimeClient/API/Kitsu/AnimeTrait.php
index 1a6c0dd7..8894a0a2 100644
--- a/src/AnimeClient/API/Kitsu/KitsuAnimeTrait.php
+++ b/src/AnimeClient/API/Kitsu/AnimeTrait.php
@@ -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
diff --git a/src/AnimeClient/API/Kitsu/ListItem.php b/src/AnimeClient/API/Kitsu/ListItem.php
index c817e24e..476bce89 100644
--- a/src/AnimeClient/API/Kitsu/ListItem.php
+++ b/src/AnimeClient/API/Kitsu/ListItem.php
@@ -35,7 +35,7 @@ use Throwable;
*/
final class ListItem extends AbstractListItem {
use ContainerAware;
- use KitsuTrait;
+ use RequestBuilderTrait;
/**
* @param array $data
diff --git a/src/AnimeClient/API/Kitsu/KitsuMangaTrait.php b/src/AnimeClient/API/Kitsu/MangaTrait.php
similarity index 99%
rename from src/AnimeClient/API/Kitsu/KitsuMangaTrait.php
rename to src/AnimeClient/API/Kitsu/MangaTrait.php
index 7f1e09bd..58a8a663 100644
--- a/src/AnimeClient/API/Kitsu/KitsuMangaTrait.php
+++ b/src/AnimeClient/API/Kitsu/MangaTrait.php
@@ -33,7 +33,7 @@ use Aviat\Ion\Json;
/**
* Manga-related list methods
*/
-trait KitsuMangaTrait {
+trait MangaTrait {
/**
* @var MangaTransformer
*/
diff --git a/src/AnimeClient/API/Kitsu/Model.php b/src/AnimeClient/API/Kitsu/Model.php
index 7f1f0439..2e6e09cd 100644
--- a/src/AnimeClient/API/Kitsu/Model.php
+++ b/src/AnimeClient/API/Kitsu/Model.php
@@ -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;
diff --git a/src/AnimeClient/API/Kitsu/KitsuMutationTrait.php b/src/AnimeClient/API/Kitsu/MutationTrait.php
similarity index 98%
rename from src/AnimeClient/API/Kitsu/KitsuMutationTrait.php
rename to src/AnimeClient/API/Kitsu/MutationTrait.php
index e0f1ba22..4c8432cc 100644
--- a/src/AnimeClient/API/Kitsu/KitsuMutationTrait.php
+++ b/src/AnimeClient/API/Kitsu/MutationTrait.php
@@ -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
// -------------------------------------------------------------------------
diff --git a/src/AnimeClient/API/Kitsu/Queries/.gitkeep b/src/AnimeClient/API/Kitsu/Queries/.gitkeep
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/AnimeClient/API/Kitsu/KitsuRequestBuilder.php b/src/AnimeClient/API/Kitsu/RequestBuilder.php
similarity index 96%
rename from src/AnimeClient/API/Kitsu/KitsuRequestBuilder.php
rename to src/AnimeClient/API/Kitsu/RequestBuilder.php
index 65c6507a..429e2851 100644
--- a/src/AnimeClient/API/Kitsu/KitsuRequestBuilder.php
+++ b/src/AnimeClient/API/Kitsu/RequestBuilder.php
@@ -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);
}
-
-
}
\ No newline at end of file
diff --git a/src/AnimeClient/API/Kitsu/KitsuTrait.php b/src/AnimeClient/API/Kitsu/RequestBuilderTrait.php
similarity index 76%
rename from src/AnimeClient/API/Kitsu/KitsuTrait.php
rename to src/AnimeClient/API/Kitsu/RequestBuilderTrait.php
index b331bcca..c56ec62a 100644
--- a/src/AnimeClient/API/Kitsu/KitsuTrait.php
+++ b/src/AnimeClient/API/Kitsu/RequestBuilderTrait.php
@@ -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;
diff --git a/src/AnimeClient/Command/BaseCommand.php b/src/AnimeClient/Command/BaseCommand.php
index 8887cacb..c1670d99 100644
--- a/src/AnimeClient/Command/BaseCommand.php
+++ b/src/AnimeClient/Command/BaseCommand.php
@@ -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();