Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
42 changes: 35 additions & 7 deletions components/aircall/actions/create-contact/create-contact.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,64 @@ import common from "../common/common-create-update.mjs";
export default {
...common,
name: "Create Contact",
description: "Create a contact in Aircall. [See the documentation](https://developer.aircall.io/api-references/#create-a-contact)",
description:
"Create a contact in Aircall. [See the documentation](https://developer.aircall.io/api-references/#create-a-contact)",
key: "aircall-create-contact",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
...common.props,
emails: {
type: "string[]",
label: "Emails",
description: "Array of email address objects (max 20). Each should contain `label` and `value`. If a string is provided, it will be used as both the label and value.",
description:
"Array of email address objects (max 20). Each should contain `label` and `value`. If a string is provided, it will be used as both the label and value. For example, `{{ [{\"label\": \"Work\", \"value\": \"[email protected]\"}] }}`, or `{{ [\"[email protected]\"] }}`",
optional: true,
},
phoneNumbers: {
type: "string[]",
label: "Phone Numbers",
description: "Array of phone number objects (max 20). Each should contain `label` and `value`. If a string is provided, it will be used as both the label and value.",
description:
"Array of phone number objects (max 20). Each should contain `label` and `value`. If a string is provided, it will be used as both the label and value. For example, `{{ [{\"label\": \"Work\", \"value\": \"+1 812-641-5139\"}] }}`, or `{{ [\"+1 812-641-5139\"] }}`",
},
},
async run({ $ }) {
const refinedPhoneNumbers = this.phoneNumbers.map((item) => {
if (typeof item === "object" && item !== null) {
return item;
}

return {
label: item,
value: item,
};
});
const refinedEmails = this.emails.map((item) => {
if (typeof item === "object" && item !== null) {
return item;
}

return {
label: item,
value: item,
};
});

const data = {
...this.getCommonData(),
emails: this.emails,
phone_numbers: this.phoneNumbers,
emails: refinedEmails,
phone_numbers: refinedPhoneNumbers,
};

const response = await this.aircall.createContact({
$,
data,
});

$.export("$summary", `Successfully created contact (ID: ${response?.contact?.id})`);
$.export(
"$summary",
`Successfully created contact (ID: ${response?.contact?.id})`,
);

return response;
},
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading