UrbitEx.API (UrbitEx v0.6.5) View Source

Module with the base functions to start the Urbit Session. Other complex functionality found in other files in this folder.

Link to this section Summary

Functions

Sends an ack to Eyre for a given event. Takes a Session struct, a Channel struct and an event_id, string or integer. Returns an {:ok, %HTTPoison.Response{}} tuple.

Closes an eyre channel. Takes a Session struct and a Channel struct. Returns an {:ok, %HTTPoison.Response{}} tuple.

Evaluates Hoon code (equivalent to clicking the code button on a Landscape chat). Takes a Session struct and a string with hoon code. Returns a string with the result of the code evaluation.

Fetches the last six characters of your base desk hash. Commonly known in Urbit as your "base hash". It shows at the bottom left corner of Landscape as of Urbit OS 2.98.

Logs in to Urbit. Takes a url url and a code string. Returns an {:ok, url, ship, cookie} tuple if login is successful, or a {:error, error} tuple if the url or the +code is wrong.

Opens the Eyre channel with an empty Airlock request. Takes a Session struct and a Channel struct. Returns :ok

Starts Server-side Event Evenstream, called by UrbitEx.Server on start. Takes a Session struct and a Channel struct. Returns :ok.

Subscribes to Gall apps pushing events to your ship. Events will be sent to the SSE feed. Takes a Session struct, a Channel struct and a list of subscriptions maps. A subscription map takes the shape of e.g.%{app: "group-view", path: "/all"}. See the urbit_ex.ex file for more examples of valid subscriptions. Returns a Session struct.

Adds necessary metadata to PUT requests sent to Airlock. Keeps track of requests to increment request id and acks server-side events received, following Landscape practice. Takes a Session struct, a Channel struct and a list of request bodies for the PUT request. Returns an {:ok, %HTTPoison.Response{}} tuple.

Link to this section Functions

Link to this function

ack(session, channel, event_id)

View Source

Sends an ack to Eyre for a given event. Takes a Session struct, a Channel struct and an event_id, string or integer. Returns an {:ok, %HTTPoison.Response{}} tuple.

Link to this function

close_channel(session, channel)

View Source

Closes an eyre channel. Takes a Session struct and a Channel struct. Returns an {:ok, %HTTPoison.Response{}} tuple.

Evaluates Hoon code (equivalent to clicking the code button on a Landscape chat). Takes a Session struct and a string with hoon code. Returns a string with the result of the code evaluation.

Fetches the last six characters of your base desk hash. Commonly known in Urbit as your "base hash". It shows at the bottom left corner of Landscape as of Urbit OS 2.98.

Logs in to Urbit. Takes a url url and a code string. Returns an {:ok, url, ship, cookie} tuple if login is successful, or a {:error, error} tuple if the url or the +code is wrong.

Link to this function

open_channel(session, channel)

View Source

Opens the Eyre channel with an empty Airlock request. Takes a Session struct and a Channel struct. Returns :ok

Link to this function

restart_sse(session, channel)

View Source
Link to this function

start_sse(session, channel)

View Source

Starts Server-side Event Evenstream, called by UrbitEx.Server on start. Takes a Session struct and a Channel struct. Returns :ok.

Link to this function

subscribe(session, channel, subscriptions)

View Source

Subscribes to Gall apps pushing events to your ship. Events will be sent to the SSE feed. Takes a Session struct, a Channel struct and a list of subscriptions maps. A subscription map takes the shape of e.g.%{app: "group-view", path: "/all"}. See the urbit_ex.ex file for more examples of valid subscriptions. Returns a Session struct.

Link to this function

wrap_put(session, channel, items)

View Source

Adds necessary metadata to PUT requests sent to Airlock. Keeps track of requests to increment request id and acks server-side events received, following Landscape practice. Takes a Session struct, a Channel struct and a list of request bodies for the PUT request. Returns an {:ok, %HTTPoison.Response{}} tuple.