# HG changeset patch # User amazy # Date 1551113857 -3600 # Node ID 3ae7563b4fe199dcc998faf4a5d9fa0092b12342 # Parent 64d90190a08ce9fc1016758c1019c05b787c918e more orthancApiClient overloads diff -r 64d90190a08c -r 3ae7563b4fe1 Framework/Toolbox/OrthancApiClient.cpp --- 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* successCallback, + MessageHandler* failureCallback, + Orthanc::IDynamicObject* payload /* takes ownership */) + { + web_.PostAsync(baseUrl_ + uri, IWebService::HttpHeaders(), body, + new WebServicePayload(successCallback, failureCallback, payload), + new Callable + (*this, &OrthancApiClient::NotifyHttpSuccess), + new Callable + (*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* successCallback, + MessageHandler* 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* successCallback, diff -r 64d90190a08c -r 3ae7563b4fe1 Framework/Toolbox/OrthancApiClient.h --- a/Framework/Toolbox/OrthancApiClient.h Wed Feb 20 20:57:43 2019 +0100 +++ b/Framework/Toolbox/OrthancApiClient.h Mon Feb 25 17:57:37 2019 +0100 @@ -201,10 +201,25 @@ void PostJsonAsync(const std::string& uri, const Json::Value& data); + // schedule a POST request and don't expect any response. + void PostJsonAsync(const std::string& uri, + const Json::Value& data, + MessageHandler* successCallback, + MessageHandler* failureCallback = NULL, + Orthanc::IDynamicObject* payload = NULL /* takes ownership */); + + // schedule a POST request and don't mind the response. void PostBinaryAsync(const std::string& uri, const std::string& body); + // schedule a POST request and don't expect any response. + void PostBinaryAsync(const std::string& uri, + const std::string& body, + MessageHandler* successCallback, + MessageHandler* failureCallback = NULL, + Orthanc::IDynamicObject* payload = NULL /* takes ownership */); + // schedule a DELETE request expecting an empty response. void DeleteAsync(const std::string& uri, MessageHandler* successCallback,