diff Plugins/Samples/Common/OrthancPluginConnection.cpp @ 2183:1d0838b8e9c5

RestApiDelete and RestApiPut
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 Nov 2016 21:33:35 +0100
parents de32f3b4ff09
children 403d92d8df83
line wrap: on
line diff
--- a/Plugins/Samples/Common/OrthancPluginConnection.cpp	Fri Nov 25 19:08:10 2016 +0100
+++ b/Plugins/Samples/Common/OrthancPluginConnection.cpp	Fri Nov 25 21:33:35 2016 +0100
@@ -58,7 +58,7 @@
   {
     OrthancPlugins::MemoryBuffer buffer(context_);
 
-    if (!buffer.RestApiPost(uri, body.c_str(), body.size(), false))
+    if (buffer.RestApiPost(uri, body.c_str(), body.size(), false))
     {
       buffer.ToString(result);
     }
@@ -67,4 +67,32 @@
       ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_UnknownResource);
     }
   }
+
+
+  void OrthancPluginConnection::RestApiPut(std::string& result,
+                                           const std::string& uri,
+                                           const std::string& body)
+  {
+    OrthancPlugins::MemoryBuffer buffer(context_);
+
+    if (buffer.RestApiPut(uri, body.c_str(), body.size(), false))
+    {
+      buffer.ToString(result);
+    }
+    else
+    {
+      ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_UnknownResource);
+    }
+  }
+
+
+  void OrthancPluginConnection::RestApiDelete(const std::string& uri)
+  {
+    OrthancPlugins::MemoryBuffer buffer(context_);
+
+    if (!::OrthancPlugins::RestApiDelete(context_, uri, false))
+    {
+      ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_UnknownResource);
+    }
+  }
 }