All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cpp-rest-sdk-client.apiclient-header.mustache Maven / Gradle / Ivy

There is a newer version: 7.6.0
Show newest version
{{>licenseInfo}}
/*
 * ApiClient.h
 *
 * This is an API client responsible for stating the HTTP calls
 */

#ifndef {{apiHeaderGuardPrefix}}_ApiClient_H_
#define {{apiHeaderGuardPrefix}}_ApiClient_H_

{{{defaultInclude}}}
#include "{{packageName}}/ApiConfiguration.h"
#include "{{packageName}}/ApiException.h"
#include "{{packageName}}/IHttpBody.h"
#include "{{packageName}}/HttpContent.h"

#if  defined (_WIN32) || defined (_WIN64)
#undef U
#endif

#include 
#include 

#include 
#include 
#include 

{{#apiNamespaceDeclarations}}
namespace {{this}} {
{{/apiNamespaceDeclarations}}

using namespace {{modelNamespace}};

class {{declspec}} ApiClient
{
public:
    ApiClient( std::shared_ptr configuration = nullptr );
    virtual ~ApiClient();

    typedef std::function ResponseHandlerType;

    const ResponseHandlerType& getResponseHandler() const;
    void setResponseHandler(const ResponseHandlerType& responseHandler);

    std::shared_ptr getConfiguration() const;
    void setConfiguration(std::shared_ptr 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
    static utility::string_t parameterToString(const std::vector& value);
    template
    static utility::string_t parameterToString(const std::shared_ptr& value);

    pplx::task callApi(
        const utility::string_t& path,
        const utility::string_t& method,
        const std::map& queryParams,
        const std::shared_ptr postBody,
        const std::map& headerParams,
        const std::map& formParams,
        const std::map>& fileParams,
        const utility::string_t& contentType
    ) const;

protected:

    ResponseHandlerType m_ResponseHandler;
    std::shared_ptr m_Configuration;
};

template
utility::string_t ApiClient::parameterToString(const std::vector& 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
utility::string_t ApiClient::parameterToString(const std::shared_ptr& value)
{
    return parameterToString(*value.get());
}


{{#apiNamespaceDeclarations}}
}
{{/apiNamespaceDeclarations}}

#endif /* {{apiHeaderGuardPrefix}}_ApiClient_H_ */




© 2015 - 2024 Weber Informatics LLC | Privacy Policy