text: /**
   * MailSlurp API
   * MailSlurp is an API for sending and receiving emails from dynamically allocated email addresses. It's designed for developers and QA teams to test applications, process inbound emails, send templated notifications, attachments, and more.  ## Resources  - [Homepage](https://www.mailslurp.com) - Get an [API KEY](https://app.mailslurp.com/sign-up/) - Generated [SDK Clients](https://www.mailslurp.com/docs/) - [Examples](https://github.com/mailslurp/examples) repository
   *
   * The version of the OpenAPI document: 6.5.2
   *
   * NOTE: This class is auto generated by OpenAPI-Generator 4.3.1.
   * https://openapi-generator.tech
   * Do not edit the class manually.
   */
  
  
  #include "ExportControllerApi.h"
  #include "IHttpBody.h"
  #include "JsonBody.h"
  #include "MultipartFormData.h"
  
  #include <unordered_set>
  
  #include <boost/algorithm/string/replace.hpp>
  
  namespace com {
  namespace mailslurp {
  namespace client {
  namespace api {
  
  using namespace com::mailslurp::client::model;
  
  ExportControllerApi::ExportControllerApi( std::shared_ptr<const ApiClient> apiClient )
      : m_ApiClient(apiClient)
  {
  }
  
  ExportControllerApi::~ExportControllerApi()
  {
  }
  
  pplx::task<utility::string_t> ExportControllerApi::exportEntities(utility::string_t apiKey, utility::string_t exportType, utility::string_t outputFormat, boost::optional<utility::datetime> createdEarliestTime, boost::optional<utility::datetime> createdOldestTime, boost::optional<bool> excludePreviouslyExported, boost::optional<utility::string_t> filter, boost::optional<utility::string_t> listSeparatorToken) const
  {
  
  
      std::shared_ptr<const ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() );
      utility::string_t localVarPath = utility::conversions::to_string_t("/export");
      
      std::map<utility::string_t, utility::string_t> localVarQueryParams;
      std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() );
      std::map<utility::string_t, utility::string_t> localVarFormParams;
      std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams;
  
      std::unordered_set<utility::string_t> localVarResponseHttpContentTypes;
      localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );
  
      utility::string_t localVarResponseHttpContentType;
  
      // use JSON if possible
      if ( localVarResponseHttpContentTypes.size() == 0 )
      {
          localVarResponseHttpContentType = utility::conversions::to_string_t("application/json");
      }
      // JSON
      else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() )
      {
          localVarResponseHttpContentType = utility::conversions::to_string_t("application/json");
      }
      // multipart formdata
      else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() )
      {
          localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
      }
      else
      {
          throw ApiException(400, utility::conversions::to_string_t("ExportControllerApi->exportEntities does not produce any supported media type"));
      }
  
      localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType;
  
      std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes;
  
      {
          localVarQueryParams[utility::conversions::to_string_t("apiKey")] = ApiClient::parameterToString(apiKey);
      }
      {
          localVarQueryParams[utility::conversions::to_string_t("exportType")] = ApiClient::parameterToString(exportType);
      }
      {
          localVarQueryParams[utility::conversions::to_string_t("outputFormat")] = ApiClient::parameterToString(outputFormat);
      }
      if (createdEarliestTime)
      {
          localVarQueryParams[utility::conversions::to_string_t("createdEarliestTime")] = ApiClient::parameterToString(*createdEarliestTime);
      }
      if (createdOldestTime)
      {
          localVarQueryParams[utility::conversions::to_string_t("createdOldestTime")] = ApiClient::parameterToString(*createdOldestTime);
      }
      if (excludePreviouslyExported)
      {
          localVarQueryParams[utility::conversions::to_string_t("excludePreviouslyExported")] = ApiClient::parameterToString(*excludePreviouslyExported);
      }
      if (filter)
      {
          localVarQueryParams[utility::conversions::to_string_t("filter")] = ApiClient::parameterToString(*filter);
      }
      if (listSeparatorToken)
      {
          localVarQueryParams[utility::conversions::to_string_t("listSeparatorToken")] = ApiClient::parameterToString(*listSeparatorToken);
      }
  
      std::shared_ptr<IHttpBody> localVarHttpBody;
      utility::string_t localVarRequestHttpContentType;
  
      // use JSON if possible
      if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() )
      {
          localVarRequestHttpContentType = utility::conversions::to_string_t("application/json");
      }
      // multipart formdata
      else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() )
      {
          localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
      }
      else
      {
          throw ApiException(415, utility::conversions::to_string_t("ExportControllerApi->exportEntities does not consume any supported media type"));
      }
  
      // authentication (API_KEY) required
      {
          utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("x-api-key"));
          if ( localVarApiKey.size() > 0 )
          {
              localVarHeaderParams[utility::conversions::to_string_t("x-api-key")] = localVarApiKey;
          }
      }
  
      return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("GET"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType)
      .then([=](web::http::http_response localVarResponse)
      {
          if (m_ApiClient->getResponseHandler())
          {
              m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers());
          }
  
          // 1xx - informational : OK
          // 2xx - successful       : OK
          // 3xx - redirection   : OK
          // 4xx - client error  : not OK
          // 5xx - client error  : not OK
          if (localVarResponse.status_code() >= 400)
          {
              throw ApiException(localVarResponse.status_code()
                  , utility::conversions::to_string_t("error calling exportEntities: ") + localVarResponse.reason_phrase()
                  , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
          }
  
          // check response content type
          if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type")))
          {
              utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")];
              if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos )
              {
                  throw ApiException(500
                      , utility::conversions::to_string_t("error calling exportEntities: unexpected response type: ") + localVarContentType
                      , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
              }
          }
  
          return localVarResponse.extract_string();
      })
      .then([=](utility::string_t localVarResponse)
      {
          utility::string_t localVarResult(utility::conversions::to_string_t(""));
  
          if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json"))
          {
              web::json::value localVarJson = web::json::value::parse(localVarResponse);
  
              ModelBase::fromJson(localVarJson, localVarResult);
          }
          // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
          // {
          // TODO multipart response parsing
          // }
          else
          {
              throw ApiException(500
                  , utility::conversions::to_string_t("error calling exportEntities: unsupported response type"));
          }
  
          return localVarResult;
      });
  }
  pplx::task<std::shared_ptr<ExportLink>> ExportControllerApi::getExportLink(utility::string_t exportType, std::shared_ptr<ExportOptions> exportOptions, boost::optional<utility::string_t> apiKey) const
  {
  
      // verify the required parameter 'exportOptions' is set
      if (exportOptions == nullptr)
      {
          throw ApiException(400, utility::conversions::to_string_t("Missing required parameter 'exportOptions' when calling ExportControllerApi->getExportLink"));
      }
  
  
      std::shared_ptr<const ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() );
      utility::string_t localVarPath = utility::conversions::to_string_t("/export");
      
      std::map<utility::string_t, utility::string_t> localVarQueryParams;
      std::map<utility::string_t, utility::string_t> localVarHeaderParams( localVarApiConfiguration->getDefaultHeaders() );
      std::map<utility::string_t, utility::string_t> localVarFormParams;
      std::map<utility::string_t, std::shared_ptr<HttpContent>> localVarFileParams;
  
      std::unordered_set<utility::string_t> localVarResponseHttpContentTypes;
      localVarResponseHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );
  
      utility::string_t localVarResponseHttpContentType;
  
      // use JSON if possible
      if ( localVarResponseHttpContentTypes.size() == 0 )
      {
          localVarResponseHttpContentType = utility::conversions::to_string_t("application/json");
      }
      // JSON
      else if ( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarResponseHttpContentTypes.end() )
      {
          localVarResponseHttpContentType = utility::conversions::to_string_t("application/json");
      }
      // multipart formdata
      else if( localVarResponseHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarResponseHttpContentTypes.end() )
      {
          localVarResponseHttpContentType = utility::conversions::to_string_t("multipart/form-data");
      }
      else
      {
          throw ApiException(400, utility::conversions::to_string_t("ExportControllerApi->getExportLink does not produce any supported media type"));
      }
  
      localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType;
  
      std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes;
      localVarConsumeHttpContentTypes.insert( utility::conversions::to_string_t("application/json") );
  
      {
          localVarQueryParams[utility::conversions::to_string_t("exportType")] = ApiClient::parameterToString(exportType);
      }
      if (apiKey)
      {
          localVarQueryParams[utility::conversions::to_string_t("apiKey")] = ApiClient::parameterToString(*apiKey);
      }
  
      std::shared_ptr<IHttpBody> localVarHttpBody;
      utility::string_t localVarRequestHttpContentType;
  
      // use JSON if possible
      if ( localVarConsumeHttpContentTypes.size() == 0 || localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/json")) != localVarConsumeHttpContentTypes.end() )
      {
          localVarRequestHttpContentType = utility::conversions::to_string_t("application/json");
          web::json::value localVarJson;
  
          localVarJson = ModelBase::toJson(exportOptions);
          
  
          localVarHttpBody = std::shared_ptr<IHttpBody>( new JsonBody( localVarJson ) );
      }
      // multipart formdata
      else if( localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("multipart/form-data")) != localVarConsumeHttpContentTypes.end() )
      {
          localVarRequestHttpContentType = utility::conversions::to_string_t("multipart/form-data");
          std::shared_ptr<MultipartFormData> localVarMultipart(new MultipartFormData);
  
          if(exportOptions.get())
          {
              exportOptions->toMultipart(localVarMultipart, utility::conversions::to_string_t("exportOptions"));
          }
          
  
          localVarHttpBody = localVarMultipart;
          localVarRequestHttpContentType += utility::conversions::to_string_t("; boundary=") + localVarMultipart->getBoundary();
      }
      else
      {
          throw ApiException(415, utility::conversions::to_string_t("ExportControllerApi->getExportLink does not consume any supported media type"));
      }
  
      // authentication (API_KEY) required
      {
          utility::string_t localVarApiKey = localVarApiConfiguration->getApiKey(utility::conversions::to_string_t("x-api-key"));
          if ( localVarApiKey.size() > 0 )
          {
              localVarHeaderParams[utility::conversions::to_string_t("x-api-key")] = localVarApiKey;
          }
      }
  
      return m_ApiClient->callApi(localVarPath, utility::conversions::to_string_t("POST"), localVarQueryParams, localVarHttpBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarRequestHttpContentType)
      .then([=](web::http::http_response localVarResponse)
      {
          if (m_ApiClient->getResponseHandler())
          {
              m_ApiClient->getResponseHandler()(localVarResponse.status_code(), localVarResponse.headers());
          }
  
          // 1xx - informational : OK
          // 2xx - successful       : OK
          // 3xx - redirection   : OK
          // 4xx - client error  : not OK
          // 5xx - client error  : not OK
          if (localVarResponse.status_code() >= 400)
          {
              throw ApiException(localVarResponse.status_code()
                  , utility::conversions::to_string_t("error calling getExportLink: ") + localVarResponse.reason_phrase()
                  , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
          }
  
          // check response content type
          if(localVarResponse.headers().has(utility::conversions::to_string_t("Content-Type")))
          {
              utility::string_t localVarContentType = localVarResponse.headers()[utility::conversions::to_string_t("Content-Type")];
              if( localVarContentType.find(localVarResponseHttpContentType) == std::string::npos )
              {
                  throw ApiException(500
                      , utility::conversions::to_string_t("error calling getExportLink: unexpected response type: ") + localVarContentType
                      , std::make_shared<std::stringstream>(localVarResponse.extract_utf8string(true).get()));
              }
          }
  
          return localVarResponse.extract_string();
      })
      .then([=](utility::string_t localVarResponse)
      {
          std::shared_ptr<ExportLink> localVarResult(new ExportLink());
  
          if(localVarResponseHttpContentType == utility::conversions::to_string_t("application/json"))
          {
              web::json::value localVarJson = web::json::value::parse(localVarResponse);
  
              ModelBase::fromJson(localVarJson, localVarResult);
          }
          // else if(localVarResponseHttpContentType == utility::conversions::to_string_t("multipart/form-data"))
          // {
          // TODO multipart response parsing
          // }
          else
          {
              throw ApiException(500
                  , utility::conversions::to_string_t("error calling getExportLink: unsupported response type"));
          }
  
          return localVarResult;
      });
  }
  
  }
  }
  }
  }
  
  