Skip to content

Latest commit

 

History

History
468 lines (358 loc) · 32 KB

File metadata and controls

468 lines (358 loc) · 32 KB

Tasks

Overview

A task is a defined, actionable item with references to linked records and assigned workspace members.

Available Operations

list

List all tasks. Results are sorted by creation date, from oldest to newest.

Required scopes: task:read, object_configuration:read, record_permission:read, user_management:read.

Example Usage

import { Attio } from "@interfere/attio";

const attio = new Attio({
  oauth2: process.env["ATTIO_OAUTH2"] ?? "",
});

async function run() {
  const result = await attio.tasks.list({
    limit: 10,
    offset: 5,
    sort: "created_at:desc",
    linkedObject: "people",
    linkedRecordId: "891dcbfc-9141-415d-9b2a-2238a6cc012d",
    assignee: "50cf242c-7fa3-4cad-87d0-75b1af71c57b",
    isCompleted: true,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { AttioCore } from "@interfere/attio/core.js";
import { tasksList } from "@interfere/attio/funcs/tasks-list.js";

// Use `AttioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const attio = new AttioCore({
  oauth2: process.env["ATTIO_OAUTH2"] ?? "",
});

async function run() {
  const res = await tasksList(attio, {
    limit: 10,
    offset: 5,
    sort: "created_at:desc",
    linkedObject: "people",
    linkedRecordId: "891dcbfc-9141-415d-9b2a-2238a6cc012d",
    assignee: "50cf242c-7fa3-4cad-87d0-75b1af71c57b",
    isCompleted: true,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("tasksList failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.ListTasksRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.ListTasksResponse>

Errors

Error Type Status Code Content Type
errors.AttioError 4XX, 5XX */*

create

Creates a new task.

At present, tasks can only be created from plaintext without record reference formatting.

Required scopes: task:read-write, object_configuration:read, record_permission:read, user_management:read.

Example Usage

import { Attio } from "@interfere/attio";

const attio = new Attio({
  oauth2: process.env["ATTIO_OAUTH2"] ?? "",
});

async function run() {
  const result = await attio.tasks.create({
    data: {
      content: "Follow up on current software solutions",
      format: "plaintext",
      deadlineAt: "2023-01-01T15:00:00.000000000Z",
      isCompleted: false,
      linkedRecords: [
        "person@company.com",
        "fundstack.com",
      ],
      assignees: [
        {
          workspaceMemberEmailAddress: "alice@attio.com",
        },
      ],
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { AttioCore } from "@interfere/attio/core.js";
import { tasksCreate } from "@interfere/attio/funcs/tasks-create.js";

// Use `AttioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const attio = new AttioCore({
  oauth2: process.env["ATTIO_OAUTH2"] ?? "",
});

async function run() {
  const res = await tasksCreate(attio, {
    data: {
      content: "Follow up on current software solutions",
      format: "plaintext",
      deadlineAt: "2023-01-01T15:00:00.000000000Z",
      isCompleted: false,
      linkedRecords: [
        "person@company.com",
        "fundstack.com",
      ],
      assignees: [
        {
          workspaceMemberEmailAddress: "alice@attio.com",
        },
      ],
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("tasksCreate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.CreateTaskRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.CreateTaskResponse>

Errors

Error Type Status Code Content Type
errors.CreateTaskValidationTypeError 400 application/json
errors.CreateTaskNotFoundError 404 application/json
errors.AttioError 4XX, 5XX */*

get

Get a single task by ID.

Required scopes: task:read, object_configuration:read, record_permission:read, user_management:read.

Example Usage

import { Attio } from "@interfere/attio";

const attio = new Attio({
  oauth2: process.env["ATTIO_OAUTH2"] ?? "",
});

async function run() {
  const result = await attio.tasks.get({
    taskId: "649e34f4-c39a-4f4d-99ef-48a36bef8f04",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { AttioCore } from "@interfere/attio/core.js";
import { tasksGet } from "@interfere/attio/funcs/tasks-get.js";

// Use `AttioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const attio = new AttioCore({
  oauth2: process.env["ATTIO_OAUTH2"] ?? "",
});

async function run() {
  const res = await tasksGet(attio, {
    taskId: "649e34f4-c39a-4f4d-99ef-48a36bef8f04",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("tasksGet failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetTaskRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.GetTaskResponse>

Errors

Error Type Status Code Content Type
errors.GetTaskNotFoundError 404 application/json
errors.AttioError 4XX, 5XX */*

delete

Delete a task by ID.

Required scopes: task:read-write.

Example Usage

import { Attio } from "@interfere/attio";

const attio = new Attio({
  oauth2: process.env["ATTIO_OAUTH2"] ?? "",
});

async function run() {
  const result = await attio.tasks.delete({
    taskId: "649e34f4-c39a-4f4d-99ef-48a36bef8f04",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { AttioCore } from "@interfere/attio/core.js";
import { tasksDelete } from "@interfere/attio/funcs/tasks-delete.js";

// Use `AttioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const attio = new AttioCore({
  oauth2: process.env["ATTIO_OAUTH2"] ?? "",
});

async function run() {
  const res = await tasksDelete(attio, {
    taskId: "649e34f4-c39a-4f4d-99ef-48a36bef8f04",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("tasksDelete failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.DeleteTaskRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.DeleteTaskResponse>

Errors

Error Type Status Code Content Type
errors.DeleteTaskNotFoundError 404 application/json
errors.AttioError 4XX, 5XX */*

update

Updates an existing task by task_id. At present, only the deadline_at, is_completed, linked_records, and assignees fields can be updated.

Required scopes: task:read-write, object_configuration:read, record_permission:read, user_management:read.

Example Usage

import { Attio } from "@interfere/attio";

const attio = new Attio({
  oauth2: process.env["ATTIO_OAUTH2"] ?? "",
});

async function run() {
  const result = await attio.tasks.update({
    taskId: "649e34f4-c39a-4f4d-99ef-48a36bef8f04",
    body: {
      data: {
        deadlineAt: "2023-01-01T15:00:00.000000000Z",
        isCompleted: false,
        linkedRecords: [
          "person@company.com",
          "fundstack.com",
        ],
        assignees: [
          {
            referencedActorType: "workspace-member",
            referencedActorId: "50cf242c-7fa3-4cad-87d0-75b1af71c57b",
          },
        ],
      },
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { AttioCore } from "@interfere/attio/core.js";
import { tasksUpdate } from "@interfere/attio/funcs/tasks-update.js";

// Use `AttioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const attio = new AttioCore({
  oauth2: process.env["ATTIO_OAUTH2"] ?? "",
});

async function run() {
  const res = await tasksUpdate(attio, {
    taskId: "649e34f4-c39a-4f4d-99ef-48a36bef8f04",
    body: {
      data: {
        deadlineAt: "2023-01-01T15:00:00.000000000Z",
        isCompleted: false,
        linkedRecords: [
          "person@company.com",
          "fundstack.com",
        ],
        assignees: [
          {
            referencedActorType: "workspace-member",
            referencedActorId: "50cf242c-7fa3-4cad-87d0-75b1af71c57b",
          },
        ],
      },
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("tasksUpdate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.UpdateTaskRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.UpdateTaskResponse>

Errors

Error Type Status Code Content Type
errors.UpdateTaskValidationTypeError 400 application/json
errors.UpdateTaskNotFoundError 404 application/json
errors.AttioError 4XX, 5XX */*