]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/ApiBundle/Controller/WallabagRestController.php
fix api properties and typo
[github/wallabag/wallabag.git] / src / Wallabag / ApiBundle / Controller / WallabagRestController.php
index 28145e45081bc957670049e16b4a73b1f0fc5ad1..3265ba3876037292eac04123b2b92e8e4b212046 100644 (file)
@@ -99,7 +99,6 @@ class WallabagRestController extends FOSRestController
      *          {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."},
      *          {"name"="starred", "dataType"="boolean", "required"=false, "format"="true or false", "description"="entry already starred"},
      *          {"name"="archive", "dataType"="boolean", "required"=false, "format"="true or false", "description"="entry already archived"},
-     *          {"name"="content", "dataType"="string", "required"=false, "format"="content", "description"="content you want to pass directly"},
      *       }
      * )
      *
@@ -110,32 +109,31 @@ class WallabagRestController extends FOSRestController
         $this->validateAuthentication();
 
         $url = $request->request->get('url');
-        $content = $request->request->get('content');
         $isArchived = $request->request->get('archive');
         $isStarred = $request->request->get('starred');
 
-        $entry = $this->get('wallabag_core.content_proxy')->updateEntry(
-            new Entry($this->getUser()),
-            $url
-        );
+        $entry = $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($url, $this->getUser()->getId());
+
+        if (false === $entry) {
+            $entry = $this->get('wallabag_core.content_proxy')->updateEntry(
+                new Entry($this->getUser()),
+                $url
+            );
+        }
 
         $tags = $request->request->get('tags', '');
         if (!empty($tags)) {
             $this->get('wallabag_core.content_proxy')->assignTagsToEntry($entry, $tags);
         }
 
-        if (true === (bool) $isStarred) {
+        if ($isStarred === 'true') {
             $entry->setStarred(true);
         }
 
-        if (true === (bool) $isArchived) {
+        if ($isArchived  === 'true') {
             $entry->setArchived(true);
         }
 
-        if (!empty($content)) {
-            $entry->setContent($content);
-        }
-
         $em = $this->getDoctrine()->getManager();
         $em->persist($entry);
 
@@ -346,6 +344,21 @@ class WallabagRestController extends FOSRestController
 
         return $this->renderJsonResponse($json);
     }
+    /**
+     * Retrieve version number.
+     *
+     * @ApiDoc()
+     *
+     * @return Response
+     */
+    public function getVersionAction()
+    {
+        $version = $this->container->getParameter('wallabag_core.version');
+
+        $json = $this->get('serializer')->serialize($version, 'json');
+
+        return $this->renderJsonResponse($json);
+    }
 
     /**
      * Validate that the first id is equal to the second one.