Class: Attio::Resources::Tasks Private

Inherits:
Base
  • Object
show all
Defined in:
lib/attio/resources/tasks.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

API resource for managing tasks in Attio

Tasks help track action items and to-dos associated with records.

Examples:

Creating a task

client.tasks.create(
  parent_object: "people",
  parent_record_id: "person_123",
  title: "Follow up on proposal",
  due_date: "2025-02-01",
  assignee_id: "user_456"
)

Listing tasks with filters

client.tasks.list(
  status: "pending",
  assignee_id: "user_456"
)

Since:

  • 1.0.0

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from Attio::Resources::Base

Instance Method Details

#complete(id:, completed_at: nil) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Mark a task as completed

Parameters:

  • id (String)

    The task ID

  • completed_at (String) (defaults to: nil)

    Optional completion timestamp (defaults to now)

Returns:

  • (Hash)

    The updated task

Raises:

  • (ArgumentError)

    if id is nil or empty

Since:

  • 1.0.0



101
102
103
104
105
106
# File 'lib/attio/resources/tasks.rb', line 101

def complete(id:, completed_at: nil)
  validate_id!(id, "Task")
  data = { status: "completed" }
  data[:completed_at] = completed_at if completed_at
  request(:patch, "tasks/#{id}", data)
end

#create(parent_object:, parent_record_id:, title:, **data) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create a new task

Parameters:

  • parent_object (String)

    The parent object type

  • parent_record_id (String)

    The ID of the parent record

  • title (String)

    The task title

  • data (Hash)

    Additional task data

Options Hash (**data):

  • :description (String)

    Task description

  • :due_date (String)

    Due date (ISO 8601 format)

  • :assignee_id (String)

    User ID to assign the task to

  • :status (String)

    Task status (pending, completed)

  • :priority (Integer)

    Task priority (1-5)

Returns:

  • (Hash)

    The created task

Raises:

  • (ArgumentError)

    if required parameters are missing

Since:

  • 1.0.0



64
65
66
67
68
69
70
71
72
73
# File 'lib/attio/resources/tasks.rb', line 64

def create(parent_object:, parent_record_id:, title:, **data)
  validate_parent!(parent_object, parent_record_id)
  validate_required_string!(title, "Task title")

  request(:post, "tasks", data.merge(
                            parent_object: parent_object,
                            parent_record_id: parent_record_id,
                            title: title
                          ))
end

#delete(id:) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Delete a task

Parameters:

  • id (String)

    The task ID to delete

Returns:

  • (Hash)

    Deletion confirmation

Raises:

  • (ArgumentError)

    if id is nil or empty

Since:

  • 1.0.0



125
126
127
128
# File 'lib/attio/resources/tasks.rb', line 125

def delete(id:)
  validate_id!(id, "Task")
  request(:delete, "tasks/#{id}")
end

#get(id:) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get a specific task by ID

Parameters:

  • id (String)

    The task ID

Returns:

  • (Hash)

    The task data

Raises:

  • (ArgumentError)

    if id is nil or empty

Since:

  • 1.0.0



45
46
47
48
# File 'lib/attio/resources/tasks.rb', line 45

def get(id:)
  validate_id!(id, "Task")
  request(:get, "tasks/#{id}")
end

#list(**params) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

List tasks with optional filters

Parameters:

  • params (Hash)

    Query parameters

Options Hash (**params):

  • :parent_object (String)

    Filter by parent object type

  • :parent_record_id (String)

    Filter by parent record

  • :status (String)

    Filter by status (pending, completed)

  • :assignee_id (String)

    Filter by assignee

  • :limit (Integer)

    Number of tasks to return

  • :cursor (String)

    Pagination cursor

Returns:

  • (Hash)

    API response containing tasks

Since:

  • 1.0.0



35
36
37
# File 'lib/attio/resources/tasks.rb', line 35

def list(**params)
  request(:get, "tasks", params)
end

#reopen(id:) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Reopen a completed task

Parameters:

  • id (String)

    The task ID

Returns:

  • (Hash)

    The updated task

Raises:

  • (ArgumentError)

    if id is nil or empty

Since:

  • 1.0.0



114
115
116
117
# File 'lib/attio/resources/tasks.rb', line 114

def reopen(id:)
  validate_id!(id, "Task")
  request(:patch, "tasks/#{id}", { status: "pending", completed_at: nil })
end

#update(id:, **data) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Update an existing task

Parameters:

  • id (String)

    The task ID

  • data (Hash)

    The fields to update

Options Hash (**data):

  • :title (String)

    New title

  • :description (String)

    New description

  • :due_date (String)

    New due date

  • :assignee_id (String)

    New assignee

  • :status (String)

    New status

  • :priority (Integer)

    New priority

Returns:

  • (Hash)

    The updated task

Raises:

  • (ArgumentError)

    if id is invalid

Since:

  • 1.0.0



88
89
90
91
92
# File 'lib/attio/resources/tasks.rb', line 88

def update(id:, **data)
  validate_id!(id, "Task")
  validate_data!(data, "Update")
  request(:patch, "tasks/#{id}", data)
end