IncidentIo (IncidentIo v0.3.0)

View Source

IncidentIo is an Elixir client for the Incident.io API.

Summary

Types

deprecated_incident_mode()

@type deprecated_incident_mode() :: :real | :test | :tutorial

deprecated_incident_modes()

@type deprecated_incident_modes() :: [:real | :test | :tutorial]

incident_mode()

@type incident_mode() :: :standard | :retrospective | :test | :tutorial | :stream

incident_modes()

@type incident_modes() :: [:standard | :retrospective | :test | :tutorial | :stream]

pagination_response()

@type pagination_response() :: {response(), binary() | nil, IncidentIo.Client.auth()}

response()

@type response() :: {integer(), any(), Req.Response.t()} | pagination_response()

Functions

add_params_to_url(url, params)

@spec add_params_to_url(binary(), list()) :: binary()

Take an existing URI and add addition params, appending and replacing as necessary.

Examples

iex> add_params_to_url("http://example.com/wat", [])
"http://example.com/wat"

iex> add_params_to_url("http://example.com/wat", [q: 1])
"http://example.com/wat?q=1"

iex> add_params_to_url("http://example.com/wat", [q: 1, t: 2])
"http://example.com/wat?q=1&t=2"

iex> add_params_to_url("http://example.com/wat", %{q: 1, t: 2})
"http://example.com/wat?q=1&t=2"

iex> add_params_to_url("http://example.com/wat?q=1&t=2", [])
"http://example.com/wat?q=1&t=2"

iex> add_params_to_url("http://example.com/wat?q=1", [t: 2])
"http://example.com/wat?q=1&t=2"

iex> add_params_to_url("http://example.com/wat?q=1", [q: 3, t: 2])
"http://example.com/wat?q=3&t=2"

iex> add_params_to_url("http://example.com/wat?q=1&s=4", [q: 3, t: 2])
"http://example.com/wat?q=3&s=4&t=2"

iex> add_params_to_url("http://example.com/wat?q=1&s=4", [q: 3, t: 2, u: [o: 1, v: 0]])
"http://example.com/wat?q=3&s=4&t=2&u[o]=1&u[v]=0"

iex> add_params_to_url("http://example.com/wat?q=1&s=4", [q: 3, t: 2, u: [1, "two", 3]])
"http://example.com/wat?q=3&s=4&t=2&u[]=1&u[]=two&u[]=3"

iex> add_params_to_url("http://example.com/wat?q=1&s=4", %{q: 3, t: 2})
"http://example.com/wat?q=3&s=4&t=2"

iex> add_params_to_url("http://example.com/wat?q=1&s=4", %{q: 3, t: 2, u: [o: 1, v: 0]})
"http://example.com/wat?q=3&s=4&t=2&u[o]=1&u[v]=0"

iex> add_params_to_url("http://example.com/wat?q=1&s=4", %{q: 3, t: 2, u: [1, "two", 3]})
"http://example.com/wat?q=3&s=4&t=2&u[]=1&u[]=two&u[]=3"

authorization_header(options)

Same as authorization_header/2 but defaults initial headers to include @user_agent.

authorization_header(arg1, headers)

@spec authorization_header(IncidentIo.Client.auth(), list()) :: list()

Use a JWT bearer token to authenticate to the Incident.io API:

Examples

iex> IncidentIo.authorization_header(%{api_key: "92873971893"}, [])
[{"Authorization", "Bearer 92873971893"}]

More info at: https://api-docs.incident.io/#section/Making-requests/Authentication

delete(path, client, body \\ "")

@spec delete(binary(), IncidentIo.Client.t(), any()) :: response()

get(path, client, params \\ [])

@spec get(binary(), IncidentIo.Client.t(), keyword()) :: response()

json_request(method, url, body \\ "", headers \\ [], options \\ [])

@spec json_request(atom(), binary(), any(), keyword(), keyword()) :: response()

patch(path, client, body \\ "")

@spec patch(binary(), IncidentIo.Client.t(), any()) :: response()

post(path, client, body \\ "")

@spec post(binary(), IncidentIo.Client.t(), any()) :: response()

process_response(resp)

@spec process_response(Req.Response.t()) :: response()

process_response_body(body)

@spec process_response_body(binary() | nil) :: term()

put(path, client, body \\ "")

@spec put(binary(), IncidentIo.Client.t(), any()) :: response()

raw_request(method, url, body \\ "", headers \\ [], options \\ [])