Intercom.API (intercom_elixir v2.0.1) View Source

Provides direct access to the Intercom API if other modules in this package don't provide the functionality you need.

See https://developers.intercom.com/intercom-api-reference/reference

Link to this section Summary

Link to this section Types

Specs

error() :: {:error, atom(), metadata() | nil}

Specs

metadata() :: %{
  :response => map(),
  :rate_limit => %{
    limit: integer(),
    reset: %DateTime{
      calendar: term(),
      day: term(),
      hour: term(),
      microsecond: term(),
      minute: term(),
      month: term(),
      second: term(),
      std_offset: term(),
      time_zone: term(),
      utc_offset: term(),
      year: term(),
      zone_abbr: term()
    },
    remaining: integer()
  },
  optional(:pagination) => metadata_pagination(),
  optional(:errors) => [map()]
}

Specs

metadata_pagination() :: %{
  :page => integer(),
  optional(:next_page) => integer(),
  :total_pages => integer(),
  :per_page => integer(),
  optional(:starting_after) => binary()
}

Specs

multiple_success() :: {:ok, [map()], metadata()}

Specs

opts() :: {:per_page, integer()} | {:starting_after, binary()}

Specs

response() :: single_success() | multiple_success() | error()

Specs

single_success() :: {:ok, map(), metadata()}

Link to this section Functions

Link to this function

call_endpoint(method, path, body \\ nil, opts \\ [])

View Source

Specs

call_endpoint(:get, String.t(), nil, [opts()]) :: response()
call_endpoint(:post, String.t(), map() | nil, [opts()]) :: response()

Call an Intercom API endpoint.

Arguments:

  • method: The HTTP request method.
  • path: The request path, e.g "users/1234".
  • body: The body of the request. Optional.
  • opts: Will be added either to the query part of the url (get) or the body of the request (post). Optional.
    • per_page: Results per page if result is a list, has to be between 1 and 150.
    • starting_after: Hash returned by the intercom API to get next page of results.

Returns {:ok, data, metadata} or {:error, error_code, metadata}.