Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
2 changed files with 22 additions and 10 deletions
Showing only changes of commit bd61bd734b - Show all commits

View File

@ -227,6 +227,21 @@ class APIRequestBuilder {
return $this->request; return $this->request;
} }
/**
* Get the data from the response of the passed request
*
* @param Request $request
* @return mixed
* @throws \Error
* @throws \Throwable
* @throws \TypeError
*/
public function getResponseData(Request $request)
{
$response = wait((new HummingbirdClient)->request($request));
return wait($response->getBody());
}
/** /**
* Create a new http request * Create a new http request
* *

View File

@ -16,9 +16,6 @@
namespace Aviat\AnimeClient\Command; namespace Aviat\AnimeClient\Command;
use function Amp\Promise\{all, wait};
use Amp\Artax\Client;
use Aviat\AnimeClient\API\{ use Aviat\AnimeClient\API\{
FailedResponseException, FailedResponseException,
JsonAPI, JsonAPI,
@ -27,8 +24,7 @@ use Aviat\AnimeClient\API\{
Mapping\MangaReadingStatus Mapping\MangaReadingStatus
}; };
use Aviat\AnimeClient\API\MAL\Transformer\{ use Aviat\AnimeClient\API\MAL\Transformer\{
AnimeListTransformer as ALT, AnimeListTransformer as ALT
MangaListTransformer as MLT
}; };
use Aviat\Ion\Json; use Aviat\Ion\Json;
@ -78,9 +74,10 @@ class SyncKitsuWithMal extends BaseCommand {
$malCount = 0; $malCount = 0;
if ( ! empty($malList)) if ( ! empty($malList))
{ {
$malCount = (array_key_exists(0, $malList)) $malCount = count(array_key_exists(0, $malList)
? count($malList) ? $malList
: count([$malList]); : [$malList]
);
} }
try try
@ -485,7 +482,7 @@ class SyncKitsuWithMal extends BaseCommand {
$responseData = Json::decode($response); $responseData = Json::decode($response);
$id = $itemsToUpdate[$key]['mal_id']; $id = $itemsToUpdate[$key]['mal_id'];
if ( ! array_key_exists('errors', $responseData)); if ( ! array_key_exists('errors', $responseData))
{ {
$verb = ($action === 'update') ? 'updated' : 'created'; $verb = ($action === 'update') ? 'updated' : 'created';
$this->echoBox("Successfully {$verb} Kitsu {$type} list item with id: {$id}"); $this->echoBox("Successfully {$verb} Kitsu {$type} list item with id: {$id}");