Class IApiClient

Inheritance Relationships

Derived Type

Class Documentation

class IApiClient

Provides an abstracted interface for working with an HTTP client library.

Subclassed by axr::sdk::net::CprApiClient

Public Functions

virtual pplx::task<utility::string_t> Send(const utility::string_t &path, const HttpMethod 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 utility::string_t &contentType) = 0

Initiates an HTTP request to the remote server for the given path and method.

Parameters
  • path – The resource path to send the request to.

  • method – The HTTP method to use in the request.

  • queryParams – The query parameters to add to the path.

  • postBody – The message body to send to the remote server.

  • headerParams – The set of headers to attach to the request.

  • contentType – The content type of the request.

Returns

The response encoded as a string.

virtual pplx::task<utility::string_t> SendForm(const utility::string_t &path, const HttpMethod method, const std::map<utility::string_t, utility::string_t> &formParams, const std::map<utility::string_t, utility::string_t> &queryParams, const std::map<utility::string_t, utility::string_t> &headerParams) = 0

Initiates an HTTP request to send a multi-part form to the remote server for the given path and method.

Parameters
  • path – The resource path to send the request to.

  • method – The HTTP method to use in the request.

  • formParms – The set of HTTP form parameters to attach to the request.

  • queryParams – The query parameters to add to the path.

  • headerParams – The set of headers to attach to the request.

Returns

The response encoded as a string.

virtual pplx::task<utility::string_t> SendFile(const utility::string_t &path, const HttpMethod method, const std::map<utility::string_t, std::shared_ptr<HttpContent>> &fileParams, const std::map<utility::string_t, utility::string_t> &queryParams, const std::map<utility::string_t, utility::string_t> &headerParams, const utility::string_t &contentType) = 0

Initiates an HTTP request to send a set of files to the remote server for the given path and method.

Parameters
  • path – The resource path to send the request to.

  • method – The HTTP method to use in the request.

  • queryParams – The query parameters to add to the path.

  • file – The set of file parameters to attach to the request.

  • headerParams – The set of headers to attach to the request.

  • contentType – The content type of the request.

Returns

The response encoded as a string.

virtual pplx::task<void> Delete(const utility::string_t &path, const std::map<utility::string_t, utility::string_t> &queryParams, const std::map<utility::string_t, utility::string_t> &headerParams) = 0

Initiates an HTTP DELETE request at the given path.

Parameters
  • path – The path to the remote resource to delete.

  • queryParams – The set of query parameters to append to the path.

  • headerParams – The set of headers to attach to the request.

virtual pplx::task<Variant> Get(const utility::string_t &path, const std::map<utility::string_t, utility::string_t> &queryParams, const std::map<utility::string_t, utility::string_t> &headerParams) = 0

Initiates an HTTP GET request at the given path.

Parameters
  • path – The path to the remote resource to retrieve.

  • queryParams – The set of query parameters to append to the path.

  • headerParams – The set of headers to attach to the request.

Returns

The response encoded as a JSON object.

virtual pplx::task<std::uint64_t> Head(const utility::string_t &path, const std::map<utility::string_t, utility::string_t> &queryParams, const std::map<utility::string_t, utility::string_t> &headerParams) = 0

Initiates an HTTP HEAD request at the given path.

Parameters
  • path – The path to the remote resource to retrieve.

  • queryParams – The set of query parameters to append to the path.

  • headerParams – The set of headers to attach to the request.

Returns

The value of the Content-Length header returned in the response.

virtual pplx::task<Variant> Post(const utility::string_t &path, const Variant &body, const std::map<utility::string_t, utility::string_t> &headerParams) = 0

Initiates an HTTP POST request at the given path using the provided message body.

Parameters
  • path – The path to the remote resource to post.

  • body – The request body to send to the remote resource, encoded as a JSON object.

  • queryParams – The set of query parameters to append to the path.

  • headerParams – The set of headers to attach to the request.

Returns

The response encoded as a JSON object.

virtual pplx::task<Variant> Put(const utility::string_t &path, const Variant &body, const std::map<utility::string_t, utility::string_t> &headerParams) = 0

Initiates an HTTP PUT request at the given path using the provided message body.

Parameters
  • path – The path to the remote resource to put.

  • body – The request body to send to the remote resource, encoded as a JSON object.

  • queryParams – The set of query parameters to append to the path.

  • headerParams – The set of headers to attach to the request.

Returns

The response encoded as a JSON object.