View Source Tw.V1_1.CursoredResult (Tw v0.1.1)

See the Twitter API documentation for details.

Link to this section Summary

Functions

Return if there is a next page from a cursor.

Return if there is a previous page from a cursor.

Return cursored endpoints results as Stream. If the rate limit is exceeded, sleep and retry.

Return cursored endpoints results as Stream.

Link to this section Types

Specs

cursor() :: integer()

Specs

t(key, type) :: %{
  required(key) => type,
  next_cursor: cursor(),
  next_cursor_str: binary(),
  previous_cursor: cursor(),
  previous_cursor_str: binary()
}

Link to this section Functions

Link to this function

has_next?(cursored_result)

View Source

Specs

has_next?(%{next_cursor: integer()}) :: boolean()

Return if there is a next page from a cursor.

Examples

iex> {:ok, res} = Tw.V1_1.User.follower_ids(client)
iex> Tw.V1_1.CursoredResult.has_next?(res)
true
Link to this function

has_previous?(cursored_result)

View Source

Specs

has_previous?(%{previous_cursor: integer()}) :: boolean()

Return if there is a previous page from a cursor.

Examples

iex> {:ok, res} = Tw.V1_1.User.follower_ids(client)
iex> Tw.V1_1.CursoredResult.has_previous?(res)
false
Link to this function

persevering_stream!(key, func, initial_cursor \\ -1)

View Source

Specs

persevering_stream!(
  atom(),
  (integer() -> {:ok, map()} | {:error, Exception.t()}),
  integer()
) ::
  Enumerable.t()

Return cursored endpoints results as Stream. If the rate limit is exceeded, sleep and retry.

Examples

iex> Tw.V1_1.CursoredResult.persevering_stream!(:ids, fn cursor -> Tw.V1_1.User.fllower_ids(client, %{screen_name: "twitterapi", cursor: cursor}) end)
...> |> Enum.each(&IO.inspect/1)
Link to this function

stream!(key, func, initial_cursor \\ -1)

View Source

Specs

stream!(
  atom(),
  (integer() -> {:ok, map()} | {:error, Exception.t()}),
  integer()
) ::
  Enumerable.t()

Return cursored endpoints results as Stream.

Examples

iex> Tw.V1_1.CursoredResult.stream!(:ids, fn cursor -> Tw.V1_1.User.fllower_ids(client, %{screen_name: "twitterapi", cursor: cursor} end)
...> |> Enum.each(&IO.inspect/1)

iex> Tw.V1_1.CursoredResult.stream!(:ids, fn cursor -> Tw.V1_1.User.fllower_ids(client, %{screen_name: "twitterapi", cursor: cursor} end)
...> |> Stream.run()
** (Tw.V1_1.CursoredResult.StreamError) Rate limit exceeded