From db69b13d87c9ce9d9d8ac9c60d06283d63ec1ff9 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Tue, 9 Feb 2016 20:12:39 -0500 Subject: [PATCH] Partially fix #9 -- API calls fail on 'Plan to Watch' section --- app/views/collection/add.php | 11 +++++------ src/Aviat/AnimeClient/Controller/Manga.php | 5 +++-- src/Aviat/AnimeClient/Model/Manga.php | 8 ++++++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/views/collection/add.php b/app/views/collection/add.php index c5b3742e..61c3a7e1 100644 --- a/app/views/collection/add.php +++ b/app/views/collection/add.php @@ -3,6 +3,11 @@

Add Anime to your Collection

+
@@ -34,11 +39,5 @@ - \ No newline at end of file diff --git a/src/Aviat/AnimeClient/Controller/Manga.php b/src/Aviat/AnimeClient/Controller/Manga.php index 84cb8a85..e6bc8207 100644 --- a/src/Aviat/AnimeClient/Controller/Manga.php +++ b/src/Aviat/AnimeClient/Controller/Manga.php @@ -12,6 +12,7 @@ */ namespace Aviat\AnimeClient\Controller; +use Aviat\Ion\Json; use Aviat\Ion\Di\ContainerInterface; use Aviat\AnimeClient\Controller; use Aviat\AnimeClient\Config; @@ -194,9 +195,9 @@ class Manga extends Controller { $post_data = $transformer->untransform($post_data); $full_result = $this->model->update($post_data); - $result = $full_result['body']; + $result = Json::decode((string)$full_result['body']); - if (array_key_exists('manga', $result)) + if ($full_result['statusCode'] == 200) { $m =& $result['manga'][0]; $title = ( ! empty($m['english_title'])) diff --git a/src/Aviat/AnimeClient/Model/Manga.php b/src/Aviat/AnimeClient/Model/Manga.php index 609b39ca..26a12c4c 100644 --- a/src/Aviat/AnimeClient/Model/Manga.php +++ b/src/Aviat/AnimeClient/Model/Manga.php @@ -50,6 +50,14 @@ class Manga extends API { */ protected $base_url = "https://hummingbird.me/"; + /** + * Make an authenticated manga API call + * + * @param string $type - the HTTP verb + * @param string $url + * @param string|null $json + * @return array + */ protected function _manga_api_call($type, $url, $json = NULL) { $token = $this->container->get('auth')