mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-20 15:57:07 +00:00
[CppRest] Remove U macro (#6903)
* [CppRest] Replace U macro with conversion function for default string values. * [CppRest] Replace U macro with conversion function in templates. * [CppRest] Update cpprest petstore client sample.
This commit is contained in:
@@ -42,12 +42,12 @@ pplx::task<void> UserApi::createUser(std::shared_ptr<User> body)
|
||||
// verify the required parameter 'body' is set
|
||||
if (body == nullptr)
|
||||
{
|
||||
throw ApiException(400, U("Missing required parameter 'body' when calling UserApi->createUser"));
|
||||
throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'body' when calling UserApi->createUser"));
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
|
||||
utility::string_t path = U("/user");
|
||||
utility::string_t path = utility::conversions::to_string_t("/user");
|
||||
|
||||
std::map<utility::string_t, utility::string_t> queryParams;
|
||||
std::map<utility::string_t, utility::string_t> headerParams( apiConfiguration->getDefaultHeaders() );
|
||||
@@ -55,32 +55,32 @@ pplx::task<void> UserApi::createUser(std::shared_ptr<User> body)
|
||||
std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;
|
||||
|
||||
std::unordered_set<utility::string_t> responseHttpContentTypes;
|
||||
responseHttpContentTypes.insert( U("application/xml") );
|
||||
responseHttpContentTypes.insert( U("application/json") );
|
||||
responseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") );
|
||||
responseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );
|
||||
|
||||
utility::string_t responseHttpContentType;
|
||||
|
||||
// use JSON if possible
|
||||
if ( responseHttpContentTypes.size() == 0 )
|
||||
{
|
||||
responseHttpContentType = U("application/json");
|
||||
responseHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
}
|
||||
// JSON
|
||||
else if ( responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() )
|
||||
else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() )
|
||||
{
|
||||
responseHttpContentType = U("application/json");
|
||||
responseHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
}
|
||||
// multipart formdata
|
||||
else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() )
|
||||
else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() )
|
||||
{
|
||||
responseHttpContentType = U("multipart/form-data");
|
||||
responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(400, U("UserApi->createUser does not produce any supported media type"));
|
||||
throw ApiException(400, utility::conversions::to_string_t("UserApi->createUser does not produce any supported media type"));
|
||||
}
|
||||
|
||||
headerParams[U("Accept")] = responseHttpContentType;
|
||||
headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;
|
||||
|
||||
std::unordered_set<utility::string_t> consumeHttpContentTypes;
|
||||
|
||||
@@ -89,9 +89,9 @@ pplx::task<void> UserApi::createUser(std::shared_ptr<User> body)
|
||||
utility::string_t requestHttpContentType;
|
||||
|
||||
// use JSON if possible
|
||||
if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() )
|
||||
if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() )
|
||||
{
|
||||
requestHttpContentType = U("application/json");
|
||||
requestHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
web::json::value json;
|
||||
|
||||
json = ModelBase::toJson(body);
|
||||
@@ -99,25 +99,25 @@ pplx::task<void> UserApi::createUser(std::shared_ptr<User> body)
|
||||
httpBody = std::shared_ptr<IHttpBody>( new JsonBody( json ) );
|
||||
}
|
||||
// multipart formdata
|
||||
else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() )
|
||||
else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() )
|
||||
{
|
||||
requestHttpContentType = U("multipart/form-data");
|
||||
requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
std::shared_ptr<MultipartFormData> multipart(new MultipartFormData);
|
||||
if(body.get())
|
||||
{
|
||||
body->toMultipart(multipart, U("body"));
|
||||
body->toMultipart(multipart, utility::conversions::to_string_t("body"));
|
||||
}
|
||||
|
||||
httpBody = multipart;
|
||||
requestHttpContentType += U("; boundary=") + multipart->getBoundary();
|
||||
requestHttpContentType += utility::conversions::to_string_t("; boundary=") + multipart->getBoundary();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, U("UserApi->createUser does not consume any supported media type"));
|
||||
throw ApiException(415, utility::conversions::to_string_t("UserApi->createUser does not consume any supported media type"));
|
||||
}
|
||||
|
||||
|
||||
return m_ApiClient->callApi(path, U("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType)
|
||||
return m_ApiClient->callApi(path, utility::conversions::to_string_t("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType)
|
||||
.then([=](web::http::http_response response)
|
||||
{
|
||||
// 1xx - informational : OK
|
||||
@@ -128,18 +128,18 @@ pplx::task<void> UserApi::createUser(std::shared_ptr<User> body)
|
||||
if (response.status_code() >= 400)
|
||||
{
|
||||
throw ApiException(response.status_code()
|
||||
, U("error calling createUser: ") + response.reason_phrase()
|
||||
, utility::conversions::to_string_t("error calling createUser: ") + response.reason_phrase()
|
||||
, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
|
||||
}
|
||||
|
||||
// check response content type
|
||||
if(response.headers().has(U("Content-Type")))
|
||||
if(response.headers().has(utility::conversions::to_string_t("Content-Type")))
|
||||
{
|
||||
utility::string_t contentType = response.headers()[U("Content-Type")];
|
||||
utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")];
|
||||
if( contentType.find(responseHttpContentType) == std::string::npos )
|
||||
{
|
||||
throw ApiException(500
|
||||
, U("error calling createUser: unexpected response type: ") + contentType
|
||||
, utility::conversions::to_string_t("error calling createUser: unexpected response type: ") + contentType
|
||||
, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
|
||||
}
|
||||
}
|
||||
@@ -156,7 +156,7 @@ pplx::task<void> UserApi::createUsersWithArrayInput(std::vector<std::shared_ptr<
|
||||
|
||||
|
||||
std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
|
||||
utility::string_t path = U("/user/createWithArray");
|
||||
utility::string_t path = utility::conversions::to_string_t("/user/createWithArray");
|
||||
|
||||
std::map<utility::string_t, utility::string_t> queryParams;
|
||||
std::map<utility::string_t, utility::string_t> headerParams( apiConfiguration->getDefaultHeaders() );
|
||||
@@ -164,32 +164,32 @@ pplx::task<void> UserApi::createUsersWithArrayInput(std::vector<std::shared_ptr<
|
||||
std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;
|
||||
|
||||
std::unordered_set<utility::string_t> responseHttpContentTypes;
|
||||
responseHttpContentTypes.insert( U("application/xml") );
|
||||
responseHttpContentTypes.insert( U("application/json") );
|
||||
responseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") );
|
||||
responseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );
|
||||
|
||||
utility::string_t responseHttpContentType;
|
||||
|
||||
// use JSON if possible
|
||||
if ( responseHttpContentTypes.size() == 0 )
|
||||
{
|
||||
responseHttpContentType = U("application/json");
|
||||
responseHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
}
|
||||
// JSON
|
||||
else if ( responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() )
|
||||
else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() )
|
||||
{
|
||||
responseHttpContentType = U("application/json");
|
||||
responseHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
}
|
||||
// multipart formdata
|
||||
else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() )
|
||||
else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() )
|
||||
{
|
||||
responseHttpContentType = U("multipart/form-data");
|
||||
responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(400, U("UserApi->createUsersWithArrayInput does not produce any supported media type"));
|
||||
throw ApiException(400, utility::conversions::to_string_t("UserApi->createUsersWithArrayInput does not produce any supported media type"));
|
||||
}
|
||||
|
||||
headerParams[U("Accept")] = responseHttpContentType;
|
||||
headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;
|
||||
|
||||
std::unordered_set<utility::string_t> consumeHttpContentTypes;
|
||||
|
||||
@@ -198,9 +198,9 @@ pplx::task<void> UserApi::createUsersWithArrayInput(std::vector<std::shared_ptr<
|
||||
utility::string_t requestHttpContentType;
|
||||
|
||||
// use JSON if possible
|
||||
if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() )
|
||||
if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() )
|
||||
{
|
||||
requestHttpContentType = U("application/json");
|
||||
requestHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
web::json::value json;
|
||||
|
||||
{
|
||||
@@ -216,9 +216,9 @@ pplx::task<void> UserApi::createUsersWithArrayInput(std::vector<std::shared_ptr<
|
||||
httpBody = std::shared_ptr<IHttpBody>( new JsonBody( json ) );
|
||||
}
|
||||
// multipart formdata
|
||||
else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() )
|
||||
else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() )
|
||||
{
|
||||
requestHttpContentType = U("multipart/form-data");
|
||||
requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
std::shared_ptr<MultipartFormData> multipart(new MultipartFormData);
|
||||
{
|
||||
std::vector<web::json::value> jsonArray;
|
||||
@@ -227,19 +227,19 @@ pplx::task<void> UserApi::createUsersWithArrayInput(std::vector<std::shared_ptr<
|
||||
jsonArray.push_back( item.get() ? item->toJson() : web::json::value::null() );
|
||||
|
||||
}
|
||||
multipart->add(ModelBase::toHttpContent(U("body"), web::json::value::array(jsonArray), U("application/json")));
|
||||
multipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("body"), web::json::value::array(jsonArray), utility::conversions::to_string_t("application/json")));
|
||||
}
|
||||
|
||||
httpBody = multipart;
|
||||
requestHttpContentType += U("; boundary=") + multipart->getBoundary();
|
||||
requestHttpContentType += utility::conversions::to_string_t("; boundary=") + multipart->getBoundary();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, U("UserApi->createUsersWithArrayInput does not consume any supported media type"));
|
||||
throw ApiException(415, utility::conversions::to_string_t("UserApi->createUsersWithArrayInput does not consume any supported media type"));
|
||||
}
|
||||
|
||||
|
||||
return m_ApiClient->callApi(path, U("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType)
|
||||
return m_ApiClient->callApi(path, utility::conversions::to_string_t("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType)
|
||||
.then([=](web::http::http_response response)
|
||||
{
|
||||
// 1xx - informational : OK
|
||||
@@ -250,18 +250,18 @@ pplx::task<void> UserApi::createUsersWithArrayInput(std::vector<std::shared_ptr<
|
||||
if (response.status_code() >= 400)
|
||||
{
|
||||
throw ApiException(response.status_code()
|
||||
, U("error calling createUsersWithArrayInput: ") + response.reason_phrase()
|
||||
, utility::conversions::to_string_t("error calling createUsersWithArrayInput: ") + response.reason_phrase()
|
||||
, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
|
||||
}
|
||||
|
||||
// check response content type
|
||||
if(response.headers().has(U("Content-Type")))
|
||||
if(response.headers().has(utility::conversions::to_string_t("Content-Type")))
|
||||
{
|
||||
utility::string_t contentType = response.headers()[U("Content-Type")];
|
||||
utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")];
|
||||
if( contentType.find(responseHttpContentType) == std::string::npos )
|
||||
{
|
||||
throw ApiException(500
|
||||
, U("error calling createUsersWithArrayInput: unexpected response type: ") + contentType
|
||||
, utility::conversions::to_string_t("error calling createUsersWithArrayInput: unexpected response type: ") + contentType
|
||||
, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
|
||||
}
|
||||
}
|
||||
@@ -278,7 +278,7 @@ pplx::task<void> UserApi::createUsersWithListInput(std::vector<std::shared_ptr<U
|
||||
|
||||
|
||||
std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
|
||||
utility::string_t path = U("/user/createWithList");
|
||||
utility::string_t path = utility::conversions::to_string_t("/user/createWithList");
|
||||
|
||||
std::map<utility::string_t, utility::string_t> queryParams;
|
||||
std::map<utility::string_t, utility::string_t> headerParams( apiConfiguration->getDefaultHeaders() );
|
||||
@@ -286,32 +286,32 @@ pplx::task<void> UserApi::createUsersWithListInput(std::vector<std::shared_ptr<U
|
||||
std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;
|
||||
|
||||
std::unordered_set<utility::string_t> responseHttpContentTypes;
|
||||
responseHttpContentTypes.insert( U("application/xml") );
|
||||
responseHttpContentTypes.insert( U("application/json") );
|
||||
responseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") );
|
||||
responseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );
|
||||
|
||||
utility::string_t responseHttpContentType;
|
||||
|
||||
// use JSON if possible
|
||||
if ( responseHttpContentTypes.size() == 0 )
|
||||
{
|
||||
responseHttpContentType = U("application/json");
|
||||
responseHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
}
|
||||
// JSON
|
||||
else if ( responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() )
|
||||
else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() )
|
||||
{
|
||||
responseHttpContentType = U("application/json");
|
||||
responseHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
}
|
||||
// multipart formdata
|
||||
else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() )
|
||||
else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() )
|
||||
{
|
||||
responseHttpContentType = U("multipart/form-data");
|
||||
responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(400, U("UserApi->createUsersWithListInput does not produce any supported media type"));
|
||||
throw ApiException(400, utility::conversions::to_string_t("UserApi->createUsersWithListInput does not produce any supported media type"));
|
||||
}
|
||||
|
||||
headerParams[U("Accept")] = responseHttpContentType;
|
||||
headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;
|
||||
|
||||
std::unordered_set<utility::string_t> consumeHttpContentTypes;
|
||||
|
||||
@@ -320,9 +320,9 @@ pplx::task<void> UserApi::createUsersWithListInput(std::vector<std::shared_ptr<U
|
||||
utility::string_t requestHttpContentType;
|
||||
|
||||
// use JSON if possible
|
||||
if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() )
|
||||
if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() )
|
||||
{
|
||||
requestHttpContentType = U("application/json");
|
||||
requestHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
web::json::value json;
|
||||
|
||||
{
|
||||
@@ -338,9 +338,9 @@ pplx::task<void> UserApi::createUsersWithListInput(std::vector<std::shared_ptr<U
|
||||
httpBody = std::shared_ptr<IHttpBody>( new JsonBody( json ) );
|
||||
}
|
||||
// multipart formdata
|
||||
else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() )
|
||||
else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() )
|
||||
{
|
||||
requestHttpContentType = U("multipart/form-data");
|
||||
requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
std::shared_ptr<MultipartFormData> multipart(new MultipartFormData);
|
||||
{
|
||||
std::vector<web::json::value> jsonArray;
|
||||
@@ -349,19 +349,19 @@ pplx::task<void> UserApi::createUsersWithListInput(std::vector<std::shared_ptr<U
|
||||
jsonArray.push_back( item.get() ? item->toJson() : web::json::value::null() );
|
||||
|
||||
}
|
||||
multipart->add(ModelBase::toHttpContent(U("body"), web::json::value::array(jsonArray), U("application/json")));
|
||||
multipart->add(ModelBase::toHttpContent(utility::conversions::to_string_t("body"), web::json::value::array(jsonArray), utility::conversions::to_string_t("application/json")));
|
||||
}
|
||||
|
||||
httpBody = multipart;
|
||||
requestHttpContentType += U("; boundary=") + multipart->getBoundary();
|
||||
requestHttpContentType += utility::conversions::to_string_t("; boundary=") + multipart->getBoundary();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, U("UserApi->createUsersWithListInput does not consume any supported media type"));
|
||||
throw ApiException(415, utility::conversions::to_string_t("UserApi->createUsersWithListInput does not consume any supported media type"));
|
||||
}
|
||||
|
||||
|
||||
return m_ApiClient->callApi(path, U("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType)
|
||||
return m_ApiClient->callApi(path, utility::conversions::to_string_t("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType)
|
||||
.then([=](web::http::http_response response)
|
||||
{
|
||||
// 1xx - informational : OK
|
||||
@@ -372,18 +372,18 @@ pplx::task<void> UserApi::createUsersWithListInput(std::vector<std::shared_ptr<U
|
||||
if (response.status_code() >= 400)
|
||||
{
|
||||
throw ApiException(response.status_code()
|
||||
, U("error calling createUsersWithListInput: ") + response.reason_phrase()
|
||||
, utility::conversions::to_string_t("error calling createUsersWithListInput: ") + response.reason_phrase()
|
||||
, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
|
||||
}
|
||||
|
||||
// check response content type
|
||||
if(response.headers().has(U("Content-Type")))
|
||||
if(response.headers().has(utility::conversions::to_string_t("Content-Type")))
|
||||
{
|
||||
utility::string_t contentType = response.headers()[U("Content-Type")];
|
||||
utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")];
|
||||
if( contentType.find(responseHttpContentType) == std::string::npos )
|
||||
{
|
||||
throw ApiException(500
|
||||
, U("error calling createUsersWithListInput: unexpected response type: ") + contentType
|
||||
, utility::conversions::to_string_t("error calling createUsersWithListInput: unexpected response type: ") + contentType
|
||||
, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
|
||||
}
|
||||
}
|
||||
@@ -400,8 +400,8 @@ pplx::task<void> UserApi::deleteUser(utility::string_t username)
|
||||
|
||||
|
||||
std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
|
||||
utility::string_t path = U("/user/{username}");
|
||||
boost::replace_all(path, U("{") U("username") U("}"), ApiClient::parameterToString(username));
|
||||
utility::string_t path = utility::conversions::to_string_t("/user/{username}");
|
||||
boost::replace_all(path, 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> queryParams;
|
||||
std::map<utility::string_t, utility::string_t> headerParams( apiConfiguration->getDefaultHeaders() );
|
||||
@@ -409,32 +409,32 @@ pplx::task<void> UserApi::deleteUser(utility::string_t username)
|
||||
std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;
|
||||
|
||||
std::unordered_set<utility::string_t> responseHttpContentTypes;
|
||||
responseHttpContentTypes.insert( U("application/xml") );
|
||||
responseHttpContentTypes.insert( U("application/json") );
|
||||
responseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") );
|
||||
responseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );
|
||||
|
||||
utility::string_t responseHttpContentType;
|
||||
|
||||
// use JSON if possible
|
||||
if ( responseHttpContentTypes.size() == 0 )
|
||||
{
|
||||
responseHttpContentType = U("application/json");
|
||||
responseHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
}
|
||||
// JSON
|
||||
else if ( responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() )
|
||||
else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() )
|
||||
{
|
||||
responseHttpContentType = U("application/json");
|
||||
responseHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
}
|
||||
// multipart formdata
|
||||
else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() )
|
||||
else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() )
|
||||
{
|
||||
responseHttpContentType = U("multipart/form-data");
|
||||
responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(400, U("UserApi->deleteUser does not produce any supported media type"));
|
||||
throw ApiException(400, utility::conversions::to_string_t("UserApi->deleteUser does not produce any supported media type"));
|
||||
}
|
||||
|
||||
headerParams[U("Accept")] = responseHttpContentType;
|
||||
headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;
|
||||
|
||||
std::unordered_set<utility::string_t> consumeHttpContentTypes;
|
||||
|
||||
@@ -443,22 +443,22 @@ pplx::task<void> UserApi::deleteUser(utility::string_t username)
|
||||
utility::string_t requestHttpContentType;
|
||||
|
||||
// use JSON if possible
|
||||
if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() )
|
||||
if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() )
|
||||
{
|
||||
requestHttpContentType = U("application/json");
|
||||
requestHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
}
|
||||
// multipart formdata
|
||||
else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() )
|
||||
else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() )
|
||||
{
|
||||
requestHttpContentType = U("multipart/form-data");
|
||||
requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, U("UserApi->deleteUser does not consume any supported media type"));
|
||||
throw ApiException(415, utility::conversions::to_string_t("UserApi->deleteUser does not consume any supported media type"));
|
||||
}
|
||||
|
||||
|
||||
return m_ApiClient->callApi(path, U("DELETE"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType)
|
||||
return m_ApiClient->callApi(path, utility::conversions::to_string_t("DELETE"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType)
|
||||
.then([=](web::http::http_response response)
|
||||
{
|
||||
// 1xx - informational : OK
|
||||
@@ -469,18 +469,18 @@ pplx::task<void> UserApi::deleteUser(utility::string_t username)
|
||||
if (response.status_code() >= 400)
|
||||
{
|
||||
throw ApiException(response.status_code()
|
||||
, U("error calling deleteUser: ") + response.reason_phrase()
|
||||
, utility::conversions::to_string_t("error calling deleteUser: ") + response.reason_phrase()
|
||||
, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
|
||||
}
|
||||
|
||||
// check response content type
|
||||
if(response.headers().has(U("Content-Type")))
|
||||
if(response.headers().has(utility::conversions::to_string_t("Content-Type")))
|
||||
{
|
||||
utility::string_t contentType = response.headers()[U("Content-Type")];
|
||||
utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")];
|
||||
if( contentType.find(responseHttpContentType) == std::string::npos )
|
||||
{
|
||||
throw ApiException(500
|
||||
, U("error calling deleteUser: unexpected response type: ") + contentType
|
||||
, utility::conversions::to_string_t("error calling deleteUser: unexpected response type: ") + contentType
|
||||
, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
|
||||
}
|
||||
}
|
||||
@@ -497,8 +497,8 @@ pplx::task<std::shared_ptr<User>> UserApi::getUserByName(utility::string_t usern
|
||||
|
||||
|
||||
std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
|
||||
utility::string_t path = U("/user/{username}");
|
||||
boost::replace_all(path, U("{") U("username") U("}"), ApiClient::parameterToString(username));
|
||||
utility::string_t path = utility::conversions::to_string_t("/user/{username}");
|
||||
boost::replace_all(path, 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> queryParams;
|
||||
std::map<utility::string_t, utility::string_t> headerParams( apiConfiguration->getDefaultHeaders() );
|
||||
@@ -506,32 +506,32 @@ pplx::task<std::shared_ptr<User>> UserApi::getUserByName(utility::string_t usern
|
||||
std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;
|
||||
|
||||
std::unordered_set<utility::string_t> responseHttpContentTypes;
|
||||
responseHttpContentTypes.insert( U("application/xml") );
|
||||
responseHttpContentTypes.insert( U("application/json") );
|
||||
responseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") );
|
||||
responseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );
|
||||
|
||||
utility::string_t responseHttpContentType;
|
||||
|
||||
// use JSON if possible
|
||||
if ( responseHttpContentTypes.size() == 0 )
|
||||
{
|
||||
responseHttpContentType = U("application/json");
|
||||
responseHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
}
|
||||
// JSON
|
||||
else if ( responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() )
|
||||
else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() )
|
||||
{
|
||||
responseHttpContentType = U("application/json");
|
||||
responseHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
}
|
||||
// multipart formdata
|
||||
else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() )
|
||||
else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() )
|
||||
{
|
||||
responseHttpContentType = U("multipart/form-data");
|
||||
responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(400, U("UserApi->getUserByName does not produce any supported media type"));
|
||||
throw ApiException(400, utility::conversions::to_string_t("UserApi->getUserByName does not produce any supported media type"));
|
||||
}
|
||||
|
||||
headerParams[U("Accept")] = responseHttpContentType;
|
||||
headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;
|
||||
|
||||
std::unordered_set<utility::string_t> consumeHttpContentTypes;
|
||||
|
||||
@@ -540,22 +540,22 @@ pplx::task<std::shared_ptr<User>> UserApi::getUserByName(utility::string_t usern
|
||||
utility::string_t requestHttpContentType;
|
||||
|
||||
// use JSON if possible
|
||||
if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() )
|
||||
if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() )
|
||||
{
|
||||
requestHttpContentType = U("application/json");
|
||||
requestHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
}
|
||||
// multipart formdata
|
||||
else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() )
|
||||
else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() )
|
||||
{
|
||||
requestHttpContentType = U("multipart/form-data");
|
||||
requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, U("UserApi->getUserByName does not consume any supported media type"));
|
||||
throw ApiException(415, utility::conversions::to_string_t("UserApi->getUserByName does not consume any supported media type"));
|
||||
}
|
||||
|
||||
|
||||
return m_ApiClient->callApi(path, U("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType)
|
||||
return m_ApiClient->callApi(path, utility::conversions::to_string_t("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType)
|
||||
.then([=](web::http::http_response response)
|
||||
{
|
||||
// 1xx - informational : OK
|
||||
@@ -566,18 +566,18 @@ pplx::task<std::shared_ptr<User>> UserApi::getUserByName(utility::string_t usern
|
||||
if (response.status_code() >= 400)
|
||||
{
|
||||
throw ApiException(response.status_code()
|
||||
, U("error calling getUserByName: ") + response.reason_phrase()
|
||||
, utility::conversions::to_string_t("error calling getUserByName: ") + response.reason_phrase()
|
||||
, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
|
||||
}
|
||||
|
||||
// check response content type
|
||||
if(response.headers().has(U("Content-Type")))
|
||||
if(response.headers().has(utility::conversions::to_string_t("Content-Type")))
|
||||
{
|
||||
utility::string_t contentType = response.headers()[U("Content-Type")];
|
||||
utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")];
|
||||
if( contentType.find(responseHttpContentType) == std::string::npos )
|
||||
{
|
||||
throw ApiException(500
|
||||
, U("error calling getUserByName: unexpected response type: ") + contentType
|
||||
, utility::conversions::to_string_t("error calling getUserByName: unexpected response type: ") + contentType
|
||||
, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
|
||||
}
|
||||
}
|
||||
@@ -588,20 +588,20 @@ pplx::task<std::shared_ptr<User>> UserApi::getUserByName(utility::string_t usern
|
||||
{
|
||||
std::shared_ptr<User> result(new User());
|
||||
|
||||
if(responseHttpContentType == U("application/json"))
|
||||
if(responseHttpContentType == utility::conversions::to_string_t("application/json"))
|
||||
{
|
||||
web::json::value json = web::json::value::parse(response);
|
||||
|
||||
result->fromJson(json);
|
||||
}
|
||||
// else if(responseHttpContentType == U("multipart/form-data"))
|
||||
// else if(responseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
||||
// {
|
||||
// TODO multipart response parsing
|
||||
// }
|
||||
else
|
||||
{
|
||||
throw ApiException(500
|
||||
, U("error calling getUserByName: unsupported response type"));
|
||||
, utility::conversions::to_string_t("error calling getUserByName: unsupported response type"));
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -612,7 +612,7 @@ pplx::task<utility::string_t> UserApi::loginUser(utility::string_t username, uti
|
||||
|
||||
|
||||
std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
|
||||
utility::string_t path = U("/user/login");
|
||||
utility::string_t path = utility::conversions::to_string_t("/user/login");
|
||||
|
||||
std::map<utility::string_t, utility::string_t> queryParams;
|
||||
std::map<utility::string_t, utility::string_t> headerParams( apiConfiguration->getDefaultHeaders() );
|
||||
@@ -620,69 +620,69 @@ pplx::task<utility::string_t> UserApi::loginUser(utility::string_t username, uti
|
||||
std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;
|
||||
|
||||
std::unordered_set<utility::string_t> responseHttpContentTypes;
|
||||
responseHttpContentTypes.insert( U("application/xml") );
|
||||
responseHttpContentTypes.insert( U("application/json") );
|
||||
responseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") );
|
||||
responseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );
|
||||
|
||||
utility::string_t responseHttpContentType;
|
||||
|
||||
// use JSON if possible
|
||||
if ( responseHttpContentTypes.size() == 0 )
|
||||
{
|
||||
responseHttpContentType = U("text/plain");
|
||||
responseHttpContentType = utility::conversions::to_string_t("text/plain");
|
||||
}
|
||||
// JSON
|
||||
else if ( responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() )
|
||||
else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() )
|
||||
{
|
||||
responseHttpContentType = U("application/json");
|
||||
responseHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
}
|
||||
// multipart formdata
|
||||
else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() )
|
||||
else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() )
|
||||
{
|
||||
responseHttpContentType = U("multipart/form-data");
|
||||
responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
// plain text
|
||||
else if( responseHttpContentTypes.find(U("text/plain")) != responseHttpContentTypes.end() )
|
||||
else if( responseHttpContentTypes.find(utility::conversions::to_string_t("text/plain")) != responseHttpContentTypes.end() )
|
||||
{
|
||||
responseHttpContentType = U("text/plain");
|
||||
responseHttpContentType = utility::conversions::to_string_t("text/plain");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(400, U("UserApi->loginUser does not produce any supported media type"));
|
||||
throw ApiException(400, utility::conversions::to_string_t("UserApi->loginUser does not produce any supported media type"));
|
||||
}
|
||||
|
||||
headerParams[U("Accept")] = responseHttpContentType;
|
||||
headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;
|
||||
|
||||
std::unordered_set<utility::string_t> consumeHttpContentTypes;
|
||||
|
||||
|
||||
{
|
||||
queryParams[U("username")] = ApiClient::parameterToString(username);
|
||||
queryParams[utility::conversions::to_string_t("username")] = ApiClient::parameterToString(username);
|
||||
}
|
||||
|
||||
{
|
||||
queryParams[U("password")] = ApiClient::parameterToString(password);
|
||||
queryParams[utility::conversions::to_string_t("password")] = ApiClient::parameterToString(password);
|
||||
}
|
||||
|
||||
std::shared_ptr<IHttpBody> httpBody;
|
||||
utility::string_t requestHttpContentType;
|
||||
|
||||
// use JSON if possible
|
||||
if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() )
|
||||
if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() )
|
||||
{
|
||||
requestHttpContentType = U("application/json");
|
||||
requestHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
}
|
||||
// multipart formdata
|
||||
else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() )
|
||||
else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() )
|
||||
{
|
||||
requestHttpContentType = U("multipart/form-data");
|
||||
requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, U("UserApi->loginUser does not consume any supported media type"));
|
||||
throw ApiException(415, utility::conversions::to_string_t("UserApi->loginUser does not consume any supported media type"));
|
||||
}
|
||||
|
||||
|
||||
return m_ApiClient->callApi(path, U("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType)
|
||||
return m_ApiClient->callApi(path, utility::conversions::to_string_t("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType)
|
||||
.then([=](web::http::http_response response)
|
||||
{
|
||||
// 1xx - informational : OK
|
||||
@@ -693,18 +693,18 @@ pplx::task<utility::string_t> UserApi::loginUser(utility::string_t username, uti
|
||||
if (response.status_code() >= 400)
|
||||
{
|
||||
throw ApiException(response.status_code()
|
||||
, U("error calling loginUser: ") + response.reason_phrase()
|
||||
, utility::conversions::to_string_t("error calling loginUser: ") + response.reason_phrase()
|
||||
, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
|
||||
}
|
||||
|
||||
// check response content type
|
||||
if(response.headers().has(U("Content-Type")))
|
||||
if(response.headers().has(utility::conversions::to_string_t("Content-Type")))
|
||||
{
|
||||
utility::string_t contentType = response.headers()[U("Content-Type")];
|
||||
utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")];
|
||||
if( contentType.find(responseHttpContentType) == std::string::npos )
|
||||
{
|
||||
throw ApiException(500
|
||||
, U("error calling loginUser: unexpected response type: ") + contentType
|
||||
, utility::conversions::to_string_t("error calling loginUser: unexpected response type: ") + contentType
|
||||
, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
|
||||
}
|
||||
}
|
||||
@@ -713,27 +713,27 @@ pplx::task<utility::string_t> UserApi::loginUser(utility::string_t username, uti
|
||||
})
|
||||
.then([=](utility::string_t response)
|
||||
{
|
||||
utility::string_t result(U(""));
|
||||
utility::string_t result(utility::conversions::to_string_t(""));
|
||||
|
||||
if(responseHttpContentType == U("application/json"))
|
||||
if(responseHttpContentType == utility::conversions::to_string_t("application/json"))
|
||||
{
|
||||
web::json::value json = web::json::value::parse(response);
|
||||
|
||||
result = ModelBase::stringFromJson(json);
|
||||
|
||||
}
|
||||
else if(responseHttpContentType == U("text/plain"))
|
||||
else if(responseHttpContentType == utility::conversions::to_string_t("text/plain"))
|
||||
{
|
||||
result = response;
|
||||
}
|
||||
// else if(responseHttpContentType == U("multipart/form-data"))
|
||||
// else if(responseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
|
||||
// {
|
||||
// TODO multipart response parsing
|
||||
// }
|
||||
else
|
||||
{
|
||||
throw ApiException(500
|
||||
, U("error calling loginUser: unsupported response type"));
|
||||
, utility::conversions::to_string_t("error calling loginUser: unsupported response type"));
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -744,7 +744,7 @@ pplx::task<void> UserApi::logoutUser()
|
||||
|
||||
|
||||
std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
|
||||
utility::string_t path = U("/user/logout");
|
||||
utility::string_t path = utility::conversions::to_string_t("/user/logout");
|
||||
|
||||
std::map<utility::string_t, utility::string_t> queryParams;
|
||||
std::map<utility::string_t, utility::string_t> headerParams( apiConfiguration->getDefaultHeaders() );
|
||||
@@ -752,32 +752,32 @@ pplx::task<void> UserApi::logoutUser()
|
||||
std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;
|
||||
|
||||
std::unordered_set<utility::string_t> responseHttpContentTypes;
|
||||
responseHttpContentTypes.insert( U("application/xml") );
|
||||
responseHttpContentTypes.insert( U("application/json") );
|
||||
responseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") );
|
||||
responseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );
|
||||
|
||||
utility::string_t responseHttpContentType;
|
||||
|
||||
// use JSON if possible
|
||||
if ( responseHttpContentTypes.size() == 0 )
|
||||
{
|
||||
responseHttpContentType = U("application/json");
|
||||
responseHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
}
|
||||
// JSON
|
||||
else if ( responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() )
|
||||
else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() )
|
||||
{
|
||||
responseHttpContentType = U("application/json");
|
||||
responseHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
}
|
||||
// multipart formdata
|
||||
else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() )
|
||||
else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() )
|
||||
{
|
||||
responseHttpContentType = U("multipart/form-data");
|
||||
responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(400, U("UserApi->logoutUser does not produce any supported media type"));
|
||||
throw ApiException(400, utility::conversions::to_string_t("UserApi->logoutUser does not produce any supported media type"));
|
||||
}
|
||||
|
||||
headerParams[U("Accept")] = responseHttpContentType;
|
||||
headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;
|
||||
|
||||
std::unordered_set<utility::string_t> consumeHttpContentTypes;
|
||||
|
||||
@@ -786,22 +786,22 @@ pplx::task<void> UserApi::logoutUser()
|
||||
utility::string_t requestHttpContentType;
|
||||
|
||||
// use JSON if possible
|
||||
if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() )
|
||||
if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() )
|
||||
{
|
||||
requestHttpContentType = U("application/json");
|
||||
requestHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
}
|
||||
// multipart formdata
|
||||
else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() )
|
||||
else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() )
|
||||
{
|
||||
requestHttpContentType = U("multipart/form-data");
|
||||
requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, U("UserApi->logoutUser does not consume any supported media type"));
|
||||
throw ApiException(415, utility::conversions::to_string_t("UserApi->logoutUser does not consume any supported media type"));
|
||||
}
|
||||
|
||||
|
||||
return m_ApiClient->callApi(path, U("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType)
|
||||
return m_ApiClient->callApi(path, utility::conversions::to_string_t("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType)
|
||||
.then([=](web::http::http_response response)
|
||||
{
|
||||
// 1xx - informational : OK
|
||||
@@ -812,18 +812,18 @@ pplx::task<void> UserApi::logoutUser()
|
||||
if (response.status_code() >= 400)
|
||||
{
|
||||
throw ApiException(response.status_code()
|
||||
, U("error calling logoutUser: ") + response.reason_phrase()
|
||||
, utility::conversions::to_string_t("error calling logoutUser: ") + response.reason_phrase()
|
||||
, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
|
||||
}
|
||||
|
||||
// check response content type
|
||||
if(response.headers().has(U("Content-Type")))
|
||||
if(response.headers().has(utility::conversions::to_string_t("Content-Type")))
|
||||
{
|
||||
utility::string_t contentType = response.headers()[U("Content-Type")];
|
||||
utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")];
|
||||
if( contentType.find(responseHttpContentType) == std::string::npos )
|
||||
{
|
||||
throw ApiException(500
|
||||
, U("error calling logoutUser: unexpected response type: ") + contentType
|
||||
, utility::conversions::to_string_t("error calling logoutUser: unexpected response type: ") + contentType
|
||||
, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
|
||||
}
|
||||
}
|
||||
@@ -841,13 +841,13 @@ pplx::task<void> UserApi::updateUser(utility::string_t username, std::shared_ptr
|
||||
// verify the required parameter 'body' is set
|
||||
if (body == nullptr)
|
||||
{
|
||||
throw ApiException(400, U("Missing required parameter 'body' when calling UserApi->updateUser"));
|
||||
throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'body' when calling UserApi->updateUser"));
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
|
||||
utility::string_t path = U("/user/{username}");
|
||||
boost::replace_all(path, U("{") U("username") U("}"), ApiClient::parameterToString(username));
|
||||
utility::string_t path = utility::conversions::to_string_t("/user/{username}");
|
||||
boost::replace_all(path, 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> queryParams;
|
||||
std::map<utility::string_t, utility::string_t> headerParams( apiConfiguration->getDefaultHeaders() );
|
||||
@@ -855,32 +855,32 @@ pplx::task<void> UserApi::updateUser(utility::string_t username, std::shared_ptr
|
||||
std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;
|
||||
|
||||
std::unordered_set<utility::string_t> responseHttpContentTypes;
|
||||
responseHttpContentTypes.insert( U("application/xml") );
|
||||
responseHttpContentTypes.insert( U("application/json") );
|
||||
responseHttpContentTypes.insert( utility::conversions::to_string_t("application/xml") );
|
||||
responseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );
|
||||
|
||||
utility::string_t responseHttpContentType;
|
||||
|
||||
// use JSON if possible
|
||||
if ( responseHttpContentTypes.size() == 0 )
|
||||
{
|
||||
responseHttpContentType = U("application/json");
|
||||
responseHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
}
|
||||
// JSON
|
||||
else if ( responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() )
|
||||
else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() )
|
||||
{
|
||||
responseHttpContentType = U("application/json");
|
||||
responseHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
}
|
||||
// multipart formdata
|
||||
else if( responseHttpContentTypes.find(U("multipart/form-data")) != responseHttpContentTypes.end() )
|
||||
else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() )
|
||||
{
|
||||
responseHttpContentType = U("multipart/form-data");
|
||||
responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(400, U("UserApi->updateUser does not produce any supported media type"));
|
||||
throw ApiException(400, utility::conversions::to_string_t("UserApi->updateUser does not produce any supported media type"));
|
||||
}
|
||||
|
||||
headerParams[U("Accept")] = responseHttpContentType;
|
||||
headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;
|
||||
|
||||
std::unordered_set<utility::string_t> consumeHttpContentTypes;
|
||||
|
||||
@@ -889,9 +889,9 @@ pplx::task<void> UserApi::updateUser(utility::string_t username, std::shared_ptr
|
||||
utility::string_t requestHttpContentType;
|
||||
|
||||
// use JSON if possible
|
||||
if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(U("application/json")) != consumeHttpContentTypes.end() )
|
||||
if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() )
|
||||
{
|
||||
requestHttpContentType = U("application/json");
|
||||
requestHttpContentType = utility::conversions::to_string_t("application/json");
|
||||
web::json::value json;
|
||||
|
||||
json = ModelBase::toJson(body);
|
||||
@@ -899,25 +899,25 @@ pplx::task<void> UserApi::updateUser(utility::string_t username, std::shared_ptr
|
||||
httpBody = std::shared_ptr<IHttpBody>( new JsonBody( json ) );
|
||||
}
|
||||
// multipart formdata
|
||||
else if( consumeHttpContentTypes.find(U("multipart/form-data")) != consumeHttpContentTypes.end() )
|
||||
else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() )
|
||||
{
|
||||
requestHttpContentType = U("multipart/form-data");
|
||||
requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
|
||||
std::shared_ptr<MultipartFormData> multipart(new MultipartFormData);
|
||||
if(body.get())
|
||||
{
|
||||
body->toMultipart(multipart, U("body"));
|
||||
body->toMultipart(multipart, utility::conversions::to_string_t("body"));
|
||||
}
|
||||
|
||||
httpBody = multipart;
|
||||
requestHttpContentType += U("; boundary=") + multipart->getBoundary();
|
||||
requestHttpContentType += utility::conversions::to_string_t("; boundary=") + multipart->getBoundary();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ApiException(415, U("UserApi->updateUser does not consume any supported media type"));
|
||||
throw ApiException(415, utility::conversions::to_string_t("UserApi->updateUser does not consume any supported media type"));
|
||||
}
|
||||
|
||||
|
||||
return m_ApiClient->callApi(path, U("PUT"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType)
|
||||
return m_ApiClient->callApi(path, utility::conversions::to_string_t("PUT"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType)
|
||||
.then([=](web::http::http_response response)
|
||||
{
|
||||
// 1xx - informational : OK
|
||||
@@ -928,18 +928,18 @@ pplx::task<void> UserApi::updateUser(utility::string_t username, std::shared_ptr
|
||||
if (response.status_code() >= 400)
|
||||
{
|
||||
throw ApiException(response.status_code()
|
||||
, U("error calling updateUser: ") + response.reason_phrase()
|
||||
, utility::conversions::to_string_t("error calling updateUser: ") + response.reason_phrase()
|
||||
, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
|
||||
}
|
||||
|
||||
// check response content type
|
||||
if(response.headers().has(U("Content-Type")))
|
||||
if(response.headers().has(utility::conversions::to_string_t("Content-Type")))
|
||||
{
|
||||
utility::string_t contentType = response.headers()[U("Content-Type")];
|
||||
utility::string_t contentType = response.headers()[utility::conversions::to_string_t("Content-Type")];
|
||||
if( contentType.find(responseHttpContentType) == std::string::npos )
|
||||
{
|
||||
throw ApiException(500
|
||||
, U("error calling updateUser: unexpected response type: ") + contentType
|
||||
, utility::conversions::to_string_t("error calling updateUser: unexpected response type: ") + contentType
|
||||
, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user