farmbot v6.0.1-alpha 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

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.

Link to this type body() View Source
body() :: binary

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 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) View Source
download_file(adapter, url, Path.t, progress_callback, body, headers) ::
  {: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.