ExMicrosoftBot.Client (ex_microsoftbot v3.0.0)

This module contains low-level functions for interacting with the Bot Framework API.

For most use-cases and a friendlier API, each of the individual endpoints' client modules should be used instead:

Still, this module exports functions that can help perform arbitrary, pre-authorized API calls, for example for fetching assets or calling new endpoints that this library hasn't implemented yet.

Link to this section Summary

Functions

Returns the headers required for an authorized JSON request to the BotFramework API.

DELETEs the given URI with an authorized request & standard options, logging the result.

Helper that deserializes a request response using the given deserializing function if the given response has a successful status. Otherwise, returns an error tuple instead.

GETs the given URI with an authorized request & standard options, logging the result.

Returns an options Keyword for request functions. Merges the default options (from config) with the given extra.

POSTs the given body to the given URI with an authorized request & standard options, logging the result.

PUTs the given body to the given URI with an authorized request & standard options, logging the result.

Link to this section Types

Link to this type

error_type()

Specs

error_type() :: {:error, integer(), String.t()}

Link to this section Functions

Link to this function

authed_headers(uri)

Specs

authed_headers(uri :: String.t()) :: [{String.t(), String.t()}]

Returns the headers required for an authorized JSON request to the BotFramework API.

Link to this function

delete(url, extra_opts \\ [])

Specs

delete(url :: String.t(), extra_opts :: keyword()) :: HTTPoison.Response.t()

DELETEs the given URI with an authorized request & standard options, logging the result.

Link to this function

deserialize_response(arg, deserialize_fn)

Specs

deserialize_response(
  response :: HTTPoison.Response.t(),
  (String.t() -> deserialized)
) :: {:ok, deserialized | String.t()} | {:error, integer(), String.t()}
when deserialized: any()

Helper that deserializes a request response using the given deserializing function if the given response has a successful status. Otherwise, returns an error tuple instead.

The deserializing function is skipped when there is no body; an empty string is returned instead.

Link to this function

get(url, extra_opts \\ [])

Specs

get(url :: String.t(), extra_opts :: keyword()) :: HTTPoison.Response.t()

GETs the given URI with an authorized request & standard options, logging the result.

Link to this function

opts(extra \\ [])

Specs

opts(keyword :: keyword()) :: keyword()

Returns an options Keyword for request functions. Merges the default options (from config) with the given extra.

Link to this function

post(url, body, extra_opts \\ [])

Specs

post(url :: String.t(), body :: String.t() | map(), extra_opts :: keyword()) ::
  HTTPoison.Response.t()

POSTs the given body to the given URI with an authorized request & standard options, logging the result.

If a map, the body is JSON encoded before POSTing. Will raise if encoding fails.

Link to this function

put(url, body, extra_opts \\ [])

Specs

put(url :: String.t(), body :: String.t() | map(), extra_opts :: keyword()) ::
  HTTPoison.Response.t()

PUTs the given body to the given URI with an authorized request & standard options, logging the result.

If a map, the body is JSON encoded before PUTing. Will raise if encoding fails.