text:
/**
* --------------------------------------------------------------------------------------------------------------------
* <copyright company="Aspose" file="ConversionApi.cpp">
*  Copyright (c) 2020 Aspose.HTML for Cloud
* </copyright>
* <summary>
*  Permission is hereby granted, free of charge, to any person obtaining a copy
*  of this software and associated documentation files (the "Software"), to deal
*  in the Software without restriction, including without limitation the rights
*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
*  copies of the Software, and to permit persons to whom the Software is
*  furnished to do so, subject to the following conditions:
*
*  The above copyright notice and this permission notice shall be included in all
*  copies or substantial portions of the Software.
*
*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
*  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
*  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*  SOFTWARE.
* </summary>
* --------------------------------------------------------------------------------------------------------------------
*/

#include "api/ConversionApi.h"
#include "IHttpBody.h"
#include "JsonBody.h"
#include <unordered_set>
#include <boost/algorithm/string/replace.hpp>

namespace com {
namespace aspose {
namespace api {

using namespace com::aspose::model;

ConversionApi::ConversionApi( std::shared_ptr<ApiClient> apiClient )
    : m_ApiClient(apiClient)
{
}

ConversionApi::~ConversionApi()
{
}

pplx::task<HttpContent>
ConversionApi::getConvertDocumentToImage(
    utility::string_t name,
    utility::string_t outFormat,
    boost::optional<int32_t> width,
    boost::optional<int32_t> height,
    boost::optional<int32_t> leftMargin,
    boost::optional<int32_t> rightMargin,
    boost::optional<int32_t> topMargin,
    boost::optional<int32_t> bottomMargin,
    boost::optional<int32_t> resolution,
    boost::optional<utility::string_t> folder,
    boost::optional<utility::string_t> storage
)
{

    std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
    utility::string_t path = utility::conversions::to_string_t("/html/{name}/convert/image/{outFormat}");
    boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("name") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(name));
    boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("outFormat") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(outFormat));

    std::map<utility::string_t, utility::string_t> queryParams;
    std::map<utility::string_t, utility::string_t> headerParams( apiConfiguration->getDefaultHeaders() );
    std::map<utility::string_t, utility::string_t> formParams;
    std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;

    std::unordered_set<utility::string_t> responseHttpContentTypes;
    responseHttpContentTypes.insert( utility::conversions::to_string_t("multipart/form-data") );

    utility::string_t responseHttpContentType;

    // use JSON if possible
    if ( responseHttpContentTypes.size() == 0 )
    {
        responseHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // JSON
    else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() )
    {
        responseHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // multipart formdata
    else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() )
    {
        responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
    }
    else
    {
        //It's going to be binary, so just use the first one.
        responseHttpContentType = *responseHttpContentTypes.begin();
    }

    headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;

    std::unordered_set<utility::string_t> consumeHttpContentTypes;
    consumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );

    if (width)
    {
        queryParams[utility::conversions::to_string_t("width")]
            = ApiClient::parameterToString(*width);
    }
    if (height)
    {
        queryParams[utility::conversions::to_string_t("height")]
            = ApiClient::parameterToString(*height);
    }
    if (leftMargin)
    {
        queryParams[utility::conversions::to_string_t("leftMargin")]
            = ApiClient::parameterToString(*leftMargin);
    }
    if (rightMargin)
    {
        queryParams[utility::conversions::to_string_t("rightMargin")]
            = ApiClient::parameterToString(*rightMargin);
    }
    if (topMargin)
    {
        queryParams[utility::conversions::to_string_t("topMargin")]
            = ApiClient::parameterToString(*topMargin);
    }
    if (bottomMargin)
    {
        queryParams[utility::conversions::to_string_t("bottomMargin")]
            = ApiClient::parameterToString(*bottomMargin);
    }
    if (resolution)
    {
        queryParams[utility::conversions::to_string_t("resolution")]
            = ApiClient::parameterToString(*resolution);
    }
    if (folder)
    {
        queryParams[utility::conversions::to_string_t("folder")]
            = ApiClient::parameterToString(*folder);
    }
    if (storage)
    {
        queryParams[utility::conversions::to_string_t("storage")]
            = ApiClient::parameterToString(*storage);
    }

    std::shared_ptr<IHttpBody> httpBody;
    utility::string_t requestHttpContentType;

