forked from loafle/openapi-generator-original
949 lines
42 KiB
C++
949 lines
42 KiB
C++
/**
|
|
* OpenAPI Petstore
|
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
|
*
|
|
* OpenAPI spec version: 1.0.0
|
|
*
|
|
* NOTE: This class is auto generated by OpenAPI-Generator 3.3.0-SNAPSHOT.
|
|
* https://openapi-generator.tech
|
|
* Do not edit the class manually.
|
|
*/
|
|
|
|
|
|
#include "UserApi.h"
|
|
#include "IHttpBody.h"
|
|
#include "JsonBody.h"
|
|
#include "MultipartFormData.h"
|
|
|
|
#include <unordered_set>
|
|
|
|
#include <boost/algorithm/string/replace.hpp>
|
|
|
|
namespace org {
|
|
namespace openapitools {
|
|
namespace client {
|
|
namespace api {
|
|
|
|
using namespace org::openapitools::client::model;
|
|
|
|
UserApi::UserApi( std::shared_ptr<ApiClient> apiClient )
|
|
: m_ApiClient(apiClient)
|
|
{
|
|
}
|
|
|
|
UserApi::~UserApi()
|
|
{
|
|
}
|
|
|
|
pplx::task<void> UserApi::createUser(std::shared_ptr<User> user)
|
|
{
|
|
|
|
// verify the required parameter 'user' is set
|
|
if (user == nullptr)
|
|
{
|
|
throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'user' when calling UserApi->createUser"));
|
|
}
|
|
|
|
|
|
std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() );
|
|
utility::string_t localVarPath = utility::conversions::to_string_t("/user");
|
|
|
|
std::map<utility::string_t, utility::string_t> localVarQueryParams;
|
|
std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() );
|
|
std::map<utility::string_t, utility::string_t> localVarFormParams;
|
|
std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams;
|
|
|
|
std::unordered_set<utility::string_t> localVarResponseHttpContentTypes;
|
|
|
|
utility::string_t localVarResponseHttpContentType;
|
|
|
|
// use JSON if possible
|
|
if ( localVarResponseHttpContentTypes.size() == 0 )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("application/json");
|
|
}
|
|
// JSON
|
|
else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("application/json");
|
|
}
|
|
// multipart formdata
|
|
else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
|
}
|
|
else
|
|
{
|
|
throw ApiException(400, utility::conversions::to_string_t("UserApi->createUser does not produce any supported media type"));
|
|
}
|
|
|
|
localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType;
|
|
|
|
std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes;
|
|
|
|
|
|
std::shared_ptr<IHttpBody> localVarHttpBody;
|
|
utility::string_t localVarRequestHttpContentType;
|
|
|
|
// use JSON if possible
|
|
if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() )
|
|
{
|
|
localVarRequestHttpContentType = utility::conversions::to_string_t("application/json");
|
|
web::json::value localVarJson;
|
|
|
|
localVarJson = ModelBase::toJson(user);
|
|
|
|
|
|
localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) );
|
|
}
|
|
// multipart formdata
|
|
else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() )
|
|
{
|
|
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
|
std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData);
|
|
|
|
if(user.get())
|
|
{
|
|
user->toMultipart(localVarMultipart, utility::conversions::to_string_t("user"));
|
|
}
|
|
|
|
localVarHttpBody = localVarMultipart;
|
|
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
|
}
|
|
else
|
|
{
|
|
throw ApiException(415, utility::conversions::to_string_t("UserApi->createUser does not consume any supported media type"));
|
|
}
|
|
|
|
|
|
return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType)
|
|
.then([=](web::http::http_response localVarResponse)
|
|
{
|
|
// 1xx - informational : OK
|
|
// 2xx - successful : OK
|
|
// 3xx - redirection : OK
|
|
// 4xx - client error : not OK
|
|
// 5xx - client error : not OK
|
|
if (localVarResponse.status_code() >= 400)
|
|
{
|
|
throw ApiException(localVarResponse.status_code()
|
|
, utility::conversions::to_string_t("error calling createUser: ") + localVarResponse.reason_phrase()
|
|
, std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
|
|
}
|
|
|
|
// check response content type
|
|
if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type")))
|
|
{
|
|
utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")];
|
|
if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos )
|
|
{
|
|
throw ApiException(500
|
|
, utility::conversions::to_string_t("error calling createUser: unexpected response type: ") + localVarContentType
|
|
, std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
|
|
}
|
|
}
|
|
|
|
return localVarResponse.extract_string();
|
|
})
|
|
.then([=](utility::string_t localVarResponse)
|
|
{
|
|
return void();
|
|
});
|
|
}
|
|
pplx::task<void> UserApi::createUsersWithArrayInput(std::vector<std::shared_ptr<User>> user)
|
|
{
|
|
|
|
|
|
std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() );
|
|
utility::string_t localVarPath = utility::conversions::to_string_t("/user/createWithArray");
|
|
|
|
std::map<utility::string_t, utility::string_t> localVarQueryParams;
|
|
std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() );
|
|
std::map<utility::string_t, utility::string_t> localVarFormParams;
|
|
std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams;
|
|
|
|
std::unordered_set<utility::string_t> localVarResponseHttpContentTypes;
|
|
|
|
utility::string_t localVarResponseHttpContentType;
|
|
|
|
// use JSON if possible
|
|
if ( localVarResponseHttpContentTypes.size() == 0 )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("application/json");
|
|
}
|
|
// JSON
|
|
else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("application/json");
|
|
}
|
|
// multipart formdata
|
|
else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
|
}
|
|
else
|
|
{
|
|
throw ApiException(400, utility::conversions::to_string_t("UserApi->createUsersWithArrayInput does not produce any supported media type"));
|
|
}
|
|
|
|
localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType;
|
|
|
|
std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes;
|
|
|
|
|
|
std::shared_ptr<IHttpBody> localVarHttpBody;
|
|
utility::string_t localVarRequestHttpContentType;
|
|
|
|
// use JSON if possible
|
|
if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() )
|
|
{
|
|
localVarRequestHttpContentType = utility::conversions::to_string_t("application/json");
|
|
web::json::value localVarJson;
|
|
|
|
{
|
|
std::vector<web::json::value> localVarJsonArray;
|
|
for( auto& localVarItem : user )
|
|
{
|
|
localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() );
|
|
|
|
}
|
|
localVarJson = web::json::value::array(localVarJsonArray);
|
|
}
|
|
|
|
localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) );
|
|
}
|
|
// multipart formdata
|
|
else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() )
|
|
{
|
|
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
|
std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData);
|
|
{
|
|
std::vector<web::json::value> localVarJsonArray;
|
|
for( auto& localVarItem : user )
|
|
{
|
|
localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() );
|
|
|
|
}
|
|
localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("user"), web::json::value::array(localVarJsonArray), utility::conversions::to_string_t("application/json")));
|
|
}
|
|
|
|
localVarHttpBody = localVarMultipart;
|
|
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
|
}
|
|
else
|
|
{
|
|
throw ApiException(415, utility::conversions::to_string_t("UserApi->createUsersWithArrayInput does not consume any supported media type"));
|
|
}
|
|
|
|
|
|
return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType)
|
|
.then([=](web::http::http_response localVarResponse)
|
|
{
|
|
// 1xx - informational : OK
|
|
// 2xx - successful : OK
|
|
// 3xx - redirection : OK
|
|
// 4xx - client error : not OK
|
|
// 5xx - client error : not OK
|
|
if (localVarResponse.status_code() >= 400)
|
|
{
|
|
throw ApiException(localVarResponse.status_code()
|
|
, utility::conversions::to_string_t("error calling createUsersWithArrayInput: ") + localVarResponse.reason_phrase()
|
|
, std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
|
|
}
|
|
|
|
// check response content type
|
|
if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type")))
|
|
{
|
|
utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")];
|
|
if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos )
|
|
{
|
|
throw ApiException(500
|
|
, utility::conversions::to_string_t("error calling createUsersWithArrayInput: unexpected response type: ") + localVarContentType
|
|
, std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
|
|
}
|
|
}
|
|
|
|
return localVarResponse.extract_string();
|
|
})
|
|
.then([=](utility::string_t localVarResponse)
|
|
{
|
|
return void();
|
|
});
|
|
}
|
|
pplx::task<void> UserApi::createUsersWithListInput(std::vector<std::shared_ptr<User>> user)
|
|
{
|
|
|
|
|
|
std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() );
|
|
utility::string_t localVarPath = utility::conversions::to_string_t("/user/createWithList");
|
|
|
|
std::map<utility::string_t, utility::string_t> localVarQueryParams;
|
|
std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() );
|
|
std::map<utility::string_t, utility::string_t> localVarFormParams;
|
|
std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams;
|
|
|
|
std::unordered_set<utility::string_t> localVarResponseHttpContentTypes;
|
|
|
|
utility::string_t localVarResponseHttpContentType;
|
|
|
|
// use JSON if possible
|
|
if ( localVarResponseHttpContentTypes.size() == 0 )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("application/json");
|
|
}
|
|
// JSON
|
|
else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("application/json");
|
|
}
|
|
// multipart formdata
|
|
else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
|
}
|
|
else
|
|
{
|
|
throw ApiException(400, utility::conversions::to_string_t("UserApi->createUsersWithListInput does not produce any supported media type"));
|
|
}
|
|
|
|
localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType;
|
|
|
|
std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes;
|
|
|
|
|
|
std::shared_ptr<IHttpBody> localVarHttpBody;
|
|
utility::string_t localVarRequestHttpContentType;
|
|
|
|
// use JSON if possible
|
|
if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() )
|
|
{
|
|
localVarRequestHttpContentType = utility::conversions::to_string_t("application/json");
|
|
web::json::value localVarJson;
|
|
|
|
{
|
|
std::vector<web::json::value> localVarJsonArray;
|
|
for( auto& localVarItem : user )
|
|
{
|
|
localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() );
|
|
|
|
}
|
|
localVarJson = web::json::value::array(localVarJsonArray);
|
|
}
|
|
|
|
localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) );
|
|
}
|
|
// multipart formdata
|
|
else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() )
|
|
{
|
|
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
|
std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData);
|
|
{
|
|
std::vector<web::json::value> localVarJsonArray;
|
|
for( auto& localVarItem : user )
|
|
{
|
|
localVarJsonArray.push_back( localVarItem.get() ? localVarItem->toJson() : web::json::value::null() );
|
|
|
|
}
|
|
localVarMultipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("user"), web::json::value::array(localVarJsonArray), utility::conversions::to_string_t("application/json")));
|
|
}
|
|
|
|
localVarHttpBody = localVarMultipart;
|
|
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
|
}
|
|
else
|
|
{
|
|
throw ApiException(415, utility::conversions::to_string_t("UserApi->createUsersWithListInput does not consume any supported media type"));
|
|
}
|
|
|
|
|
|
return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType)
|
|
.then([=](web::http::http_response localVarResponse)
|
|
{
|
|
// 1xx - informational : OK
|
|
// 2xx - successful : OK
|
|
// 3xx - redirection : OK
|
|
// 4xx - client error : not OK
|
|
// 5xx - client error : not OK
|
|
if (localVarResponse.status_code() >= 400)
|
|
{
|
|
throw ApiException(localVarResponse.status_code()
|
|
, utility::conversions::to_string_t("error calling createUsersWithListInput: ") + localVarResponse.reason_phrase()
|
|
, std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
|
|
}
|
|
|
|
// check response content type
|
|
if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type")))
|
|
{
|
|
utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")];
|
|
if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos )
|
|
{
|
|
throw ApiException(500
|
|
, utility::conversions::to_string_t("error calling createUsersWithListInput: unexpected response type: ") + localVarContentType
|
|
, std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
|
|
}
|
|
}
|
|
|
|
return localVarResponse.extract_string();
|
|
})
|
|
.then([=](utility::string_t localVarResponse)
|
|
{
|
|
return void();
|
|
});
|
|
}
|
|
pplx::task<void> UserApi::deleteUser(utility::string_t username)
|
|
{
|
|
|
|
|
|
std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() );
|
|
utility::string_t localVarPath = utility::conversions::to_string_t("/user/{username}");
|
|
boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("username") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(username));
|
|
|
|
std::map<utility::string_t, utility::string_t> localVarQueryParams;
|
|
std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() );
|
|
std::map<utility::string_t, utility::string_t> localVarFormParams;
|
|
std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams;
|
|
|
|
std::unordered_set<utility::string_t> localVarResponseHttpContentTypes;
|
|
|
|
utility::string_t localVarResponseHttpContentType;
|
|
|
|
// use JSON if possible
|
|
if ( localVarResponseHttpContentTypes.size() == 0 )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("application/json");
|
|
}
|
|
// JSON
|
|
else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("application/json");
|
|
}
|
|
// multipart formdata
|
|
else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
|
}
|
|
else
|
|
{
|
|
throw ApiException(400, utility::conversions::to_string_t("UserApi->deleteUser does not produce any supported media type"));
|
|
}
|
|
|
|
localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType;
|
|
|
|
std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes;
|
|
|
|
|
|
std::shared_ptr<IHttpBody> localVarHttpBody;
|
|
utility::string_t localVarRequestHttpContentType;
|
|
|
|
// use JSON if possible
|
|
if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() )
|
|
{
|
|
localVarRequestHttpContentType = utility::conversions::to_string_t("application/json");
|
|
}
|
|
// multipart formdata
|
|
else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() )
|
|
{
|
|
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
|
}
|
|
else
|
|
{
|
|
throw ApiException(415, utility::conversions::to_string_t("UserApi->deleteUser does not consume any supported media type"));
|
|
}
|
|
|
|
|
|
return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("DELETE"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType)
|
|
.then([=](web::http::http_response localVarResponse)
|
|
{
|
|
// 1xx - informational : OK
|
|
// 2xx - successful : OK
|
|
// 3xx - redirection : OK
|
|
// 4xx - client error : not OK
|
|
// 5xx - client error : not OK
|
|
if (localVarResponse.status_code() >= 400)
|
|
{
|
|
throw ApiException(localVarResponse.status_code()
|
|
, utility::conversions::to_string_t("error calling deleteUser: ") + localVarResponse.reason_phrase()
|
|
, std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
|
|
}
|
|
|
|
// check response content type
|
|
if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type")))
|
|
{
|
|
utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")];
|
|
if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos )
|
|
{
|
|
throw ApiException(500
|
|
, utility::conversions::to_string_t("error calling deleteUser: unexpected response type: ") + localVarContentType
|
|
, std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
|
|
}
|
|
}
|
|
|
|
return localVarResponse.extract_string();
|
|
})
|
|
.then([=](utility::string_t localVarResponse)
|
|
{
|
|
return void();
|
|
});
|
|
}
|
|
pplx::task<std::shared_ptr<User>> UserApi::getUserByName(utility::string_t username)
|
|
{
|
|
|
|
|
|
std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() );
|
|
utility::string_t localVarPath = utility::conversions::to_string_t("/user/{username}");
|
|
boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("username") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(username));
|
|
|
|
std::map<utility::string_t, utility::string_t> localVarQueryParams;
|
|
std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() );
|
|
std::map<utility::string_t, utility::string_t> localVarFormParams;
|
|
std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams;
|
|
|
|
std::unordered_set<utility::string_t> localVarResponseHttpContentTypes;
|
|
localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") );
|
|
localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );
|
|
|
|
utility::string_t localVarResponseHttpContentType;
|
|
|
|
// use JSON if possible
|
|
if ( localVarResponseHttpContentTypes.size() == 0 )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("application/json");
|
|
}
|
|
// JSON
|
|
else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("application/json");
|
|
}
|
|
// multipart formdata
|
|
else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
|
}
|
|
else
|
|
{
|
|
throw ApiException(400, utility::conversions::to_string_t("UserApi->getUserByName does not produce any supported media type"));
|
|
}
|
|
|
|
localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType;
|
|
|
|
std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes;
|
|
|
|
|
|
std::shared_ptr<IHttpBody> localVarHttpBody;
|
|
utility::string_t localVarRequestHttpContentType;
|
|
|
|
// use JSON if possible
|
|
if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() )
|
|
{
|
|
localVarRequestHttpContentType = utility::conversions::to_string_t("application/json");
|
|
}
|
|
// multipart formdata
|
|
else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() )
|
|
{
|
|
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
|
}
|
|
else
|
|
{
|
|
throw ApiException(415, utility::conversions::to_string_t("UserApi->getUserByName does not consume any supported media type"));
|
|
}
|
|
|
|
|
|
return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType)
|
|
.then([=](web::http::http_response localVarResponse)
|
|
{
|
|
// 1xx - informational : OK
|
|
// 2xx - successful : OK
|
|
// 3xx - redirection : OK
|
|
// 4xx - client error : not OK
|
|
// 5xx - client error : not OK
|
|
if (localVarResponse.status_code() >= 400)
|
|
{
|
|
throw ApiException(localVarResponse.status_code()
|
|
, utility::conversions::to_string_t("error calling getUserByName: ") + localVarResponse.reason_phrase()
|
|
, std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
|
|
}
|
|
|
|
// check response content type
|
|
if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type")))
|
|
{
|
|
utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")];
|
|
if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos )
|
|
{
|
|
throw ApiException(500
|
|
, utility::conversions::to_string_t("error calling getUserByName: unexpected response type: ") + localVarContentType
|
|
, std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
|
|
}
|
|
}
|
|
|
|
return localVarResponse.extract_string();
|
|
})
|
|
.then([=](utility::string_t localVarResponse)
|
|
{
|
|
std::shared_ptr<User> localVarResult(new User());
|
|
|
|
if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json"))
|
|
{
|
|
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
|
|
|
localVarResult->fromJson(localVarJson);
|
|
}
|
|
// else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
|
// {
|
|
// TODO multipart response parsing
|
|
// }
|
|
else
|
|
{
|
|
throw ApiException(500
|
|
, utility::conversions::to_string_t("error calling getUserByName: unsupported response type"));
|
|
}
|
|
|
|
return localVarResult;
|
|
});
|
|
}
|
|
pplx::task<utility::string_t> UserApi::loginUser(utility::string_t username, utility::string_t password)
|
|
{
|
|
|
|
|
|
std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() );
|
|
utility::string_t localVarPath = utility::conversions::to_string_t("/user/login");
|
|
|
|
std::map<utility::string_t, utility::string_t> localVarQueryParams;
|
|
std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() );
|
|
std::map<utility::string_t, utility::string_t> localVarFormParams;
|
|
std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams;
|
|
|
|
std::unordered_set<utility::string_t> localVarResponseHttpContentTypes;
|
|
localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") );
|
|
localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );
|
|
|
|
utility::string_t localVarResponseHttpContentType;
|
|
|
|
// use JSON if possible
|
|
if ( localVarResponseHttpContentTypes.size() == 0 )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("text/plain");
|
|
}
|
|
// JSON
|
|
else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("application/json");
|
|
}
|
|
// multipart formdata
|
|
else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
|
}
|
|
// plain text
|
|
else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("text/plain")) != localVarResponseHttpContentTypes.end() )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("text/plain");
|
|
}
|
|
else
|
|
{
|
|
throw ApiException(400, utility::conversions::to_string_t("UserApi->loginUser does not produce any supported media type"));
|
|
}
|
|
|
|
localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType;
|
|
|
|
std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes;
|
|
|
|
{
|
|
localVarQueryParams[utility::conversions::to_string_t("username")] = ApiClient::parameterToString(username);
|
|
}
|
|
{
|
|
localVarQueryParams[utility::conversions::to_string_t("password")] = ApiClient::parameterToString(password);
|
|
}
|
|
|
|
std::shared_ptr<IHttpBody> localVarHttpBody;
|
|
utility::string_t localVarRequestHttpContentType;
|
|
|
|
// use JSON if possible
|
|
if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() )
|
|
{
|
|
localVarRequestHttpContentType = utility::conversions::to_string_t("application/json");
|
|
}
|
|
// multipart formdata
|
|
else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() )
|
|
{
|
|
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
|
}
|
|
else
|
|
{
|
|
throw ApiException(415, utility::conversions::to_string_t("UserApi->loginUser does not consume any supported media type"));
|
|
}
|
|
|
|
|
|
return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType)
|
|
.then([=](web::http::http_response localVarResponse)
|
|
{
|
|
// 1xx - informational : OK
|
|
// 2xx - successful : OK
|
|
// 3xx - redirection : OK
|
|
// 4xx - client error : not OK
|
|
// 5xx - client error : not OK
|
|
if (localVarResponse.status_code() >= 400)
|
|
{
|
|
throw ApiException(localVarResponse.status_code()
|
|
, utility::conversions::to_string_t("error calling loginUser: ") + localVarResponse.reason_phrase()
|
|
, std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
|
|
}
|
|
|
|
// check response content type
|
|
if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type")))
|
|
{
|
|
utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")];
|
|
if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos )
|
|
{
|
|
throw ApiException(500
|
|
, utility::conversions::to_string_t("error calling loginUser: unexpected response type: ") + localVarContentType
|
|
, std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
|
|
}
|
|
}
|
|
|
|
return localVarResponse.extract_string();
|
|
})
|
|
.then([=](utility::string_t localVarResponse)
|
|
{
|
|
utility::string_t localVarResult(utility::conversions::to_string_t(""));
|
|
|
|
if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json"))
|
|
{
|
|
web::json::value localVarJson = web::json::value::parse(localVarResponse);
|
|
|
|
localVarResult = ModelBase::stringFromJson(localVarJson);
|
|
|
|
}
|
|
else if(localVarResponseHttpContentType == utility::conversions::to_string_t("text/plain"))
|
|
{
|
|
localVarResult = localVarResponse;
|
|
}
|
|
// else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
|
// {
|
|
// TODO multipart response parsing
|
|
// }
|
|
else
|
|
{
|
|
throw ApiException(500
|
|
, utility::conversions::to_string_t("error calling loginUser: unsupported response type"));
|
|
}
|
|
|
|
return localVarResult;
|
|
});
|
|
}
|
|
pplx::task<void> UserApi::logoutUser()
|
|
{
|
|
|
|
|
|
std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() );
|
|
utility::string_t localVarPath = utility::conversions::to_string_t("/user/logout");
|
|
|
|
std::map<utility::string_t, utility::string_t> localVarQueryParams;
|
|
std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() );
|
|
std::map<utility::string_t, utility::string_t> localVarFormParams;
|
|
std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams;
|
|
|
|
std::unordered_set<utility::string_t> localVarResponseHttpContentTypes;
|
|
|
|
utility::string_t localVarResponseHttpContentType;
|
|
|
|
// use JSON if possible
|
|
if ( localVarResponseHttpContentTypes.size() == 0 )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("application/json");
|
|
}
|
|
// JSON
|
|
else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("application/json");
|
|
}
|
|
// multipart formdata
|
|
else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
|
}
|
|
else
|
|
{
|
|
throw ApiException(400, utility::conversions::to_string_t("UserApi->logoutUser does not produce any supported media type"));
|
|
}
|
|
|
|
localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType;
|
|
|
|
std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes;
|
|
|
|
|
|
std::shared_ptr<IHttpBody> localVarHttpBody;
|
|
utility::string_t localVarRequestHttpContentType;
|
|
|
|
// use JSON if possible
|
|
if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() )
|
|
{
|
|
localVarRequestHttpContentType = utility::conversions::to_string_t("application/json");
|
|
}
|
|
// multipart formdata
|
|
else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() )
|
|
{
|
|
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
|
}
|
|
else
|
|
{
|
|
throw ApiException(415, utility::conversions::to_string_t("UserApi->logoutUser does not consume any supported media type"));
|
|
}
|
|
|
|
|
|
return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType)
|
|
.then([=](web::http::http_response localVarResponse)
|
|
{
|
|
// 1xx - informational : OK
|
|
// 2xx - successful : OK
|
|
// 3xx - redirection : OK
|
|
// 4xx - client error : not OK
|
|
// 5xx - client error : not OK
|
|
if (localVarResponse.status_code() >= 400)
|
|
{
|
|
throw ApiException(localVarResponse.status_code()
|
|
, utility::conversions::to_string_t("error calling logoutUser: ") + localVarResponse.reason_phrase()
|
|
, std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
|
|
}
|
|
|
|
// check response content type
|
|
if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type")))
|
|
{
|
|
utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")];
|
|
if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos )
|
|
{
|
|
throw ApiException(500
|
|
, utility::conversions::to_string_t("error calling logoutUser: unexpected response type: ") + localVarContentType
|
|
, std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
|
|
}
|
|
}
|
|
|
|
return localVarResponse.extract_string();
|
|
})
|
|
.then([=](utility::string_t localVarResponse)
|
|
{
|
|
return void();
|
|
});
|
|
}
|
|
pplx::task<void> UserApi::updateUser(utility::string_t username, std::shared_ptr<User> user)
|
|
{
|
|
|
|
// verify the required parameter 'user' is set
|
|
if (user == nullptr)
|
|
{
|
|
throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'user' when calling UserApi->updateUser"));
|
|
}
|
|
|
|
|
|
std::shared_ptr<ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() );
|
|
utility::string_t localVarPath = utility::conversions::to_string_t("/user/{username}");
|
|
boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("username") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(username));
|
|
|
|
std::map<utility::string_t, utility::string_t> localVarQueryParams;
|
|
std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() );
|
|
std::map<utility::string_t, utility::string_t> localVarFormParams;
|
|
std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams;
|
|
|
|
std::unordered_set<utility::string_t> localVarResponseHttpContentTypes;
|
|
|
|
utility::string_t localVarResponseHttpContentType;
|
|
|
|
// use JSON if possible
|
|
if ( localVarResponseHttpContentTypes.size() == 0 )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("application/json");
|
|
}
|
|
// JSON
|
|
else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("application/json");
|
|
}
|
|
// multipart formdata
|
|
else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() )
|
|
{
|
|
localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
|
}
|
|
else
|
|
{
|
|
throw ApiException(400, utility::conversions::to_string_t("UserApi->updateUser does not produce any supported media type"));
|
|
}
|
|
|
|
localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType;
|
|
|
|
std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes;
|
|
|
|
|
|
std::shared_ptr<IHttpBody> localVarHttpBody;
|
|
utility::string_t localVarRequestHttpContentType;
|
|
|
|
// use JSON if possible
|
|
if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() )
|
|
{
|
|
localVarRequestHttpContentType = utility::conversions::to_string_t("application/json");
|
|
web::json::value localVarJson;
|
|
|
|
localVarJson = ModelBase::toJson(user);
|
|
|
|
|
|
localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) );
|
|
}
|
|
// multipart formdata
|
|
else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() )
|
|
{
|
|
localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
|
std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData);
|
|
|
|
if(user.get())
|
|
{
|
|
user->toMultipart(localVarMultipart, utility::conversions::to_string_t("user"));
|
|
}
|
|
|
|
localVarHttpBody = localVarMultipart;
|
|
localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
|
|
}
|
|
else
|
|
{
|
|
throw ApiException(415, utility::conversions::to_string_t("UserApi->updateUser does not consume any supported media type"));
|
|
}
|
|
|
|
|
|
return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("PUT"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType)
|
|
.then([=](web::http::http_response localVarResponse)
|
|
{
|
|
// 1xx - informational : OK
|
|
// 2xx - successful : OK
|
|
// 3xx - redirection : OK
|
|
// 4xx - client error : not OK
|
|
// 5xx - client error : not OK
|
|
if (localVarResponse.status_code() >= 400)
|
|
{
|
|
throw ApiException(localVarResponse.status_code()
|
|
, utility::conversions::to_string_t("error calling updateUser: ") + localVarResponse.reason_phrase()
|
|
, std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
|
|
}
|
|
|
|
// check response content type
|
|
if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type")))
|
|
{
|
|
utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")];
|
|
if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos )
|
|
{
|
|
throw ApiException(500
|
|
, utility::conversions::to_string_t("error calling updateUser: unexpected response type: ") + localVarContentType
|
|
, std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
|
|
}
|
|
}
|
|
|
|
return localVarResponse.extract_string();
|
|
})
|
|
.then([=](utility::string_t localVarResponse)
|
|
{
|
|
return void();
|
|
});
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|