View Source CozyAliyunOpenAPI.HTTPClient behaviour (cozy_aliyun_open_api v0.3.0)

The specification for a HTTP client.

It can be set to a client provided by CozyAliyunOpenAPI, such as:

config :cozy_aliyun_open_api,
  http_client: CozyAliyunOpenAPI.HTTPClient.Finch

Or, set it to your own API client, such as:

config :cozy_aliyun_open_api,
  http_client: MyHTTPClient

Summary

Types

The response of a request.

Callbacks

Callback to initialize the given API client.

Callback to send a request.

Functions

Issues an HTTP request by the given HTTP client.

Types

@type body() :: map() | binary()
@type headers() :: [{binary(), binary()}]
@type response() :: {:ok, status(), headers(), body()} | {:error, term()}

The response of a request.

@type status() :: pos_integer()

Callbacks

@callback init() :: :ok

Callback to initialize the given API client.

@callback request(CozyAliyunOpenAPI.HTTPRequest.t()) :: response()

Callback to send a request.

Functions

Issues an HTTP request by the given HTTP client.

When the content-type header of the response is "application/xml" or "text/xml", this function will try to convert the XML body to a map with snaked-cased keys.

When the content-type header of the response is "application/json", this function will try to convert the body to a map with snaked-cased keys.