diff --git a/components/aircall/actions/create-contact/create-contact.mjs b/components/aircall/actions/create-contact/create-contact.mjs index ab87ccb18999d..0014d67878917 100644 --- a/components/aircall/actions/create-contact/create-contact.mjs +++ b/components/aircall/actions/create-contact/create-contact.mjs @@ -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\": \"john.doe@test.com\"}] }}`, or `{{ [\"john.doe@test.com\"] }}`", 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; }, diff --git a/components/aircall/package.json b/components/aircall/package.json index 68da5d2adfd54..57e401645ac14 100644 --- a/components/aircall/package.json +++ b/components/aircall/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/aircall", - "version": "0.1.0", + "version": "0.1.1", "description": "Pipedream Aircall Components", "main": "aircall.app.mjs", "keywords": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a5967e6847e2c..7d0301d2f4479 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41922,7 +41922,7 @@ snapshots: jest-util: 29.7.0 natural-compare: 1.4.0 pretty-format: 29.7.0 - semver: 7.6.3 + semver: 7.7.1 transitivePeerDependencies: - supports-color