/** * 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.4. * https://openapi-generator.tech * Do not edit the class manually. */ #include "UserApi.h" #include "IHttpBody.h" #include "JsonBody.h" #include "MultipartFormData.h" #include #include namespace org { namespace openapitools { namespace client { namespace api { using namespace org::openapitools::client::model; UserApi::UserApi( std::shared_ptr apiClient ) : m_ApiClient(apiClient) { } UserApi::~UserApi() { } pplx::task UserApi::createUser(std::shared_ptr 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 localVarApiConfiguration( m_ApiClient->getConfiguration() ); utility::string_t localVarPath = utility::conversions::to_string_t("/user"); std::map localVarQueryParams; std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); std::map localVarFormParams; std::map> localVarFileParams; std::unordered_set 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 localVarConsumeHttpContentTypes; std::shared_ptr 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( 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 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) { if (m_ApiClient->getResponseHandler()) { m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); } // 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(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(localVarResponse.extract_utf8string(true).get())); } } return localVarResponse.extract_string(); }) .then([=](utility::string_t localVarResponse) { return void(); }); } pplx::task UserApi::createUsersWithArrayInput(std::vector> user) { std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); utility::string_t localVarPath = utility::conversions::to_string_t("/user/createWithArray"); std::map localVarQueryParams; std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); std::map localVarFormParams; std::map> localVarFileParams; std::unordered_set 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 localVarConsumeHttpContentTypes; std::shared_ptr 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 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( 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 localVarMultipart(new MultipartFormData); { std::vector 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) { if (m_ApiClient->getResponseHandler()) { m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); } // 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(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(localVarResponse.extract_utf8string(true).get())); } } return localVarResponse.extract_string(); }) .then([=](utility::string_t localVarResponse) { return void(); }); } pplx::task UserApi::createUsersWithListInput(std::vector> user) { std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); utility::string_t localVarPath = utility::conversions::to_string_t("/user/createWithList"); std::map localVarQueryParams; std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); std::map localVarFormParams; std::map> localVarFileParams; std::unordered_set 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 localVarConsumeHttpContentTypes; std::shared_ptr 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 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( 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 localVarMultipart(new MultipartFormData); { std::vector 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) { if (m_ApiClient->getResponseHandler()) { m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); } // 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(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(localVarResponse.extract_utf8string(true).get())); } } return localVarResponse.extract_string(); }) .then([=](utility::string_t localVarResponse) { return void(); }); } pplx::task UserApi::deleteUser(utility::string_t username) { std::shared_ptr 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 localVarQueryParams; std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); std::map localVarFormParams; std::map> localVarFileParams; std::unordered_set 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 localVarConsumeHttpContentTypes; std::shared_ptr 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) { if (m_ApiClient->getResponseHandler()) { m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); } // 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(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(localVarResponse.extract_utf8string(true).get())); } } return localVarResponse.extract_string(); }) .then([=](utility::string_t localVarResponse) { return void(); }); } pplx::task> UserApi::getUserByName(utility::string_t username) { std::shared_ptr 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 localVarQueryParams; std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); std::map localVarFormParams; std::map> localVarFileParams; std::unordered_set 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 localVarConsumeHttpContentTypes; std::shared_ptr 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) { if (m_ApiClient->getResponseHandler()) { m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); } // 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(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(localVarResponse.extract_utf8string(true).get())); } } return localVarResponse.extract_string(); }) .then([=](utility::string_t localVarResponse) { std::shared_ptr 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 UserApi::loginUser(utility::string_t username, utility::string_t password) { std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); utility::string_t localVarPath = utility::conversions::to_string_t("/user/login"); std::map localVarQueryParams; std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); std::map localVarFormParams; std::map> localVarFileParams; std::unordered_set 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 localVarConsumeHttpContentTypes; { localVarQueryParams[utility::conversions::to_string_t("username")] = ApiClient::parameterToString(username); } { localVarQueryParams[utility::conversions::to_string_t("password")] = ApiClient::parameterToString(password); } std::shared_ptr 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) { if (m_ApiClient->getResponseHandler()) { m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); } // 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(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(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 UserApi::logoutUser() { std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); utility::string_t localVarPath = utility::conversions::to_string_t("/user/logout"); std::map localVarQueryParams; std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); std::map localVarFormParams; std::map> localVarFileParams; std::unordered_set 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 localVarConsumeHttpContentTypes; std::shared_ptr 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) { if (m_ApiClient->getResponseHandler()) { m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); } // 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(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(localVarResponse.extract_utf8string(true).get())); } } return localVarResponse.extract_string(); }) .then([=](utility::string_t localVarResponse) { return void(); }); } pplx::task UserApi::updateUser(utility::string_t username, std::shared_ptr 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 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 localVarQueryParams; std::map localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() ); std::map localVarFormParams; std::map> localVarFileParams; std::unordered_set 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 localVarConsumeHttpContentTypes; std::shared_ptr 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( 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 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) { if (m_ApiClient->getResponseHandler()) { m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers()); } // 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(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(localVarResponse.extract_utf8string(true).get())); } } return localVarResponse.extract_string(); }) .then([=](utility::string_t localVarResponse) { return void(); }); } } } } }