View Source Intercom.API (intercom_elixir v3.0.0)

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

@type error() :: {:error, atom(), metadata() | nil}
@type metadata() :: %{
  :response => map(),
  :rate_limit => %{
    limit: integer() | nil,
    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()
      }
      | nil,
    remaining: integer() | nil
  },
  optional(:pagination) => metadata_pagination(),
  optional(:errors) => [map()]
}
@type metadata_pagination() :: %{
  :page => integer(),
  optional(:next_page) => integer(),
  :total_pages => integer(),
  :per_page => integer(),
  optional(:starting_after) => binary()
}
@type multiple_success() :: {:ok, [map()], metadata()}
@type opts() :: {:per_page, integer()} | {:starting_after, binary()}
@type response() :: single_success() | multiple_success() | error()
@type single_success() :: {:ok, map(), metadata()}

Link to this section Functions

Link to this function

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

View Source
@spec call_endpoint(:get, String.t(), nil, [opts()]) :: response()
@spec 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}.