farmbot v6.4.1 Farmbot.HTTP.Adapter behaviour View Source

Behaviour for a Farmbot HTTP adapter implementation.

Link to this section Summary

Types

Adapter pid

HTTP request payload

HTTP request header

HTTP method

Options to the underlying http adapter

Callback for progress of a downloaded file. Arg 1 should be the the downloaded bytes. Arg 2 should be the total number of bytes, nil, or the atom :complete

HTTP Status code

A json serializable map of meta data about an upload

HTTP url. Must be fully formatted

Link to this section Types

Link to this type adapter() View Source
adapter() :: pid()

Adapter pid.

HTTP request payload.

Link to this type headers() View Source
headers() :: [{binary(), binary()}]

HTTP request header.

Link to this type method() View Source
method() :: :get | :put | :post | :update

HTTP method.

Options to the underlying http adapter.

Link to this type progress_callback() View Source
progress_callback() :: (number(), number() | nil | :complete -> any())

Callback for progress of a downloaded file. Arg 1 should be the the downloaded bytes. Arg 2 should be the total number of bytes, nil, or the atom :complete

Link to this type status_code() View Source
status_code() :: integer()

HTTP Status code.

Link to this type stream_fun() View Source
stream_fun() :: (number(), binary() -> any())
Link to this type upload_meta() View Source
upload_meta() :: map()

A json serializable map of meta data about an upload.

HTTP url. Must be fully formatted.

Link to this section Callbacks

Link to this callback download_file(adapter, url, arg2, progress_callback, body, headers, stream_fun) View Source
download_file(
  adapter(),
  url(),
  Path.t(),
  progress_callback(),
  body(),
  headers(),
  stream_fun()
) :: {:ok, Path.t()} | {:error, term()}

Download a file to the Filesystem.

Link to this callback request(adapter, method, url, body, headers, opts) View Source
request(adapter(), method(), url(), body(), headers(), opts()) ::
  {:ok, Farmbot.HTTP.Response.t()} | {:error, term()}

HTTP Request.

Link to this callback start_link() View Source
start_link() :: {:ok, adapter()}

Start the adapter.

Link to this callback upload_file(adapter, arg1, upload_meta) View Source
upload_file(adapter(), Path.t(), upload_meta()) :: :ok | {:error, term()}

Upload a file.