Skip to content

[Components] attio - added new components #16411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions components/attio/actions/create-note/create-note.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,33 @@ export default {
key: "attio-create-note",
name: "Create Note",
description: "Creates a new note for a given record. The note will be linked to the specified record. [See the documentation](https://developers.attio.com/reference/post_v2-notes)",
version: "0.0.2",
version: "0.0.3",
type: "action",
props: {
attio,
parentObject: {
propDefinition: [
attio,
"objectId",
() => ({
mapper: ({
api_slug: value,
singular_noun: label,
}) => ({
value,
label,
}),
}),
],
label: "Parent Object ID",
description: "The ID of the parent object the note belongs to",
label: "Parent Object",
description: "The parent object the note belongs to",
},
parentRecordId: {
propDefinition: [
attio,
"recordId",
(c) => ({
objectId: c.parentObject,
({ parentObject }) => ({
targetObject: parentObject,
}),
],
label: "Parent Record ID",
Expand All @@ -38,8 +47,16 @@ export default {
description: "The content of the note",
},
},
methods: {
createNote(args = {}) {
return this.attio.post({
path: "/notes",
...args,
});
},
},
async run({ $ }) {
const response = await this.attio.createNote({
const response = await this.createNote({
$,
data: {
data: {
Expand All @@ -51,7 +68,7 @@ export default {
},
},
});
$.export("$summary", `Successfully created note with ID: ${response.data.id.note_id}`);
$.export("$summary", `Successfully created note with ID \`${response.data.id.note_id}\`.`);
return response;
},
};
199 changes: 199 additions & 0 deletions components/attio/actions/create-person/create-person.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
import attio from "../../attio.app.mjs";
import constants from "../../common/constants.mjs";

export default {
key: "attio-create-person",
name: "Create Person",
description: "Creates a new person. [See the documentation](https://developers.attio.com/reference/post_v2-objects-people-records).",
version: "0.0.1",
type: "action",
props: {
attio,
firstName: {
propDefinition: [
attio,
"firstName",
],
},
lastName: {
propDefinition: [
attio,
"lastName",
],
},
emailAddress: {
propDefinition: [
attio,
"emailAddress",
],
},
description: {
propDefinition: [
attio,
"description",
],
},
jobTitle: {
propDefinition: [
attio,
"jobTitle",
],
},
phoneNumber: {
propDefinition: [
attio,
"phoneNumber",
],
},
phoneNumberCountryCode: {
propDefinition: [
attio,
"phoneNumberCountryCode",
],
},
linkedin: {
propDefinition: [
attio,
"linkedin",
],
},
twitter: {
propDefinition: [
attio,
"twitter",
],
},
facebook: {
propDefinition: [
attio,
"facebook",
],
},
instagram: {
propDefinition: [
attio,
"instagram",
],
},
companyId: {
label: "Company ID",
description: "The ID of the company to associate with the person.",
optional: true,
propDefinition: [
attio,
"recordId",
() => ({
targetObject: constants.TARGET_OBJECT.COMPANIES,
}),
],
},
},
async run({ $ }) {
const {
attio,
firstName,
lastName,
emailAddress,
description,
jobTitle,
phoneNumber,
phoneNumberCountryCode,
linkedin,
twitter,
facebook,
instagram,
companyId,
} = this;

const response = await attio.createRecord({
$,
targetObject: constants.TARGET_OBJECT.PEOPLE,
data: {
data: {
values: {
...(emailAddress && {
email_addresses: [
{
email_address: emailAddress,
},
],
}),
...(firstName || lastName) && {
name: [
{
first_name: firstName || "",
last_name: lastName || "",
full_name: `${firstName || ""} ${lastName || ""}`.trim(),
},
],
},
...(description && {
description: [
{
value: description,
},
],
}),
...(jobTitle && {
job_title: [
{
value: jobTitle,
},
],
}),
...(phoneNumber && {
phone_numbers: [
{
original_phone_number: phoneNumber,
...(phoneNumberCountryCode && {
country_code: phoneNumberCountryCode,
}),
},
],
}),
...(linkedin && {
linkedin: [
{
value: linkedin,
},
],
}),
...(twitter && {
twitter: [
{
value: twitter,
},
],
}),
...(facebook && {
facebook: [
{
value: facebook,
},
],
}),
...(instagram && {
instagram: [
{
value: instagram,
},
],
}),
...(companyId && {
company: [
{
target_object: constants.TARGET_OBJECT.COMPANIES,
target_record_id: companyId,
},
],
}),
},
},
},
});

$.export("$summary", `Successfully created person with ID \`${response.data.id.record_id}\`.`);

return response;
},
};
Loading
Loading