text: /**
   * FastReport Cloud
   * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
   *
   * The version of the OpenAPI document: v1
   *
   * NOTE: This class is auto generated by OpenAPI-Generator 5.1.1.
   * https://openapi-generator.tech
   * Do not edit the class manually.
   */
  
  
  #include "SubscriptionPlansApi.h"
  #include "IHttpBody.h"
  #include "JsonBody.h"
  #include "MultipartFormData.h"
  
  #include <unordered_set>
  
  #include <boost/algorithm/string/replace.hpp>
  
  namespace fastreport {
  namespace cloud {
  namespace client {
  
  using namespace fastreport::cloud::models;
  
  SubscriptionPlansApi::SubscriptionPlansApi( std::shared_ptr<const ApiClient> apiClient )
      : m_ApiClient(apiClient)
  {
  }
  
  SubscriptionPlansApi::~SubscriptionPlansApi()
  {
  }
  
  pplx::task<std::shared_ptr<SubscriptionPlanVM>> SubscriptionPlansApi::subscriptionPlansGetSubscriptionPlan(utility::string_t id) const
  {
  
  
      std::shared_ptr<const ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() );
      utility::string_t localVarPath = utility::conversions::to_string_t("/api/manage/v1/SubscriptionPlans/{id}");
      boost::replace_all(localVarPath, utility::conversions::to_string_t("{") + utility::conversions::to_string_t("id") + utility::conversions::to_string_t("}"), ApiClient::parameterToString(id));
  
      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("SubscriptionPlansApi->subscriptionPlansGetSubscriptionPlan does not produce any supported media type"));
      }
  
      localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType;
  
      std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes;
  
  
      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 if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
      {
          localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
      }
      else
      {
          throw ApiException(415, utility::conversions::to_string_t("SubscriptionPlansApi->subscriptionPlansGetSubscriptionPlan does not consume any supported media type"));
      }
  
      // authentication (ApiKey) required
      // Basic authentication is added automatically as part of the http_client_config
      // authentication (JWT) required
      // Basic authentication is added automatically as part of the http_client_config
  
      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 subscriptionPlansGetSubscriptionPlan: ") + 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 subscriptionPlansGetSubscriptionPlan: 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<SubscriptionPlanVM> localVarResult(new SubscriptionPlanVM());
  
          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 subscriptionPlansGetSubscriptionPlan: unsupported response type"));
          }
  
          return localVarResult;
      });
  }
  pplx::task<std::shared_ptr<SubscriptionPlansVM>> SubscriptionPlansApi::subscriptionPlansGetSubscriptionPlans(boost::optional<int32_t> skip, boost::optional<int32_t> take) const
  {
  
  
      std::shared_ptr<const ApiConfiguration> localVarApiConfiguration( m_ApiClient->getConfiguration() );
      utility::string_t localVarPath = utility::conversions::to_string_t("/api/manage/v1/SubscriptionPlans");
      
      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("SubscriptionPlansApi->subscriptionPlansGetSubscriptionPlans does not produce any supported media type"));
      }
  
      localVarHeaderParams[utility::conversions::to_string_t("Accept")] = localVarResponseHttpContentType;
  
      std::unordered_set<utility::string_t> localVarConsumeHttpContentTypes;
  
      if (skip)
      {
          localVarQueryParams[utility::conversions::to_string_t("skip")] = ApiClient::parameterToString(*skip);
      }
      if (take)
      {
          localVarQueryParams[utility::conversions::to_string_t("take")] = ApiClient::parameterToString(*take);
      }
  
      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 if (localVarConsumeHttpContentTypes.find(utility::conversions::to_string_t("application/x-www-form-urlencoded")) != localVarConsumeHttpContentTypes.end())
      {
          localVarRequestHttpContentType = utility::conversions::to_string_t("application/x-www-form-urlencoded");
      }
      else
      {
          throw ApiException(415, utility::conversions::to_string_t("SubscriptionPlansApi->subscriptionPlansGetSubscriptionPlans does not consume any supported media type"));
      }
  
      // authentication (ApiKey) required
      // Basic authentication is added automatically as part of the http_client_config
      // authentication (JWT) required
      // Basic authentication is added automatically as part of the http_client_config
  
      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 subscriptionPlansGetSubscriptionPlans: ") + 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 subscriptionPlansGetSubscriptionPlans: 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<SubscriptionPlansVM> localVarResult(new SubscriptionPlansVM());
  
          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 subscriptionPlansGetSubscriptionPlans: unsupported response type"));
          }
  
          return localVarResult;
      });
  }
  
  }
  }
  }
  
  