# `Attio.Tasks`
[🔗](https://github.com/sgerrand/ex_attio/blob/v0.2.0/lib/attio/tasks.ex#L1)

Functions for managing tasks with linked records.

Tasks are actionable items that can reference records and be assigned to
workspace members. Requires the `task:read` scope for read operations and
`task:read-write` for mutations.

## Pagination

`list/2` returns a single page. `stream/2` lazily pages through all tasks;
`stream_all/2` collects them into `{:ok, list}`. See `Attio` for an overview.

    client
    |> Attio.Tasks.stream()
    |> Stream.reject(fn t -> t["is_completed"] end)
    |> Enum.to_list()

# `create`

```elixir
@spec create(Attio.Client.t(), map()) :: {:ok, map()} | {:error, term()}
```

Creates a task.

## Required attributes

  * `"content"` - Task description text.
  * `"deadline_at"` - ISO 8601 deadline timestamp, or `nil`.

## Optional attributes

  * `"linked_records"` - List of `%{"target_object" => slug, "target_record_id" => id}` maps.
  * `"assignees"` - List of `%{"referenced_actor_type" => "workspace-member", "referenced_actor_id" => id}` maps.

# `delete`

```elixir
@spec delete(Attio.Client.t(), String.t()) :: {:ok, map()} | {:error, term()}
```

Deletes a task.

# `get`

```elixir
@spec get(Attio.Client.t(), String.t()) :: {:ok, map()} | {:error, term()}
```

Gets a single task by its ID.

# `list`

```elixir
@spec list(
  Attio.Client.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}
```

Lists tasks. Returns one page.

## Options

  * `:limit` - Number of tasks per page.
  * `:cursor` - Pagination cursor from a previous response.

# `stream`

```elixir
@spec stream(
  Attio.Client.t(),
  keyword()
) :: Enumerable.t()
```

Returns a lazy stream of all tasks across all pages.

Accepts the same options as `list/2`. Raises `{:attio_stream_error, error}`
on API failure mid-stream. Use `stream_all/2` if you prefer a standard
`{:ok, list} | {:error, term()}` return value.

# `stream_all`

```elixir
@spec stream_all(
  Attio.Client.t(),
  keyword()
) :: {:ok, [map()]} | {:error, Attio.Error.t() | Exception.t()}
```

Fetches all tasks across all pages and returns them as a list.

Accepts the same options as `list/2`. Returns `{:ok, [map()]}` on success
or `{:error, term()}` if any page request fails. Unlike `stream/2`, the
entire result set is loaded into memory.

## Example

    {:ok, tasks} = Attio.Tasks.stream_all(client)

# `update`

```elixir
@spec update(Attio.Client.t(), String.t(), map()) :: {:ok, map()} | {:error, term()}
```

Updates a task.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
