element_kit v0.3.0 ElementKit.API

Offers convenience functions that call ELEMENT IoT API endpoints

Example:

API.get("/api/v1/streams?mandate_id=MANDATE_ID")

will expand to

HTTPoison.get("https://element-iot.com/api/v1/streams?auth=API_KEY&mandate_id=MANDATE_ID")

Convenience functionality:

  • HTTP methods with body automatically render JSON with Jason and add a content-type: application/json header.
  • The response will be parsed using Jason.

Link to this section Summary

Functions

Merges 2 URIs including their query parameters

Opens a WebSocket connection to the given url. An additional process is used to manage the connection. New messages will be sent to the process that called this function in this format

Link to this section Functions

Link to this function

delete(path, headers \\ [], opts \\ [])

Link to this function

get(path, headers \\ [], opts \\ [])

Link to this function

merge(a_bin, b_bin)

Merges 2 URIs including their query parameters

Link to this function

patch(path, body, headers \\ [], opts \\ [])

Link to this function

post(path, body, headers \\ [], opts \\ [])

Link to this function

put(path, body, headers \\ [], opts \\ [])

Link to this function

request(method, path, body \\ "", headers \\ [], options \\ [])

Link to this function

ws_link(uri, opts \\ [])

ws_link(URI.t() | binary(), keyword()) :: {:ok, pid()} | {:error, any()}

Opens a WebSocket connection to the given url. An additional process is used to manage the connection. New messages will be sent to the process that called this function in this format:

{:ws, :text, message} - message will be the result of decoding then json.