/** * 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 "StoreApi.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; StoreApi::StoreApi( std::shared_ptr apiClient ) : m_ApiClient(apiClient) { } StoreApi::~StoreApi() { } pplx::task StoreApi::deleteOrder(utility::string_t orderId) { std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); utility::string_t localVarPath = utility::conversions::to_string_t("/store/order/{orderId}"); boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("orderId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(orderId)); 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("StoreApi->deleteOrder 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("StoreApi->deleteOrder 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 deleteOrder: ") + 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 deleteOrder: 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> StoreApi::getInventory() { std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); utility::string_t localVarPath = utility::conversions::to_string_t("/store/inventory"); 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/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("StoreApi->getInventory 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("StoreApi->getInventory does not consume any supported media type")); } // authentication (api_key) required { utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("api_key")); if ( localVarApiKey.size() > 0 ) { localVarHeaderParams[utility::conversions::to_string_t("api_key")] = localVarApiKey; } } 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 getInventory: ") + 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 getInventory: unexpected response type: ") + localVarContentType , std::make_shared(localVarResponse.extract_utf8string(true).get())); } } return localVarResponse.extract_string(); }) .then([=](utility::string_t localVarResponse) { std::map localVarResult; if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json")) { web::json::value localVarJson = web::json::value::parse(localVarResponse); for( auto& localVarItem : localVarJson.as_object() ) { localVarResult[localVarItem.first] = ModelBase::int32_tFromJson(localVarItem.second); } } // 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 getInventory: unsupported response type")); } return localVarResult; }); } pplx::task> StoreApi::getOrderById(int64_t orderId) { std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); utility::string_t localVarPath = utility::conversions::to_string_t("/store/order/{orderId}"); boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("orderId") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(orderId)); 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("StoreApi->getOrderById 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("StoreApi->getOrderById 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 getOrderById: ") + 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 getOrderById: 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 Order()); 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 getOrderById: unsupported response type")); } return localVarResult; }); } pplx::task> StoreApi::placeOrder(std::shared_ptr order) { // verify the required parameter 'order' is set if (order == nullptr) { throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'order' when calling StoreApi->placeOrder")); } std::shared_ptr localVarApiConfiguration( m_ApiClient->getConfiguration() ); utility::string_t localVarPath = utility::conversions::to_string_t("/store/order"); 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("StoreApi->placeOrder 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(order); 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(order.get()) { order->toMultipart(localVarMultipart, utility::conversions::to_string_t("order")); } localVarHttpBody = localVarMultipart; localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary(); } else { throw ApiException(415, utility::conversions::to_string_t("StoreApi->placeOrder 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 placeOrder: ") + 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 placeOrder: 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 Order()); 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 placeOrder: unsupported response type")); } return localVarResult; }); } } } } }