    // use JSON if possible
    if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() )
    {
        requestHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // multipart formdata
    else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() )
    {
        requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
    }
    else
    {
        throw ApiException(415, utility::conversions::to_string_t("ConversionApi->getConvertDocumentToImage does not consume any supported media type"));
    }

    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
        // 2xx - successful    : OK
        // 3xx - redirection   : OK
        // 4xx - client error  : not OK
        // 5xx - client error  : not OK
        if (response.status_code() >= 400)
        {
            throw ApiException(response.status_code()
                , utility::conversions::to_string_t("error calling getConvertDocumentToImage: ") + response.reason_phrase()
                , std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
        }

        return response.extract_vector();
    })
    .then([=](std::vector<unsigned char> response)
    {
        HttpContent result;
        std::shared_ptr<std::stringstream> stream = std::make_shared<std::stringstream>(std::string(response.begin(), response.end()));
        result.setData(stream);
        return result;
    });
}
pplx::task<HttpContent>
ConversionApi::getConvertDocumentToImageByUrl(
    utility::string_t sourceUrl,
    utility::string_t outFormat,
    boost::optional<int32_t> width,
    boost::optional<int32_t> height,
    boost::optional<int32_t> leftMargin,
    boost::optional<int32_t> rightMargin,
    boost::optional<int32_t> topMargin,
    boost::optional<int32_t> bottomMargin,
    boost::optional<int32_t> resolution
)
{
    std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
    utility::string_t path = utility::conversions::to_string_t("/html/convert/image/{outFormat}");
    boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("outFormat") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(outFormat));

    std::map<utility::string_t, utility::string_t> queryParams;
    std::map<utility::string_t, utility::string_t> headerParams( apiConfiguration->getDefaultHeaders() );
    std::map<utility::string_t, utility::string_t> formParams;
    std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;

    std::unordered_set<utility::string_t> responseHttpContentTypes;
    responseHttpContentTypes.insert( utility::conversions::to_string_t("multipart/form-data") );

    utility::string_t responseHttpContentType;

    // use JSON if possible
    if ( responseHttpContentTypes.size() == 0 )
    {
        responseHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // JSON
    else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() )
    {
        responseHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // multipart formdata
    else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() )
    {
        responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
    }
    else
    {
        //It's going to be binary, so just use the first one.
        responseHttpContentType = *responseHttpContentTypes.begin();
    }

    headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;

    std::unordered_set<utility::string_t> consumeHttpContentTypes;
    consumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );

    {
        queryParams[utility::conversions::to_string_t("sourceUrl")]
            = ApiClient::parameterToString(sourceUrl);
    }
    if (width)
    {
        queryParams[utility::conversions::to_string_t("width")]
            = ApiClient::parameterToString(*width);
    }
    if (height)
    {
        queryParams[utility::conversions::to_string_t("height")]
            = ApiClient::parameterToString(*height);
    }
    if (leftMargin)
    {
        queryParams[utility::conversions::to_string_t("leftMargin")]
            = ApiClient::parameterToString(*leftMargin);
    }
    if (rightMargin)
    {
        queryParams[utility::conversions::to_string_t("rightMargin")]
            = ApiClient::parameterToString(*rightMargin);
    }
    if (topMargin)
    {
        queryParams[utility::conversions::to_string_t("topMargin")]
            = ApiClient::parameterToString(*topMargin);
    }
    if (bottomMargin)
    {
        queryParams[utility::conversions::to_string_t("bottomMargin")]
            = ApiClient::parameterToString(*bottomMargin);
    }
    if (resolution)
    {
        queryParams[utility::conversions::to_string_t("resolution")]

            = ApiClient::parameterToString(*resolution);
    }

    std::shared_ptr<IHttpBody> httpBody;
    utility::string_t requestHttpContentType;

    // use JSON if possible
    if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() )
    {
        requestHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // multipart formdata
    else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() )
    {
        requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
    }
    else
    {
        throw ApiException(415, utility::conversions::to_string_t("ConversionApi->getConvertDocumentToImageByUrl does not consume any supported media type"));
    }

    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
        // 2xx - successful    : OK
        // 3xx - redirection   : OK
        // 4xx - client error  : not OK
        // 5xx - client error  : not OK
        if (response.status_code() >= 400)
        {
            throw ApiException(response.status_code()
                , utility::conversions::to_string_t("error calling getConvertDocumentToImageByUrl: ") + response.reason_phrase()
                , std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
        }

        return response.extract_vector();
    })
    .then([=](std::vector<unsigned char> response)
    {
        HttpContent result;
        std::shared_ptr<std::stringstream> stream = std::make_shared<std::stringstream>(std::string(response.begin(), response.end()));
        result.setData(stream);
        return result;
    });
}
pplx::task<HttpContent> ConversionApi::getConvertDocumentToPdf(
    utility::string_t name,
    boost::optional<int32_t> width,
    boost::optional<int32_t> height,
    boost::optional<int32_t> leftMargin,
    boost::optional<int32_t> rightMargin,
    boost::optional<int32_t> topMargin,
    boost::optional<int32_t> bottomMargin,
    boost::optional<utility::string_t> folder,
    boost::optional<utility::string_t> storage
)
{
    std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
    utility::string_t path = utility::conversions::to_string_t("/html/{name}/convert/pdf");
    boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("name") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(name));

    std::map<utility::string_t, utility::string_t> queryParams;
    std::map<utility::string_t, utility::string_t> headerParams( apiConfiguration->getDefaultHeaders() );
    std::map<utility::string_t, utility::string_t> formParams;
    std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;

    std::unordered_set<utility::string_t> responseHttpContentTypes;
    responseHttpContentTypes.insert( utility::conversions::to_string_t("multipart/form-data") );

    utility::string_t responseHttpContentType;

    // use JSON if possible
    if ( responseHttpContentTypes.size() == 0 )
    {
        responseHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // JSON
    else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() )
    {
        responseHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // multipart formdata
    else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() )
    {
        responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
    }
    else
    {
        //It's going to be binary, so just use the first one.
        responseHttpContentType = *responseHttpContentTypes.begin();
    }

    headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;

    std::unordered_set<utility::string_t> consumeHttpContentTypes;
    consumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );

    if (width)
    {
        queryParams[utility::conversions::to_string_t("width")]
            = ApiClient::parameterToString(*width);
    }
    if (height)
    {
        queryParams[utility::conversions::to_string_t("height")]
            = ApiClient::parameterToString(*height);
    }
    if (leftMargin)
    {
        queryParams[utility::conversions::to_string_t("leftMargin")]
            = ApiClient::parameterToString(*leftMargin);
    }
    if (rightMargin)
    {
        queryParams[utility::conversions::to_string_t("rightMargin")]
            = ApiClient::parameterToString(*rightMargin);
    }
    if (topMargin)
    {
        queryParams[utility::conversions::to_string_t("topMargin")]
            = ApiClient::parameterToString(*topMargin);
    }
    if (bottomMargin)
    {
        queryParams[utility::conversions::to_string_t("bottomMargin")]
            = ApiClient::parameterToString(*bottomMargin);
    }
    if (folder)
    {
        queryParams[utility::conversions::to_string_t("folder")]
            = ApiClient::parameterToString(*folder);
    }
    if (storage)
    {
        queryParams[utility::conversions::to_string_t("storage")]
            = ApiClient::parameterToString(*storage);
    }

    std::shared_ptr<IHttpBody> httpBody;
    utility::string_t requestHttpContentType;

    // use JSON if possible
    if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() )
    {
        requestHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // multipart formdata
    else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() )
    {
        requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
    }
    else
    {
        throw ApiException(415, utility::conversions::to_string_t("ConversionApi->getConvertDocumentToPdf does not consume any supported media type"));
    }

    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
        // 2xx - successful    : OK
        // 3xx - redirection   : OK
        // 4xx - client error  : not OK
        // 5xx - client error  : not OK
        if (response.status_code() >= 400)
        {
            throw ApiException(response.status_code()
                , utility::conversions::to_string_t("error calling getConvertDocumentToPdf: ") + response.reason_phrase()
                , std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
        }

        return response.extract_vector();
    })
    .then([=](std::vector<unsigned char> response)
    {
        HttpContent result;
        std::shared_ptr<std::stringstream> stream = std::make_shared<std::stringstream>(std::string(response.begin(), response.end()));
        result.setData(stream);
        return result;
    });
}
pplx::task<HttpContent>
ConversionApi::getConvertDocumentToPdfByUrl(
    utility::string_t sourceUrl,
    boost::optional<int32_t> width,
    boost::optional<int32_t> height,
    boost::optional<int32_t> leftMargin,
    boost::optional<int32_t> rightMargin,
    boost::optional<int32_t> topMargin,
    boost::optional<int32_t> bottomMargin
)
{

    std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
    utility::string_t path = utility::conversions::to_string_t("/html/convert/pdf");

    std::map<utility::string_t, utility::string_t> queryParams;
    std::map<utility::string_t, utility::string_t> headerParams( apiConfiguration->getDefaultHeaders() );
    std::map<utility::string_t, utility::string_t> formParams;
    std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;

    std::unordered_set<utility::string_t> responseHttpContentTypes;
    responseHttpContentTypes.insert( utility::conversions::to_string_t("multipart/form-data") );

    utility::string_t responseHttpContentType;

    // use JSON if possible
    if ( responseHttpContentTypes.size() == 0 )
    {
        responseHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // JSON
    else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() )
    {
        responseHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // multipart formdata
    else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() )
    {
        responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
    }
    else
    {
        //It's going to be binary, so just use the first one.
        responseHttpContentType = *responseHttpContentTypes.begin();
    }

    headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;

    std::unordered_set<utility::string_t> consumeHttpContentTypes;
    consumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );

    queryParams[utility::conversions::to_string_t("sourceUrl")]
        = ApiClient::parameterToString(sourceUrl);

    if (width)
    {
        queryParams[utility::conversions::to_string_t("width")]
            = ApiClient::parameterToString(*width);
    }
    if (height)
    {
        queryParams[utility::conversions::to_string_t("height")]
            = ApiClient::parameterToString(*height);
    }
    if (leftMargin)
    {
        queryParams[utility::conversions::to_string_t("leftMargin")]
            = ApiClient::parameterToString(*leftMargin);
    }
    if (rightMargin)
    {
        queryParams[utility::conversions::to_string_t("rightMargin")]
            = ApiClient::parameterToString(*rightMargin);
    }
    if (topMargin)
    {
        queryParams[utility::conversions::to_string_t("topMargin")]
            = ApiClient::parameterToString(*topMargin);
    }
    if (bottomMargin)
    {
        queryParams[utility::conversions::to_string_t("bottomMargin")]
            = ApiClient::parameterToString(*bottomMargin);
    }

    std::shared_ptr<IHttpBody> httpBody;
    utility::string_t requestHttpContentType;

    // use JSON if possible
    if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() )
    {
        requestHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // multipart formdata
    else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() )
    {
        requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
    }
    else
    {
        throw ApiException(415, utility::conversions::to_string_t("ConversionApi->getConvertDocumentToPdfByUrl does not consume any supported media type"));
    }

    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
        // 2xx - successful    : OK
        // 3xx - redirection   : OK
        // 4xx - client error  : not OK
        // 5xx - client error  : not OK
        if (response.status_code() >= 400)
        {
            throw ApiException(response.status_code()
                , utility::conversions::to_string_t("error calling getConvertDocumentToPdfByUrl: ") + response.reason_phrase()
                , std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
        }

        return response.extract_vector();
    })
    .then([=](std::vector<unsigned char> response)
    {
        HttpContent result;
        std::shared_ptr<std::stringstream> stream = std::make_shared<std::stringstream>(std::string(response.begin(), response.end()));
        result.setData(stream);
        return result;
    });
}
pplx::task<HttpContent>
ConversionApi::getConvertDocumentToXps(
    utility::string_t name,
    boost::optional<int32_t> width,
    boost::optional<int32_t> height,
    boost::optional<int32_t> leftMargin,
    boost::optional<int32_t> rightMargin,
    boost::optional<int32_t> topMargin,
    boost::optional<int32_t> bottomMargin,
    boost::optional<utility::string_t> folder,
    boost::optional<utility::string_t> storage
)
{
    std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
    utility::string_t path = utility::conversions::to_string_t("/html/{name}/convert/xps");
    boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("name") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(name));

    std::map<utility::string_t, utility::string_t> queryParams;
    std::map<utility::string_t, utility::string_t> headerParams( apiConfiguration->getDefaultHeaders() );
    std::map<utility::string_t, utility::string_t> formParams;
    std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;

    std::unordered_set<utility::string_t> responseHttpContentTypes;
    responseHttpContentTypes.insert( utility::conversions::to_string_t("multipart/form-data") );

    utility::string_t responseHttpContentType;

    // use JSON if possible
    if ( responseHttpContentTypes.size() == 0 )
    {
        responseHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // JSON
    else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() )
    {
        responseHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // multipart formdata
    else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() )
    {
        responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
    }
    else
    {
        //It's going to be binary, so just use the first one.
        responseHttpContentType = *responseHttpContentTypes.begin();
    }

    headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;

    std::unordered_set<utility::string_t> consumeHttpContentTypes;
    consumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );

    if (width)
    {
        queryParams[utility::conversions::to_string_t("width")]
            = ApiClient::parameterToString(*width);
    }
    if (height)
    {
        queryParams[utility::conversions::to_string_t("height")]
            = ApiClient::parameterToString(*height);
    }
    if (leftMargin)
    {
        queryParams[utility::conversions::to_string_t("leftMargin")]
            = ApiClient::parameterToString(*leftMargin);
    }
    if (rightMargin)
    {
        queryParams[utility::conversions::to_string_t("rightMargin")]
            = ApiClient::parameterToString(*rightMargin);
    }
    if (topMargin)
    {
        queryParams[utility::conversions::to_string_t("topMargin")]
            = ApiClient::parameterToString(*topMargin);
    }
    if (bottomMargin)
    {
        queryParams[utility::conversions::to_string_t("bottomMargin")]
            = ApiClient::parameterToString(*bottomMargin);
    }
    if (folder)
    {
        queryParams[utility::conversions::to_string_t("folder")]
            = ApiClient::parameterToString(*folder);
    }
    if (storage)
    {
        queryParams[utility::conversions::to_string_t("storage")]
            = ApiClient::parameterToString(*storage);
    }

    std::shared_ptr<IHttpBody> httpBody;
    utility::string_t requestHttpContentType;

    // use JSON if possible
    if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() )
    {
        requestHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // multipart formdata
    else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() )
    {
        requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
    }
    else
    {
        throw ApiException(415, utility::conversions::to_string_t("ConversionApi->getConvertDocumentToXps does not consume any supported media type"));
    }

    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
        // 2xx - successful    : OK
        // 3xx - redirection   : OK
        // 4xx - client error  : not OK
        // 5xx - client error  : not OK
        if (response.status_code() >= 400)
        {
            throw ApiException(response.status_code()
                , utility::conversions::to_string_t("error calling getConvertDocumentToXps: ") + response.reason_phrase()
                , std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
        }

        return response.extract_vector();
    })
    .then([=](std::vector<unsigned char> response)
    {
        HttpContent result;
        std::shared_ptr<std::stringstream> stream = std::make_shared<std::stringstream>(std::string(response.begin(), response.end()));
        result.setData(stream);
        return result;
    });
}
pplx::task<HttpContent>
ConversionApi::getConvertDocumentToXpsByUrl(
    utility::string_t sourceUrl,
    boost::optional<int32_t> width,
    boost::optional<int32_t> height,
    boost::optional<int32_t> leftMargin,
    boost::optional<int32_t> rightMargin,
    boost::optional<int32_t> topMargin,
    boost::optional<int32_t> bottomMargin
)
{
    std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
    utility::string_t path = utility::conversions::to_string_t("/html/convert/xps");

    std::map<utility::string_t, utility::string_t> queryParams;
    std::map<utility::string_t, utility::string_t> headerParams( apiConfiguration->getDefaultHeaders() );
    std::map<utility::string_t, utility::string_t> formParams;
    std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;

    std::unordered_set<utility::string_t> responseHttpContentTypes;
    responseHttpContentTypes.insert( utility::conversions::to_string_t("multipart/form-data") );

    utility::string_t responseHttpContentType;

    // use JSON if possible
    if ( responseHttpContentTypes.size() == 0 )
    {
        responseHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // JSON
    else if ( responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end() )
    {
        responseHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // multipart formdata
    else if( responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end() )
    {
        responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
    }
    else
    {
        //It's going to be binary, so just use the first one.
        responseHttpContentType = *responseHttpContentTypes.begin();
    }

    headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;

    std::unordered_set<utility::string_t> consumeHttpContentTypes;
    consumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );

    queryParams[utility::conversions::to_string_t("sourceUrl")]
        = ApiClient::parameterToString(sourceUrl);

    if (width)
    {
        queryParams[utility::conversions::to_string_t("width")]
            = ApiClient::parameterToString(*width);
    }
    if (height)
    {
        queryParams[utility::conversions::to_string_t("height")]
            = ApiClient::parameterToString(*height);
    }
    if (leftMargin)
    {
        queryParams[utility::conversions::to_string_t("leftMargin")]
            = ApiClient::parameterToString(*leftMargin);
    }
    if (rightMargin)
    {
        queryParams[utility::conversions::to_string_t("rightMargin")]
            = ApiClient::parameterToString(*rightMargin);
    }
    if (topMargin)
    {
        queryParams[utility::conversions::to_string_t("topMargin")]
            = ApiClient::parameterToString(*topMargin);
    }
    if (bottomMargin)
    {
        queryParams[utility::conversions::to_string_t("bottomMargin")]
            = ApiClient::parameterToString(*bottomMargin);
    }

    std::shared_ptr<IHttpBody> httpBody;
    utility::string_t requestHttpContentType;

    // use JSON if possible
    if ( consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end() )
    {
        requestHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // multipart formdata
    else if( consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end() )
    {
        requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
    }
    else
    {
        throw ApiException(415, utility::conversions::to_string_t("ConversionApi->getConvertDocumentToXpsByUrl does not consume any supported media type"));
    }

    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
        // 2xx - successful    : OK
        // 3xx - redirection   : OK
        // 4xx - client error  : not OK
        // 5xx - client error  : not OK
        if (response.status_code() >= 400)
        {
            throw ApiException(response.status_code()
                , utility::conversions::to_string_t("error calling getConvertDocumentToXpsByUrl: ") + response.reason_phrase()
                , std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
        }

        return response.extract_vector();
    })
    .then([=](std::vector<unsigned char> response)
    {
        HttpContent result;
        std::shared_ptr<std::stringstream> stream = std::make_shared<std::stringstream>(std::string(response.begin(), response.end()));
        result.setData(stream);
        return result;
    });
}

pplx::task<HttpContent>
ConversionApi::postConvertDocumentInRequestToImage(
    utility::string_t outPath,
    utility::string_t outFormat,
    std::shared_ptr<HttpContent> file,
    boost::optional<int32_t> width,
    boost::optional<int32_t> height,
    boost::optional<int32_t> leftMargin,
    boost::optional<int32_t> rightMargin,
    boost::optional<int32_t> topMargin,
    boost::optional<int32_t> bottomMargin,
    boost::optional<int32_t> resolution,
    boost::optional<utility::string_t> storage
)
{
	// verify the required parameter 'file' is set
	if (file == nullptr)
	{
		throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'file' when calling ConversionApi->postConvertDocumentInRequestToImage"));
	}

	std::shared_ptr<ApiConfiguration> apiConfiguration(m_ApiClient->getConfiguration());
	utility::string_t path = utility::conversions::to_string_t("/html/convert/image/{outFormat}");
	boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("outFormat") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(outFormat));

	std::map<utility::string_t, utility::string_t> queryParams;
	std::map<utility::string_t, utility::string_t> headerParams(apiConfiguration->getDefaultHeaders());
	std::map<utility::string_t, utility::string_t> formParams;
	std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;

	std::unordered_set<utility::string_t> responseHttpContentTypes;
	responseHttpContentTypes.insert(utility::conversions::to_string_t("application/json"));

	utility::string_t responseHttpContentType;

	// use JSON if possible
	if (responseHttpContentTypes.size() == 0)
	{
		responseHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// JSON
	else if (responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end())
	{
		responseHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// multipart formdata
	else if (responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end())
	{
		responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
	}
	else
	{
		//It's going to be binary, so just use the first one.
		responseHttpContentType = *responseHttpContentTypes.begin();
	}

	headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;

	std::unordered_set<utility::string_t> consumeHttpContentTypes;
	consumeHttpContentTypes.insert(utility::conversions::to_string_t("multipart/form-data"));

	queryParams[utility::conversions::to_string_t("outPath")] = ApiClient::parameterToString(outPath);
    fileParams[utility::conversions::to_string_t("file")] = file;

    if (width)
	{
		queryParams[utility::conversions::to_string_t("width")]
            = ApiClient::parameterToString(*width);
	}
	if (height)
	{
		queryParams[utility::conversions::to_string_t("height")]
            = ApiClient::parameterToString(*height);
	}
	if (leftMargin)
	{
		queryParams[utility::conversions::to_string_t("leftMargin")]
            = ApiClient::parameterToString(*leftMargin);
	}
	if (rightMargin)
	{
		queryParams[utility::conversions::to_string_t("rightMargin")]
            = ApiClient::parameterToString(*rightMargin);
	}
	if (topMargin)
	{
		queryParams[utility::conversions::to_string_t("topMargin")]
            = ApiClient::parameterToString(*topMargin);
	}
	if (bottomMargin)
	{
		queryParams[utility::conversions::to_string_t("bottomMargin")]
            = ApiClient::parameterToString(*bottomMargin);
	}
	if (resolution)
	{
		queryParams[utility::conversions::to_string_t("resolution")]
            = ApiClient::parameterToString(*resolution);
	}

	std::shared_ptr<IHttpBody> httpBody;
	utility::string_t requestHttpContentType;

	// use JSON if possible
	if (consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end())
	{
		requestHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// multipart formdata
	else if (consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end())
	{
		requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
	}
	else
	{
		throw ApiException(415, utility::conversions::to_string_t("ConversionApi->postConvertDocumentInRequestToImage does not consume any supported media type"));
	}

	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
		// 2xx - successful    : OK
		// 3xx - redirection   : OK
		// 4xx - client error  : not OK
		// 5xx - client error  : not OK
		if (response.status_code() >= 400)
		{
			throw ApiException(response.status_code()
				, utility::conversions::to_string_t("error calling postConvertDocumentInRequestToImage: ") + response.reason_phrase()
				, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
		}

		// check response content type
		if (response.headers().has(utility::conversions::to_string_t("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
					, utility::conversions::to_string_t("error calling postConvertDocumentInRequestToImage: unexpected response type: ") + contentType
					, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
			}
		}

		return response.extract_vector();
	})
		.then([=](std::vector<unsigned char> response)
	{
		HttpContent result;
		std::shared_ptr<std::stringstream> stream = std::make_shared<std::stringstream>(std::string(response.begin(), response.end()));
		result.setData(stream);
		return result;
	});
}
pplx::task<HttpContent>
ConversionApi::postConvertDocumentInRequestToPdf(
    utility::string_t outPath,
    std::shared_ptr<HttpContent> file,
    boost::optional<int32_t> width,
    boost::optional<int32_t> height,
    boost::optional<int32_t> leftMargin,
    boost::optional<int32_t> rightMargin,
    boost::optional<int32_t> topMargin,
    boost::optional<int32_t> bottomMargin,
    boost::optional<utility::string_t> storage
)
{
    // verify the required parameter 'file' is set
    if (file == nullptr)
    {
        throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'file' when calling ConversionApi->postConvertDocumentInRequestToImage"));
    }

    std::shared_ptr<ApiConfiguration> apiConfiguration(m_ApiClient->getConfiguration());
    utility::string_t path = utility::conversions::to_string_t("/html/convert/pdf");

    std::map<utility::string_t, utility::string_t> queryParams;
    std::map<utility::string_t, utility::string_t> headerParams(apiConfiguration->getDefaultHeaders());
    std::map<utility::string_t, utility::string_t> formParams;
    std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;

    std::unordered_set<utility::string_t> responseHttpContentTypes;
    responseHttpContentTypes.insert(utility::conversions::to_string_t("application/json"));

    utility::string_t responseHttpContentType;

    // use JSON if possible
    if (responseHttpContentTypes.size() == 0)
    {
        responseHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // JSON
    else if (responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end())
    {
        responseHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // multipart formdata
    else if (responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end())
    {
        responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
    }
    else
    {
        //It's going to be binary, so just use the first one.
        responseHttpContentType = *responseHttpContentTypes.begin();
    }

    headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;

    std::unordered_set<utility::string_t> consumeHttpContentTypes;
    consumeHttpContentTypes.insert(utility::conversions::to_string_t("multipart/form-data"));

    queryParams[utility::conversions::to_string_t("outPath")] = ApiClient::parameterToString(outPath);
    fileParams[utility::conversions::to_string_t("file")] = file;

    if (width)
    {
        queryParams[utility::conversions::to_string_t("width")]
            = ApiClient::parameterToString(*width);
    }
    if (height)
    {
        queryParams[utility::conversions::to_string_t("height")]
            = ApiClient::parameterToString(*height);
    }
    if (leftMargin)
    {
        queryParams[utility::conversions::to_string_t("leftMargin")]
            = ApiClient::parameterToString(*leftMargin);
    }
    if (rightMargin)
    {
        queryParams[utility::conversions::to_string_t("rightMargin")]
            = ApiClient::parameterToString(*rightMargin);
    }
    if (topMargin)
    {
        queryParams[utility::conversions::to_string_t("topMargin")]
            = ApiClient::parameterToString(*topMargin);
    }
    if (bottomMargin)
    {
        queryParams[utility::conversions::to_string_t("bottomMargin")]
            = ApiClient::parameterToString(*bottomMargin);
    }
    if (storage)
    {
        queryParams[utility::conversions::to_string_t("storage")]
            = ApiClient::parameterToString(*storage);
    }

    std::shared_ptr<IHttpBody> httpBody;
    utility::string_t requestHttpContentType;

    // use JSON if possible
    if (consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end())
    {
        requestHttpContentType = utility::conversions::to_string_t("application/json");
    }
    // multipart formdata
    else if (consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end())
    {
        requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
    }
    else
    {
        throw ApiException(415, utility::conversions::to_string_t("ConversionApi->postConvertDocumentInRequestToPdf does not consume any supported media type"));
    }

	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
		// 2xx - successful    : OK
		// 3xx - redirection   : OK
		// 4xx - client error  : not OK
		// 5xx - client error  : not OK
		if (response.status_code() >= 400)
		{
			throw ApiException(response.status_code()
				, utility::conversions::to_string_t("error calling postConvertDocumentInRequestToPdf: ") + response.reason_phrase()
				, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
		}

		// check response content type
		if (response.headers().has(utility::conversions::to_string_t("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
					, utility::conversions::to_string_t("error calling postConvertDocumentInRequestToPdf: unexpected response type: ") + contentType
					, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
			}
		}

		return response.extract_vector();
	})
		.then([=](std::vector<unsigned char> response)
	{
		HttpContent result;
		std::shared_ptr<std::stringstream> stream = std::make_shared<std::stringstream>(std::string(response.begin(), response.end()));
		result.setData(stream);
		return result;
	});
}
pplx::task<HttpContent>
ConversionApi::postConvertDocumentInRequestToXps(
    utility::string_t outPath,
    std::shared_ptr<HttpContent> file,
    boost::optional<int32_t> width,
    boost::optional<int32_t> height,
    boost::optional<int32_t> leftMargin,
    boost::optional<int32_t> rightMargin,
    boost::optional<int32_t> topMargin,
    boost::optional<int32_t> bottomMargin,
    boost::optional<utility::string_t> storage
)
{
	// verify the required parameter 'file' is set
	if (file == nullptr)
	{
		throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'file' when calling ConversionApi->postConvertDocumentInRequestToXps"));
	}

	std::shared_ptr<ApiConfiguration> apiConfiguration(m_ApiClient->getConfiguration());
	utility::string_t path = utility::conversions::to_string_t("/html/convert/xps");

	std::map<utility::string_t, utility::string_t> queryParams;
	std::map<utility::string_t, utility::string_t> headerParams(apiConfiguration->getDefaultHeaders());
	std::map<utility::string_t, utility::string_t> formParams;
	std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;

	std::unordered_set<utility::string_t> responseHttpContentTypes;
	responseHttpContentTypes.insert(utility::conversions::to_string_t("application/json"));

	utility::string_t responseHttpContentType;

	// use JSON if possible
	if (responseHttpContentTypes.size() == 0)
	{
		responseHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// JSON
	else if (responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end())
	{
		responseHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// multipart formdata
	else if (responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end())
	{
		responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
	}
	else
	{
		//It's going to be binary, so just use the first one.
		responseHttpContentType = *responseHttpContentTypes.begin();
	}

	headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;

    std::unordered_set<utility::string_t> consumeHttpContentTypes;
    consumeHttpContentTypes.insert(utility::conversions::to_string_t("multipart/form-data"));

	queryParams[utility::conversions::to_string_t("outPath")]
        = ApiClient::parameterToString(outPath);
    fileParams[utility::conversions::to_string_t("file")] = file;

    if (width)
	{
		queryParams[utility::conversions::to_string_t("width")]
            = ApiClient::parameterToString(*width);
	}
	if (height)
	{
		queryParams[utility::conversions::to_string_t("height")]
            = ApiClient::parameterToString(*height);
	}
	if (leftMargin)
	{
		queryParams[utility::conversions::to_string_t("leftMargin")]
            = ApiClient::parameterToString(*leftMargin);
	}
	if (rightMargin)
	{
		queryParams[utility::conversions::to_string_t("rightMargin")]
            = ApiClient::parameterToString(*rightMargin);
	}
	if (topMargin)
	{
		queryParams[utility::conversions::to_string_t("topMargin")]
            = ApiClient::parameterToString(*topMargin);
	}
	if (bottomMargin)
	{
		queryParams[utility::conversions::to_string_t("bottomMargin")]
            = ApiClient::parameterToString(*bottomMargin);
	}
    if (storage)
    {
        queryParams[utility::conversions::to_string_t("storage")]
            = ApiClient::parameterToString(*storage);
    }

    std::shared_ptr<IHttpBody> httpBody;
    utility::string_t requestHttpContentType;

	// use JSON if possible
	if (consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end())
	{
		requestHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// multipart formdata
	else if (consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end())
	{
		requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
	}
	// application/octet-stream
	else if (consumeHttpContentTypes.find(utility::conversions::to_string_t("application/octet-stream")) != consumeHttpContentTypes.end())
	{
		requestHttpContentType = utility::conversions::to_string_t("application/octet-stream");
	}
	else
	{
		throw ApiException(415, utility::conversions::to_string_t("ConversionApi->postConvertDocumentInRequestToImage does not consume any supported media type"));
	}

	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
		// 2xx - successful    : OK
		// 3xx - redirection   : OK
		// 4xx - client error  : not OK
		// 5xx - client error  : not OK
		if (response.status_code() >= 400)
		{
			throw ApiException(response.status_code()
				, utility::conversions::to_string_t("error calling postConvertDocumentInRequestToXps: ") + response.reason_phrase()
				, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
		}

		// check response content type
		if (response.headers().has(utility::conversions::to_string_t("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
					, utility::conversions::to_string_t("error calling postConvertDocumentInRequestToXps: unexpected response type: ") + contentType
					, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
			}
		}

		return response.extract_vector();
	})
		.then([=](std::vector<unsigned char> response)
	{
		HttpContent result;
		std::shared_ptr<std::stringstream> stream = std::make_shared<std::stringstream>(std::string(response.begin(), response.end()));
		result.setData(stream);
		return result;
	});
}
pplx::task<HttpContent>
ConversionApi::putConvertDocumentToImage(
    utility::string_t name,
    utility::string_t outPath,
    utility::string_t outFormat,
    boost::optional<int32_t> width,
    boost::optional<int32_t> height,
    boost::optional<int32_t> leftMargin,
    boost::optional<int32_t> rightMargin,
    boost::optional<int32_t> topMargin,
    boost::optional<int32_t> bottomMargin,
    boost::optional<int32_t> resolution,
    boost::optional<utility::string_t> folder,
    boost::optional<utility::string_t> storage
)
{
	std::shared_ptr<ApiConfiguration> apiConfiguration(m_ApiClient->getConfiguration());
	utility::string_t path = utility::conversions::to_string_t("/html/{name}/convert/image/{outFormat}");
	boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("name") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(name));
	boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("outFormat") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(outFormat));

	std::map<utility::string_t, utility::string_t> queryParams;
	std::map<utility::string_t, utility::string_t> headerParams(apiConfiguration->getDefaultHeaders());
	std::map<utility::string_t, utility::string_t> formParams;
	std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;

	std::unordered_set<utility::string_t> responseHttpContentTypes;
	responseHttpContentTypes.insert(utility::conversions::to_string_t("application/json"));

	utility::string_t responseHttpContentType;

	// use JSON if possible
	if (responseHttpContentTypes.size() == 0)
	{
		responseHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// JSON
	else if (responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end())
	{
		responseHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// multipart formdata
	else if (responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end())
	{
		responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
	}
	else
	{
		//It's going to be binary, so just use the first one.
		responseHttpContentType = *responseHttpContentTypes.begin();
	}

	headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;

	std::unordered_set<utility::string_t> consumeHttpContentTypes;
	consumeHttpContentTypes.insert(utility::conversions::to_string_t("application/json"));

	{
		queryParams[utility::conversions::to_string_t("outPath")]
            = ApiClient::parameterToString(outPath);
	}
	if (width)
	{
		queryParams[utility::conversions::to_string_t("width")]
            = ApiClient::parameterToString(*width);
	}
	if (height)
	{
		queryParams[utility::conversions::to_string_t("height")]
            = ApiClient::parameterToString(*height);
	}
	if (leftMargin)
	{
		queryParams[utility::conversions::to_string_t("leftMargin")]
            = ApiClient::parameterToString(*leftMargin);
	}
	if (rightMargin)
	{
		queryParams[utility::conversions::to_string_t("rightMargin")]
            = ApiClient::parameterToString(*rightMargin);
	}
	if (topMargin)
	{
		queryParams[utility::conversions::to_string_t("topMargin")]
            = ApiClient::parameterToString(*topMargin);
	}
	if (bottomMargin)
	{
		queryParams[utility::conversions::to_string_t("bottomMargin")]
            = ApiClient::parameterToString(*bottomMargin);
	}
	if (resolution)
	{
		queryParams[utility::conversions::to_string_t("resolution")]
            = ApiClient::parameterToString(*resolution);
	}
	if (folder)
	{
		queryParams[utility::conversions::to_string_t("folder")]
            = ApiClient::parameterToString(*folder);
	}
	if (storage)
	{
		queryParams[utility::conversions::to_string_t("storage")]
            = ApiClient::parameterToString(*storage);
	}

	std::shared_ptr<IHttpBody> httpBody;
	utility::string_t requestHttpContentType;

	// use JSON if possible
	if (consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end())
	{
		requestHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// multipart formdata
	else if (consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end())
	{
		requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
	}
	else
	{
		throw ApiException(415, utility::conversions::to_string_t("ConversionApi->putConvertDocumentToImage does not consume any supported media type"));
	}

	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
		// 2xx - successful    : OK
		// 3xx - redirection   : OK
		// 4xx - client error  : not OK
		// 5xx - client error  : not OK
		if (response.status_code() >= 400)
		{
			throw ApiException(response.status_code()
				, utility::conversions::to_string_t("error calling putConvertDocumentToImage: ") + response.reason_phrase()
				, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
		}

		// check response content type
		if (response.headers().has(utility::conversions::to_string_t("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
					, utility::conversions::to_string_t("error calling putConvertDocumentToImage: unexpected response type: ") + contentType
					, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
			}
		}

		return response.extract_vector();
	})
		.then([=](std::vector<unsigned char> response)
	{
		HttpContent result;
		std::shared_ptr<std::stringstream> stream = std::make_shared<std::stringstream>(std::string(response.begin(), response.end()));
		result.setData(stream);
		return result;
	});
}
pplx::task<HttpContent>
ConversionApi::putConvertDocumentToPdf(
    utility::string_t name,
    utility::string_t outPath,
    boost::optional<int32_t> width,
    boost::optional<int32_t> height,
    boost::optional<int32_t> leftMargin,
    boost::optional<int32_t> rightMargin,
    boost::optional<int32_t> topMargin,
    boost::optional<int32_t> bottomMargin,
    boost::optional<utility::string_t> folder,
    boost::optional<utility::string_t> storage
)
{
	std::shared_ptr<ApiConfiguration> apiConfiguration(m_ApiClient->getConfiguration());
	utility::string_t path = utility::conversions::to_string_t("/html/{name}/convert/pdf");
	boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("name") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(name));

	std::map<utility::string_t, utility::string_t> queryParams;
	std::map<utility::string_t, utility::string_t> headerParams(apiConfiguration->getDefaultHeaders());
	std::map<utility::string_t, utility::string_t> formParams;
	std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;

	std::unordered_set<utility::string_t> responseHttpContentTypes;
	responseHttpContentTypes.insert(utility::conversions::to_string_t("application/json"));

	utility::string_t responseHttpContentType;

	// use JSON if possible
	if (responseHttpContentTypes.size() == 0)
	{
		responseHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// JSON
	else if (responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end())
	{
		responseHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// multipart formdata
	else if (responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end())
	{
		responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
	}
	else
	{
		//It's going to be binary, so just use the first one.
		responseHttpContentType = *responseHttpContentTypes.begin();
	}

	headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;

	std::unordered_set<utility::string_t> consumeHttpContentTypes;
	consumeHttpContentTypes.insert(utility::conversions::to_string_t("application/json"));

    queryParams[utility::conversions::to_string_t("outPath")]
        = ApiClient::parameterToString(outPath);

    if (width)
	{
		queryParams[utility::conversions::to_string_t("width")]
            = ApiClient::parameterToString(*width);
	}
	if (height)
	{
		queryParams[utility::conversions::to_string_t("height")]
            = ApiClient::parameterToString(*height);
	}
	if (leftMargin)
	{
		queryParams[utility::conversions::to_string_t("leftMargin")]
            = ApiClient::parameterToString(*leftMargin);
	}
	if (rightMargin)
	{
		queryParams[utility::conversions::to_string_t("rightMargin")]
            = ApiClient::parameterToString(*rightMargin);
	}
	if (topMargin)
	{
		queryParams[utility::conversions::to_string_t("topMargin")]
            = ApiClient::parameterToString(*topMargin);
	}
	if (bottomMargin)
	{
		queryParams[utility::conversions::to_string_t("bottomMargin")]
            = ApiClient::parameterToString(*bottomMargin);
	}
	if (folder)
	{
		queryParams[utility::conversions::to_string_t("folder")]
            = ApiClient::parameterToString(*folder);
	}
	if (storage)
	{
		queryParams[utility::conversions::to_string_t("storage")]
            = ApiClient::parameterToString(*storage);
	}

	std::shared_ptr<IHttpBody> httpBody;
	utility::string_t requestHttpContentType;

	// use JSON if possible
	if (consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end())
	{
		requestHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// multipart formdata
	else if (consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end())
	{
		requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
	}
	else
	{
		throw ApiException(415, utility::conversions::to_string_t("ConversionApi->putConvertDocumentToPdf does not consume any supported media type"));
	}

	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
		// 2xx - successful    : OK
		// 3xx - redirection   : OK
		// 4xx - client error  : not OK
		// 5xx - client error  : not OK
		if (response.status_code() >= 400)
		{
			throw ApiException(response.status_code()
				, utility::conversions::to_string_t("error calling putConvertDocumentToPdf: ") + response.reason_phrase()
				, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
		}

		// check response content type
		if (response.headers().has(utility::conversions::to_string_t("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
					, utility::conversions::to_string_t("error calling putConvertDocumentToPdf: unexpected response type: ") + contentType
					, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
			}
		}

		return response.extract_vector();
	})
		.then([=](std::vector<unsigned char> response)
	{
		HttpContent result;
		std::shared_ptr<std::stringstream> stream = std::make_shared<std::stringstream>(std::string(response.begin(), response.end()));
		result.setData(stream);
		return result;
	});
}
pplx::task<HttpContent>
ConversionApi::putConvertDocumentToXps(
    utility::string_t name,
    utility::string_t outPath,
    boost::optional<int32_t> width,
    boost::optional<int32_t> height,
    boost::optional<int32_t> leftMargin,
    boost::optional<int32_t> rightMargin,
    boost::optional<int32_t> topMargin,
    boost::optional<int32_t> bottomMargin,
    boost::optional<utility::string_t> folder,
    boost::optional<utility::string_t> storage
)
{

	std::shared_ptr<ApiConfiguration> apiConfiguration(m_ApiClient->getConfiguration());
	utility::string_t path = utility::conversions::to_string_t("/html/{name}/convert/xps");
	boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("name") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(name));

	std::map<utility::string_t, utility::string_t> queryParams;
	std::map<utility::string_t, utility::string_t> headerParams(apiConfiguration->getDefaultHeaders());
	std::map<utility::string_t, utility::string_t> formParams;
	std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;

	std::unordered_set<utility::string_t> responseHttpContentTypes;
	responseHttpContentTypes.insert(utility::conversions::to_string_t("application/json"));

	utility::string_t responseHttpContentType;

	// use JSON if possible
	if (responseHttpContentTypes.size() == 0)
	{
		responseHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// JSON
	else if (responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end())
	{
		responseHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// multipart formdata
	else if (responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end())
	{
		responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
	}
	else
	{
		//It's going to be binary, so just use the first one.
		responseHttpContentType = *responseHttpContentTypes.begin();
	}

	headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;
	std::unordered_set<utility::string_t> consumeHttpContentTypes;
	consumeHttpContentTypes.insert(utility::conversions::to_string_t("application/json"));

	queryParams[utility::conversions::to_string_t("outPath")]
        = ApiClient::parameterToString(outPath);

	if (width)
	{
		queryParams[utility::conversions::to_string_t("width")]
            = ApiClient::parameterToString(*width);
	}
	if (height)
	{
		queryParams[utility::conversions::to_string_t("height")]
            = ApiClient::parameterToString(*height);
	}
	if (leftMargin)
	{
		queryParams[utility::conversions::to_string_t("leftMargin")]
            = ApiClient::parameterToString(*leftMargin);
	}
	if (rightMargin)
	{
		queryParams[utility::conversions::to_string_t("rightMargin")]
            = ApiClient::parameterToString(*rightMargin);
	}
	if (topMargin)
	{
		queryParams[utility::conversions::to_string_t("topMargin")]
            = ApiClient::parameterToString(*topMargin);
	}
	if (bottomMargin)
	{
		queryParams[utility::conversions::to_string_t("bottomMargin")]
            = ApiClient::parameterToString(*bottomMargin);
	}
	if (folder)
	{
		queryParams[utility::conversions::to_string_t("folder")]
            = ApiClient::parameterToString(*folder);
	}
	if (storage)
	{
		queryParams[utility::conversions::to_string_t("storage")]
            = ApiClient::parameterToString(*storage);
	}

	std::shared_ptr<IHttpBody> httpBody;
	utility::string_t requestHttpContentType;

	// use JSON if possible
	if (consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end())
	{
		requestHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// multipart formdata
	else if (consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end())
	{
		requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
	}
	else
	{
		throw ApiException(415, utility::conversions::to_string_t("ConversionApi->putConvertDocumentToXps does not consume any supported media type"));
	}
	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
		// 2xx - successful    : OK
		// 3xx - redirection   : OK
		// 4xx - client error  : not OK
		// 5xx - client error  : not OK
		if (response.status_code() >= 400)
		{
			throw ApiException(response.status_code()
				, utility::conversions::to_string_t("error calling putConvertDocumentToXps: ") + response.reason_phrase()
				, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
		}

		// check response content type
		if (response.headers().has(utility::conversions::to_string_t("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
					, utility::conversions::to_string_t("error calling putConvertDocumentToXps: unexpected response type: ") + contentType
					, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
			}
		}
		return response.extract_vector();
	})
		.then([=](std::vector<unsigned char> response)
	{
		HttpContent result;
		std::shared_ptr<std::stringstream> stream = std::make_shared<std::stringstream>(std::string(response.begin(), response.end()));
		result.setData(stream);
		return result;
	});

}

pplx::task<HttpContent>
ConversionApi::getConvertDocumentToMHTMLByUrl(utility::string_t sourceUrl)
{
	std::shared_ptr<ApiConfiguration> apiConfiguration(m_ApiClient->getConfiguration());
	utility::string_t path = utility::conversions::to_string_t("/html/convert/mhtml");

	std::map<utility::string_t, utility::string_t> queryParams;
	std::map<utility::string_t, utility::string_t> headerParams(apiConfiguration->getDefaultHeaders());
	std::map<utility::string_t, utility::string_t> formParams;
	std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;

	std::unordered_set<utility::string_t> responseHttpContentTypes;
	responseHttpContentTypes.insert(utility::conversions::to_string_t("multipart/form-data"));

	utility::string_t responseHttpContentType;

	// use JSON if possible
	if (responseHttpContentTypes.size() == 0)
	{
		responseHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// JSON
	else if (responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end())
	{
		responseHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// multipart formdata
	else if (responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end())
	{
		responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
	}
	else
	{
		//It's going to be binary, so just use the first one.
		responseHttpContentType = *responseHttpContentTypes.begin();
	}

	headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;

	std::unordered_set<utility::string_t> consumeHttpContentTypes;
	consumeHttpContentTypes.insert(utility::conversions::to_string_t("application/json"));

	{
		queryParams[utility::conversions::to_string_t("sourceUrl")] = ApiClient::parameterToString(sourceUrl);
	}

	std::shared_ptr<IHttpBody> httpBody;
	utility::string_t requestHttpContentType;

	// use JSON if possible
	if (consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end())
	{
		requestHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// multipart formdata
	else if (consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end())
	{
		requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
	}
	else
	{
		throw ApiException(415, utility::conversions::to_string_t("ConversionApi->getConvertDocumentToMHTMLByUrl does not consume any supported media type"));
	}

	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
		// 2xx - successful    : OK
		// 3xx - redirection   : OK
		// 4xx - client error  : not OK
		// 5xx - client error  : not OK
		if (response.status_code() >= 400)
		{
			throw ApiException(response.status_code()
				, utility::conversions::to_string_t("error calling getConvertDocumentToMHTMLByUrl: ") + response.reason_phrase()
				, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
		}

		return response.extract_vector();
	})
		.then([=](std::vector<unsigned char> response)
	{
		HttpContent result;
		std::shared_ptr<std::stringstream> stream = std::make_shared<std::stringstream>(std::string(response.begin(), response.end()));
		result.setData(stream);
		return result;
	});
}

pplx::task<HttpContent> ConversionApi::getConvertDocumentToMarkdown(
	utility::string_t name,
	boost::optional<bool> useGit,
	boost::optional<utility::string_t> folder,
	boost::optional<utility::string_t> storage
)
{
	std::shared_ptr<ApiConfiguration> apiConfiguration(m_ApiClient->getConfiguration());
	utility::string_t path = utility::conversions::to_string_t("/html/{name}/convert/md");
	boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("name") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(name));

	std::map<utility::string_t, utility::string_t> queryParams;
	std::map<utility::string_t, utility::string_t> headerParams(apiConfiguration->getDefaultHeaders());
	std::map<utility::string_t, utility::string_t> formParams;
	std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;

	std::unordered_set<utility::string_t> responseHttpContentTypes;
	responseHttpContentTypes.insert(utility::conversions::to_string_t("application/json"));

	utility::string_t responseHttpContentType;

	// use JSON if possible
	if (responseHttpContentTypes.size() == 0)
	{
		responseHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// JSON
	else if (responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end())
	{
		responseHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// multipart formdata
	else if (responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end())
	{
		responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
	}
	else
	{
		//It's going to be binary, so just use the first one.
		responseHttpContentType = *responseHttpContentTypes.begin();
	}

	headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;
	std::unordered_set<utility::string_t> consumeHttpContentTypes;
	consumeHttpContentTypes.insert(utility::conversions::to_string_t("application/json"));

	if (useGit == true)
	{
		queryParams[utility::conversions::to_string_t("useGit")]
            = utility::conversions::to_string_t("true");
	}
	if (folder)
	{
		queryParams[utility::conversions::to_string_t("folder")]
            = ApiClient::parameterToString(*folder);
	}
	if (storage)
	{
		queryParams[utility::conversions::to_string_t("storage")]
            = ApiClient::parameterToString(*storage);
	}

	std::shared_ptr<IHttpBody> httpBody;
	utility::string_t requestHttpContentType;

	// use JSON if possible
	if (consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end())
	{
		requestHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// multipart formdata
	else if (consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end())
	{
		requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
	}
	else
	{
		throw ApiException(415, utility::conversions::to_string_t("ConversionApi->GetConvertDocumentToMarkdown does not consume any supported media type"));
	}
	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
		// 2xx - successful    : OK
		// 3xx - redirection   : OK
		// 4xx - client error  : not OK
		// 5xx - client error  : not OK
		if (response.status_code() >= 400)
		{
			throw ApiException(response.status_code()
				, utility::conversions::to_string_t("error calling GetConvertDocumentToMarkdown: ") + response.reason_phrase()
				, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
		}

		return response.extract_vector();
	})
		.then([=](std::vector<unsigned char> response)
	{
		HttpContent result;
		std::shared_ptr<std::stringstream> stream = std::make_shared<std::stringstream>(std::string(response.begin(), response.end()));
		result.setData(stream);
		return result;
	});
}

pplx::task<HttpContent>
ConversionApi::putConvertDocumentToMarkdown(
    utility::string_t name,
    utility::string_t outPath,
    boost::optional<bool> useGit,
    boost::optional<utility::string_t> folder,
    boost::optional<utility::string_t> storage
)
{
	std::shared_ptr<ApiConfiguration> apiConfiguration(m_ApiClient->getConfiguration());
	utility::string_t path = utility::conversions::to_string_t("/html/{name}/convert/md");
	boost::replace_all(path, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("name") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(name));

	std::map<utility::string_t, utility::string_t> queryParams;
	std::map<utility::string_t, utility::string_t> headerParams(apiConfiguration->getDefaultHeaders());
	std::map<utility::string_t, utility::string_t> formParams;
	std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;

	std::unordered_set<utility::string_t> responseHttpContentTypes;
	responseHttpContentTypes.insert(utility::conversions::to_string_t("application/json"));

	utility::string_t responseHttpContentType;

	// use JSON if possible
	if (responseHttpContentTypes.size() == 0)
	{
		responseHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// JSON
	else if (responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end())
	{
		responseHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// multipart formdata
	else if (responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end())
	{
		responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
	}
	else
	{
		//It's going to be binary, so just use the first one.
		responseHttpContentType = *responseHttpContentTypes.begin();
	}

	headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;

	std::unordered_set<utility::string_t> consumeHttpContentTypes;
	consumeHttpContentTypes.insert(utility::conversions::to_string_t("application/json"));

	queryParams[utility::conversions::to_string_t("outPath")]
        = ApiClient::parameterToString(outPath);

	if (useGit == true)
	{
		queryParams[utility::conversions::to_string_t("useGit")]
            = utility::conversions::to_string_t("true");
	}
	if (folder)
	{
		queryParams[utility::conversions::to_string_t("folder")]
            = ApiClient::parameterToString(*folder);
	}
	if (storage)
	{
		queryParams[utility::conversions::to_string_t("storage")]
            = ApiClient::parameterToString(*storage);
	}

	std::shared_ptr<IHttpBody> httpBody;
	utility::string_t requestHttpContentType;

	// use JSON if possible
	if (consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end())
	{
		requestHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// multipart formdata
	else if (consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end())
	{
		requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
	}
	else
	{
		throw ApiException(415, utility::conversions::to_string_t("ConversionApi->PutConvertDocumentToMarkdown does not consume any supported media type"));
	}
	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
		// 2xx - successful    : OK
		// 3xx - redirection   : OK
		// 4xx - client error  : not OK
		// 5xx - client error  : not OK
		if (response.status_code() >= 400)
		{
			throw ApiException(response.status_code()
				, utility::conversions::to_string_t("error calling PutConvertDocumentToMarkdown: ") + response.reason_phrase()
				, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
		}
		return response.extract_vector();
	})
		.then([=](std::vector<unsigned char> response)
	{
		HttpContent result;
		std::shared_ptr<std::stringstream> stream = std::make_shared<std::stringstream>(std::string(response.begin(), response.end()));
		result.setData(stream);
		return result;
	});
}

pplx::task<HttpContent>
ConversionApi::postConvertDocumentInRequestToMarkdown(
    utility::string_t outPath,
    std::shared_ptr<HttpContent> file,
    boost::optional<bool> useGit,
    boost::optional<utility::string_t> storage
)
{
	// verify the required parameter 'file' is set
	if (file == nullptr)
	{
		throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'file' when calling ConversionApi->postConvertDocumentInRequestToMarkdown"));
	}

	std::shared_ptr<ApiConfiguration> apiConfiguration(m_ApiClient->getConfiguration());
	utility::string_t path = utility::conversions::to_string_t("/html/convert/md");

	std::map<utility::string_t, utility::string_t> queryParams;
	std::map<utility::string_t, utility::string_t> headerParams(apiConfiguration->getDefaultHeaders());
	std::map<utility::string_t, utility::string_t> formParams;
	std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;

	std::unordered_set<utility::string_t> responseHttpContentTypes;
	responseHttpContentTypes.insert(utility::conversions::to_string_t("application/json"));

	utility::string_t responseHttpContentType;

	// use JSON if possible
	if (responseHttpContentTypes.size() == 0)
	{
		responseHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// JSON
	else if (responseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != responseHttpContentTypes.end())
	{
		responseHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// multipart formdata
	else if (responseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != responseHttpContentTypes.end())
	{
		responseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
	}
	else
	{
		//It's going to be binary, so just use the first one.
		responseHttpContentType = *responseHttpContentTypes.begin();
	}

	headerParams[utility::conversions::to_string_t("Accept")] = responseHttpContentType;

	std::unordered_set<utility::string_t> consumeHttpContentTypes;
	consumeHttpContentTypes.insert(utility::conversions::to_string_t("multipart/form-data"));

	queryParams[utility::conversions::to_string_t("outPath")] = ApiClient::parameterToString(outPath);
	fileParams[utility::conversions::to_string_t("file")] = file;

    if (useGit == true)
	{
		queryParams[utility::conversions::to_string_t("useGit")] = utility::conversions::to_string_t("true");
	}
    if (storage)
    {
        queryParams[utility::conversions::to_string_t("storage")]
            = ApiClient::parameterToString(*storage);
    }

    std::shared_ptr<IHttpBody> httpBody;
    utility::string_t requestHttpContentType;

	// use JSON if possible
	if (consumeHttpContentTypes.size() == 0 || consumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != consumeHttpContentTypes.end())
	{
		requestHttpContentType = utility::conversions::to_string_t("application/json");
	}
	// multipart formdata
	else if (consumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != consumeHttpContentTypes.end())
	{
		requestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
	}
	else
	{
		throw ApiException(415, utility::conversions::to_string_t("ConversionApi->PostConvertDocumentInRequestToMarkdown does not consume any supported media type"));
	}
	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
		// 2xx - successful    : OK
		// 3xx - redirection   : OK
		// 4xx - client error  : not OK
		// 5xx - client error  : not OK
		if (response.status_code() >= 400)
		{
			throw ApiException(response.status_code()
				, utility::conversions::to_string_t("error calling postConvertDocumentInRequestToMarkdown: ") + response.reason_phrase()
				, std::make_shared<std::stringstream>(response.extract_utf8string(true).get()));
		}
		return response.extract_vector();
	})
		.then([=](std::vector<unsigned char> response)
	{
		HttpContent result;
		std::shared_ptr<std::stringstream> stream = std::make_shared<std::stringstream>(std::string(response.begin(), response.end()));
		result.setData(stream);
		return result;
	});
}

}
}
}

max_stars_repo_name: aspose-html-cloud/aspose-html-cloud-cpp

max_issues_repo_name: aspose-html-cloud/aspose-html-cloud-cpp

max_forks_repo_name: aspose-html-cloud/aspose-html-cloud-cpp


text:
/////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga  2007.
//
// Distributed under the Boost Software License, Version 1.0.
//    (See accompanying file LICENSE_1_0.txt or copy at
//          http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/intrusive for documentation.
//
/////////////////////////////////////////////////////////////////////////////

#ifndef BOOST_INTRUSIVE_TREE_NODE_HPP
#define BOOST_INTRUSIVE_TREE_NODE_HPP

#include <boost/intrusive/detail/config_begin.hpp>
#include <iterator>
#include <boost/intrusive/detail/pointer_to_other.hpp>
#include <boost/intrusive/detail/mpl.hpp>

namespace boost {
namespace intrusive {

template<class VoidPointer>
struct tree_node
{
   typedef typename pointer_to_other
      <VoidPointer
      ,tree_node<VoidPointer> >::type   node_ptr;

   node_ptr parent_, left_, right_;
};

template<class VoidPointer>
struct tree_node_traits
{
   typedef tree_node<VoidPointer> node;

   typedef typename boost::pointer_to_other
      <VoidPointer, node>::type              node_ptr;
   typedef typename boost::pointer_to_other
      <VoidPointer, const node>::type        const_node_ptr;

   static node_ptr get_parent(const_node_ptr n)
   {  return n->parent_;  }

   static void set_parent(node_ptr n, node_ptr p)
   {  n->parent_ = p;  }

   static node_ptr get_left(const_node_ptr n)
   {  return n->left_;  }

   static void set_left(node_ptr n, node_ptr l)
   {  n->left_ = l;  }

   static node_ptr get_right(const_node_ptr n)
   {  return n->right_;  }

   static void set_right(node_ptr n, node_ptr r)
   {  n->right_ = r;  }
};

/////////////////////////////////////////////////////////////////////////////
//                                                                         //
//                   Implementation of the tree iterator                   //
//                                                                         //
/////////////////////////////////////////////////////////////////////////////

// tree_iterator provides some basic functions for a
// node oriented bidirectional iterator:
template<class Container, bool IsConst>
class tree_iterator
   :  public std::iterator
         < std::bidirectional_iterator_tag
         , typename Container::value_type
         , typename Container::difference_type
         , typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type
         , typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type
         >
{
   protected:
   typedef typename Container::real_value_traits   real_value_traits;
   typedef typename Container::node_algorithms     node_algorithms;
   typedef typename real_value_traits::node_traits node_traits;
   typedef typename node_traits::node              node;
   typedef typename node_traits::node_ptr          node_ptr;
   typedef typename boost::pointer_to_other
      <node_ptr, void>::type                       void_pointer;
   static const bool store_container_ptr =
      detail::store_cont_ptr_on_it<Container>::value;

   public:
   typedef typename Container::value_type    value_type;
   typedef typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type pointer;
   typedef typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type reference;

   tree_iterator()
      : members_ (0, 0)
   {}

   explicit tree_iterator(node_ptr nodeptr, const Container *cont_ptr)
      : members_ (nodeptr, cont_ptr)
   {}

   tree_iterator(tree_iterator<Container, false> const& other)
      :  members_(other.pointed_node(), other.get_container())
   {}

   const node_ptr &pointed_node() const
   { return members_.nodeptr_; }

   tree_iterator &operator=(const node_ptr &nodeptr)
   {  members_.nodeptr_ = nodeptr;  return static_cast<tree_iterator&>(*this);  }

   public:
   tree_iterator& operator++()
   {
      members_.nodeptr_ = node_algorithms::next_node(members_.nodeptr_);
      return static_cast<tree_iterator&> (*this);
   }

   tree_iterator operator++(int)
   {
      tree_iterator result (*this);
      members_.nodeptr_ = node_algorithms::next_node(members_.nodeptr_);
      return result;
   }

   tree_iterator& operator--()
   {
      members_.nodeptr_ = node_algorithms::prev_node(members_.nodeptr_);
      return static_cast<tree_iterator&> (*this);
   }

   tree_iterator operator--(int)
   {
      tree_iterator result (*this);
      members_.nodeptr_ = node_algorithms::prev_node(members_.nodeptr_);
      return result;
   }

   friend bool operator== (const tree_iterator& l, const tree_iterator& r)
   { return l.pointed_node() == r.pointed_node(); }

   friend bool operator!= (const tree_iterator& l, const tree_iterator& r)
   {  return !(l == r);   }

   reference operator*() const
   {  return *operator->();   }

   pointer operator->() const
   { return detail::boost_intrusive_get_pointer(this->get_real_value_traits()->to_value_ptr(members_.nodeptr_)); }

   const Container *get_container() const
   {  return static_cast<const Container*>(members_.get_ptr());   }

   const real_value_traits *get_real_value_traits() const
   {  return &this->get_container()->get_real_value_traits();  }

   tree_iterator end_iterator_from_it() const
   {
      return tree_iterator(node_algorithms::get_header(this->pointed_node()), this->get_container());
   }

   tree_iterator<Container, false> unconst() const
   {  return tree_iterator<Container, false>(this->pointed_node(), this->get_container());   }

   private:
   struct members
      :  public detail::select_constptr
         <void_pointer, store_container_ptr>::type
   {
      typedef typename detail::select_constptr
         <void_pointer, store_container_ptr>::type Base;

      members(const node_ptr &n_ptr, const void *cont)
         :  Base(cont), nodeptr_(n_ptr)
      {}

      node_ptr nodeptr_;
   } members_;
};

} //namespace intrusive
} //namespace boost

#include <boost/intrusive/detail/config_end.hpp>

#endif //BOOST_INTRUSIVE_TREE_NODE_HPP

ext: hpp

max_stars_repo_name: smartmobili/MonkVG

max_issues_repo_name: jonstewart/boost-svn

max_forks_repo_name: jonstewart/boost-svn


text:
//==================================================================================================
/*!
  @file

  @copyright 2016 NumScale SAS

  Distributed under the Boost Software License, Version 1.0.
  (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
//==================================================================================================
#ifndef BOOST_SIMD_ARCH_X86_AVX2_SIMD_FUNCTION_SPLAT_HPP_INCLUDED
#define BOOST_SIMD_ARCH_X86_AVX2_SIMD_FUNCTION_SPLAT_HPP_INCLUDED

#include <boost/simd/meta/hierarchy/simd.hpp>
#include <boost/dispatch/function/overload.hpp>
#include <boost/config.hpp>

namespace boost { namespace simd { namespace ext
{
  namespace bd = ::boost::dispatch;
  namespace bs = ::boost::simd;

  //------------------------------------------------------------------------------------------------
  // splat from a scalar into a pack of 8 bits integers
  BOOST_DISPATCH_OVERLOAD ( splat_
                          , (typename Target, typename Value)
                          , bs::avx2_
                          , bd::scalar_< bd::unspecified_<Value> >
                          , bd::target_<bs::pack_<bd::ints8_<Target>,bs::avx_>>
                          )
  {
    using target = typename Target::type;

    BOOST_FORCEINLINE target operator()(Value const& v, Target const&) const BOOST_NOEXCEPT
    {
      return _mm256_set1_epi8(v);
    }
  };

  //------------------------------------------------------------------------------------------------
  // splat from a scalar into a pack of 16 bits integers
  BOOST_DISPATCH_OVERLOAD ( splat_
                          , (typename Target, typename Value)
                          , bs::avx2_
                          , bd::scalar_< bd::unspecified_<Value> >
                          , bd::target_<bs::pack_<bd::ints16_<Target>,bs::avx_>>
                          )
  {
    using target = typename Target::type;

    BOOST_FORCEINLINE target operator()(Value const& v, Target const&) const BOOST_NOEXCEPT
    {
      return _mm256_set1_epi16(v);
    }
  };

  //------------------------------------------------------------------------------------------------
  // splat from a scalar into a pack of 32 bits integers
  BOOST_DISPATCH_OVERLOAD ( splat_
                          , (typename Target, typename Value)
                          , bs::avx2_
                          , bd::scalar_< bd::unspecified_<Value> >
                          , bd::target_<bs::pack_<bd::ints32_<Target>,bs::avx_>>
                          )
  {
    using target = typename Target::type;

    BOOST_FORCEINLINE target operator()(Value const& v, Target const&) const BOOST_NOEXCEPT
    {
      return _mm256_set1_epi32(v);
    }
  };

  //------------------------------------------------------------------------------------------------
  // splat from a scalar into a pack of 64 bits integers
  BOOST_DISPATCH_OVERLOAD ( splat_
                          , (typename Target, typename Value)
                          , bs::avx2_
                          , bd::scalar_< bd::unspecified_<Value> >
                          , bd::target_<bs::pack_<bd::ints64_<Target>,bs::avx_>>
                          )
  {
    using target = typename Target::type;

    BOOST_FORCEINLINE target operator()(Value const& v, Target const&) const BOOST_NOEXCEPT
    {
      return _mm256_set1_epi64x(v);
    }
  };
} } }

#endif


text: #include <boost/random/uniform_on_sphere.hpp>

max_stars_repo_name: miathedev/BoostForArduino

max_issues_repo_name: miathedev/BoostForArduino

max_forks_repo_name: miathedev/BoostForArduino