diff Framework/Toolbox/OrthancApiClient.cpp @ 502:3ae7563b4fe1 am-touch-events

more orthancApiClient overloads
author amazy
date Mon, 25 Feb 2019 17:57:37 +0100
parents a750f11892ec
children 4f2416d519b4
line wrap: on
line diff
--- a/Framework/Toolbox/OrthancApiClient.cpp	Wed Feb 20 20:57:43 2019 +0100
+++ b/Framework/Toolbox/OrthancApiClient.cpp	Mon Feb 25 17:57:37 2019 +0100
@@ -248,6 +248,21 @@
     web_.PostAsync(baseUrl_ + uri, IWebService::HttpHeaders(), body, NULL, NULL, NULL);
   }
 
+  void OrthancApiClient::PostBinaryAsync(
+      const std::string& uri,
+      const std::string& body,
+      MessageHandler<EmptyResponseReadyMessage>* successCallback,
+      MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback,
+      Orthanc::IDynamicObject* payload   /* takes ownership */)
+  {
+    web_.PostAsync(baseUrl_ + uri, IWebService::HttpHeaders(), body,
+                   new WebServicePayload(successCallback, failureCallback, payload),
+                   new Callable<OrthancApiClient, IWebService::HttpRequestSuccessMessage>
+                   (*this, &OrthancApiClient::NotifyHttpSuccess),
+                   new Callable<OrthancApiClient, IWebService::HttpRequestErrorMessage>
+                   (*this, &OrthancApiClient::NotifyHttpError));
+  }
+
   void OrthancApiClient::PostJsonAsyncExpectJson(
       const std::string& uri,
       const Json::Value& data,
@@ -269,6 +284,18 @@
     return PostBinaryAsync(uri, body);
   }
 
+  void OrthancApiClient::PostJsonAsync(
+      const std::string& uri,
+      const Json::Value& data,
+      MessageHandler<EmptyResponseReadyMessage>* successCallback,
+      MessageHandler<IWebService::HttpRequestErrorMessage>* failureCallback,
+      Orthanc::IDynamicObject* payload   /* takes ownership */)
+  {
+    std::string body;
+    MessagingToolbox::JsonToString(body, data);
+    return PostBinaryAsync(uri, body, successCallback, failureCallback, payload);
+  }
+
   void OrthancApiClient::DeleteAsync(
       const std::string& uri,
       MessageHandler<EmptyResponseReadyMessage>* successCallback,