mirror of
https://github.com/tribufu/sdk-cpp
synced 2025-06-16 10:34:18 +00:00
Format c++ files on generation
This commit is contained in:
@ -19,93 +19,87 @@
|
||||
#ifndef TRIBUFU_API_ApiClient_H_
|
||||
#define TRIBUFU_API_ApiClient_H_
|
||||
|
||||
|
||||
#include "tribufu++/ApiConfiguration.h"
|
||||
#include "tribufu++/ApiException.h"
|
||||
#include "tribufu++/IHttpBody.h"
|
||||
#include "tribufu++/HttpContent.h"
|
||||
#include "tribufu++/IHttpBody.h"
|
||||
|
||||
#if defined (_WIN32) || defined (_WIN64)
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#undef U
|
||||
#endif
|
||||
|
||||
#include <cpprest/details/basic_types.h>
|
||||
#include <cpprest/http_client.h>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
namespace tribufu {
|
||||
namespace api {
|
||||
|
||||
using namespace tribufu::models;
|
||||
|
||||
class ApiClient
|
||||
namespace tribufu
|
||||
{
|
||||
public:
|
||||
ApiClient( std::shared_ptr<const ApiConfiguration> configuration = nullptr );
|
||||
virtual ~ApiClient();
|
||||
|
||||
typedef std::function<void(web::http::status_code, const web::http::http_headers&)> ResponseHandlerType;
|
||||
|
||||
const ResponseHandlerType& getResponseHandler() const;
|
||||
void setResponseHandler(const ResponseHandlerType& responseHandler);
|
||||
|
||||
std::shared_ptr<const ApiConfiguration> getConfiguration() const;
|
||||
void setConfiguration(std::shared_ptr<const ApiConfiguration> configuration);
|
||||
|
||||
static utility::string_t parameterToString(utility::string_t value);
|
||||
static utility::string_t parameterToString(int32_t value);
|
||||
static utility::string_t parameterToString(int64_t value);
|
||||
static utility::string_t parameterToString(float value);
|
||||
static utility::string_t parameterToString(double value);
|
||||
static utility::string_t parameterToString(const utility::datetime &value);
|
||||
static utility::string_t parameterToString(bool value);
|
||||
template<class T>
|
||||
static utility::string_t parameterToString(const std::vector<T>& value);
|
||||
template<class T>
|
||||
static utility::string_t parameterToString(const std::shared_ptr<T>& value);
|
||||
|
||||
pplx::task<web::http::http_response> callApi(
|
||||
const utility::string_t& path,
|
||||
const utility::string_t& method,
|
||||
const std::map<utility::string_t, utility::string_t>& queryParams,
|
||||
const std::shared_ptr<IHttpBody> postBody,
|
||||
const std::map<utility::string_t, utility::string_t>& headerParams,
|
||||
const std::map<utility::string_t, utility::string_t>& formParams,
|
||||
const std::map<utility::string_t, std::shared_ptr<HttpContent>>& fileParams,
|
||||
const utility::string_t& contentType
|
||||
) const;
|
||||
|
||||
protected:
|
||||
|
||||
ResponseHandlerType m_ResponseHandler;
|
||||
std::shared_ptr<const ApiConfiguration> m_Configuration;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
utility::string_t ApiClient::parameterToString(const std::vector<T>& value)
|
||||
{
|
||||
utility::stringstream_t ss;
|
||||
|
||||
for( size_t i = 0; i < value.size(); i++)
|
||||
namespace api
|
||||
{
|
||||
if( i > 0) ss << utility::conversions::to_string_t(", ");
|
||||
ss << ApiClient::parameterToString(value[i]);
|
||||
|
||||
using namespace tribufu::models;
|
||||
|
||||
class ApiClient
|
||||
{
|
||||
public:
|
||||
ApiClient(std::shared_ptr<const ApiConfiguration> configuration = nullptr);
|
||||
virtual ~ApiClient();
|
||||
|
||||
typedef std::function<void(web::http::status_code, const web::http::http_headers &)> ResponseHandlerType;
|
||||
|
||||
const ResponseHandlerType &getResponseHandler() const;
|
||||
void setResponseHandler(const ResponseHandlerType &responseHandler);
|
||||
|
||||
std::shared_ptr<const ApiConfiguration> getConfiguration() const;
|
||||
void setConfiguration(std::shared_ptr<const ApiConfiguration> configuration);
|
||||
|
||||
static utility::string_t parameterToString(utility::string_t value);
|
||||
static utility::string_t parameterToString(int32_t value);
|
||||
static utility::string_t parameterToString(int64_t value);
|
||||
static utility::string_t parameterToString(float value);
|
||||
static utility::string_t parameterToString(double value);
|
||||
static utility::string_t parameterToString(const utility::datetime &value);
|
||||
static utility::string_t parameterToString(bool value);
|
||||
template <class T> static utility::string_t parameterToString(const std::vector<T> &value);
|
||||
template <class T> static utility::string_t parameterToString(const std::shared_ptr<T> &value);
|
||||
|
||||
pplx::task<web::http::http_response> callApi(
|
||||
const utility::string_t &path, const utility::string_t &method,
|
||||
const std::map<utility::string_t, utility::string_t> &queryParams,
|
||||
const std::shared_ptr<IHttpBody> postBody,
|
||||
const std::map<utility::string_t, utility::string_t> &headerParams,
|
||||
const std::map<utility::string_t, utility::string_t> &formParams,
|
||||
const std::map<utility::string_t, std::shared_ptr<HttpContent>> &fileParams,
|
||||
const utility::string_t &contentType) const;
|
||||
|
||||
protected:
|
||||
ResponseHandlerType m_ResponseHandler;
|
||||
std::shared_ptr<const ApiConfiguration> m_Configuration;
|
||||
};
|
||||
|
||||
template <class T> utility::string_t ApiClient::parameterToString(const std::vector<T> &value)
|
||||
{
|
||||
utility::stringstream_t ss;
|
||||
|
||||
for (size_t i = 0; i < value.size(); i++)
|
||||
{
|
||||
if (i > 0)
|
||||
ss << utility::conversions::to_string_t(", ");
|
||||
ss << ApiClient::parameterToString(value[i]);
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
template <class T> utility::string_t ApiClient::parameterToString(const std::shared_ptr<T> &value)
|
||||
{
|
||||
return parameterToString(*value.get());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
utility::string_t ApiClient::parameterToString(const std::shared_ptr<T>& value)
|
||||
{
|
||||
return parameterToString(*value.get());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* TRIBUFU_API_ApiClient_H_ */
|
||||
|
Reference in New Issue
Block a user