From 2cc6c7d0ee59020329c6bea310e433f17ce3fcf4 Mon Sep 17 00:00:00 2001 From: Dendy Faist Date: Mon, 10 Jul 2023 06:14:29 +0200 Subject: [PATCH] Implement Item->getJson(); --- main.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/main.php b/main.php index f231756..e13c649 100644 --- a/main.php +++ b/main.php @@ -41,7 +41,7 @@ function get_item() Json::error('No item was found with the given ID')->die(); } - return Json::new($item->getUri()); + return $item->getJson(); } function post_item() @@ -49,11 +49,7 @@ function post_item() // The checks are performed internally $item = Item::upload($_FILES['file']); - return Json::new([ - 'type' => 'success', - 'id' => $item->getHash(), - 'link' => $item->getUri(), - ]); + return $item->getJson(); }; class MediaDB @@ -237,6 +233,15 @@ class Item $this->extension, ); } + + public function getJson(): Json + { + return Json::new([ + 'id' => $this->hash, + 'link' => $this->getUri(), + 'tags' => $this->tags, + ]); + } } class Json