From b31695737a9c94218a2f3ed767bf70b5a1c501ec Mon Sep 17 00:00:00 2001 From: Marcelo Jabali Date: Fri, 26 Apr 2024 14:22:46 -0700 Subject: [PATCH 1/9] Added the ability to list phone numbers --- .../get-phone-numbers/get-phone-numbers.mjs | 137 +++++++++++++ .../actions/send-message/send-message.mjs | 190 +++++++++--------- components/telnyx/common/constants.mjs | 30 +++ components/telnyx/telnyx.app.mjs | 23 +++ 4 files changed, 284 insertions(+), 96 deletions(-) create mode 100644 components/telnyx/actions/get-phone-numbers/get-phone-numbers.mjs create mode 100644 components/telnyx/common/constants.mjs diff --git a/components/telnyx/actions/get-phone-numbers/get-phone-numbers.mjs b/components/telnyx/actions/get-phone-numbers/get-phone-numbers.mjs new file mode 100644 index 0000000000000..d011f7ceae7da --- /dev/null +++ b/components/telnyx/actions/get-phone-numbers/get-phone-numbers.mjs @@ -0,0 +1,137 @@ +import telnyxApp from "../../telnyx.app.mjs"; +import constants from "../../common/constants.mjs"; + +export default { + key: "telnyx-get-phone-numbers", + name: "Get Phone Numbers", + description: "Get a list of phone numbers. See documentation [here](https://developers.telnyx.com/api/numbers/list-phone-numbers)", + version: "0.1.8", + type: "action", + props: { + telnyxApp, + pageSize: { + type: "integer", + label: "Page Size", + description: "The size of the page.", + optional: true, + min: 1, + max: 250, + default: 20, + }, + pageNumber: { + type: "integer", + label: "Page Number", + description: "The page number to load.", + optional: true, + min: 1, + default: 1, + }, + tag: { + type: "string", + label: "Tag", + description: "Filter by tag.", + optional: true, + }, + phoneNumber: { + type: "string", + label: "Phone Number", + description: "Filter by phone number. Requires at least three digits. Non-numerical characters will result in no values being returned.", + optional: true, + }, + status: { + type: "string", + label: "Status", + description: "Filter by phone number status.", + options: Object.values(constants.phoneNumberStatus), + optional: true, + }, + connectionId: { + type: "string", + label: "Connection Id", + description: "Filter by connection Id.", + optional: true, + }, + contains: { + type: "string", + label: "Contains", + description: "Filter contains connection name. Requires at least three characters.", + optional: true, + }, + startsWith: { + type: "string", + label: "Starts With", + description: "Filter starts with connection name. Requires at least three characters.", + optional: true, + }, + endsWith: { + type: "string", + label: "Ends With", + description: "Filter ends with connection name. Requires at least three characters.", + optional: true, + }, + equals: { + type: "string", + label: "Equals", + description: "Filter by connection name.", + optional: true, + }, + paymentMethod: { + type: "string", + label: "Payment Method", + description: "Filter by usage payment method.", + options: Object.values(constants.paymentMethods), + optional: true, + }, + billingGroupId: { + type: "string", + label: "Billing Group Id", + description: "Filter by the billing group Id associated with phone numbers. To filter to only phone numbers that have no billing group associated them, set the value of this filter to the string 'null'.", + optional: true, + }, + emergencyAddressId: { + type: "string", + label: "Emergency Address Id", + description: "Filter by the emergency_address_id associated with phone numbers. To filter only phone numbers that have no emergency address associated with them, set the value of this filter to the string 'null'.", + optional: true, + }, + customerReference: { + type: "string", + label: "Customer Reference", + description: "Filter numbers via the customer reference set.", + optional: true, + }, + sort: { + type: "string", + label: "Sort", + description: "Specifies the sort order for results. If not given, results are sorted by created_at in descending order.", + options: Object.values(constants.sortPhoneNumbers), + optional: true, + }, + }, + async run({ $ }) { + const phoneNumbers = await this.telnyxApp.getPhoneNumbers({ + $, + params: { + 'page[size]': this.pageSize || 20, + 'page[number]': this.pageNumber || 1, + 'filter[tag]': this.tag, + 'filter[phone_number]': this.phoneNumber, + 'filter[status]': this.status, + 'filter[connection_id]': this.connectionId, + 'filter[voice.connection_name][contains]': this.contains, + 'filter[voice.connection_name][starts_with]': this.startsWith, + 'filter[voice.connection_name][ends_with]': this.endsWith, + 'filter[voice.connection_name][eq]': this.equals, + 'filter[voice.usage_payment_method]': this.paymentMethod, + 'filter[billing_group_id]': this.billingGroupId, + 'filter[emergency_address_id]': this.emergencyAddressId, + 'filter[customer_reference]': this.customerReference, + sort: this.sort, + }, + }); + $.export("$summary", `Successfully retrieved ${phoneNumbers.data.length} phone number${phoneNumbers.data.length === 1 + ? "" + : "s"}.`); + return phoneNumbers; + }, +}; diff --git a/components/telnyx/actions/send-message/send-message.mjs b/components/telnyx/actions/send-message/send-message.mjs index 0f77bae1779b1..80429534d4813 100644 --- a/components/telnyx/actions/send-message/send-message.mjs +++ b/components/telnyx/actions/send-message/send-message.mjs @@ -1,102 +1,100 @@ import telnyxApp from "../../telnyx.app.mjs"; export default { - key: "telnyx-send-message", - name: "Send Message", - description: "Send an SMS or MMS message. See documentation [here](https://developers.telnyx.com/docs/messaging/messages/send-message)", - version: "0.0.1", - type: "action", - props: { - telnyxApp, - messagingProfileId: { - optional: true, - propDefinition: [ + key: "telnyx-send-message", + name: "Send Message", + description: "Send an SMS or MMS message. See documentation [here](https://developers.telnyx.com/docs/messaging/messages/send-message)", + version: "0.1.14", + type: "action", + props: { telnyxApp, - "messagingProfileId", - ], + messagingProfileId: { + optional: true, + propDefinition: [ + telnyxApp, + "messagingProfileId", + ], + }, + phoneNumber: { + optional: true, + propDefinition: [ + telnyxApp, + "phoneNumber", + ], + }, + to: { + type: "string", + label: "To", + description: "Receiving address (+E.164 formatted phone number or short code).", + }, + text: { + type: "string", + label: "Text", + description: "Message content. Must be a valid UTF-8 string, and no longer than 1600 characters for SMS or 5MB for MMS. Required if sending an SMS message.", + optional: true, + }, + subject: { + type: "string", + label: "Subject", + description: "Subject of the MMS message.", + optional: true, + }, + mediaUrls: { + type: "string[]", + label: "Media URLs", + description: "URLs of media files to send with the message.", + optional: true, + }, + webhookUrl: { + type: "string", + label: "Webhook URL", + description: "URL to send delivery receipts to. Must be a valid URL.", + optional: true, + }, + webhookFailoverUrl: { + type: "string", + label: "Webhook Failover URL", + description: "URL to send delivery receipts to if the primary webhook fails. Must be a valid URL.", + optional: true, + }, + useProfileWebhooks: { + type: "boolean", + label: "Use Profile Webhooks", + description: "Whether to use the messaging profile's webhook URL for delivery receipts.", + optional: true, + }, + type: { + type: "string", + label: "Type", + description: "Type of message to sent.", + optional: true, + options: ["SMS", "MMS"], + }, + autoDetect: { + type: "boolean", + label: "Auto Detect", + description: "Automatically detect if an SMS message is unusually long and exceeds a recommended limit of message parts.", + optional: true, + }, }, - to: { - type: "string", - label: "To", - description: "Receiving address (+E.164 formatted phone number or short code).", + async run({ $ }) { + const response = await this.telnyxApp.sendMessage({ + $, + data: { + to: this.to, + from: this.phoneNumber, + text: this.text, + messaging_profile_id: this.messagingProfileId, + subject: this.subject, + media_urls: this.mediaUrls, + webhook_url: this.webhookUrl, + webhook_failover_url: this.webhookFailoverUrl, + use_profile_webhooks: this.useProfileWebhooks, + type: this.type, + auto_detect: this.autoDetect, + }, + }); + $.export("$summary", `Successfully sent SMS/MMS message with Id: ${response.data.id}`); + return response; }, - from: { - type: "string", - label: "From", - description: "Sending address (+E.164 formatted phone number or short code). Required if sending with a phone number, short code, or alphanumeric sender ID. See [Sending a message on the Telnyx platform](https://developers.telnyx.com/docs/messaging/messages/send-message) for more details.", - optional: true, - }, - text: { - type: "string", - label: "Text", - description: "Message content. Must be a valid UTF-8 string, and no longer than 1600 characters for SMS or 5MB for MMS. Required if sending an SMS message.", - optional: true, - }, - subject: { - type: "string", - label: "Subject", - description: "Subject of the MMS message.", - optional: true, - }, - mediaUrls: { - type: "string[]", - label: "Media URLs", - description: "URLs of media files to send with the message.", - optional: true, - }, - webhookUrl: { - type: "string", - label: "Webhook URL", - description: "URL to send delivery receipts to. Must be a valid URL.", - optional: true, - }, - webhookFailoverUrl: { - type: "string", - label: "Webhook Failover URL", - description: "URL to send delivery receipts to if the primary webhook fails. Must be a valid URL.", - optional: true, - }, - useProfileWebhooks: { - type: "boolean", - label: "Use Profile Webhooks", - description: "Whether to use the messaging profile's webhook URL for delivery receipts.", - optional: true, - }, - type: { - type: "string", - label: "Type", - description: "Type of message to sent.", - optional: true, - options: [ - "SMS", - "MMS", - ], - }, - autoDetect: { - type: "boolean", - label: "Auto Detect", - description: "Automatically detect if an SMS message is unusually long and exceeds a recommended limit of message parts.", - optional: true, - }, - }, - async run({ $ }) { - const response = await this.telnyxApp.sendMessage({ - $, - data: { - to: this.to, - from: this.from, - text: this.text, - messaging_profile_id: this.messaging_profile_id, - subject: this.subject, - media_urls: this.mediaUrls, - webhook_url: this.webhookUrl, - webhook_failover_url: this.webhookFailoverUrl, - use_profile_webhooks: this.useProfileWebhooks, - type: this.type, - auto_detect: this.autoDetect, - }, - }); - $.export("$summary", `Successfully sent SMS/MMS message with Id: ${response.data.id}`); - return response; - }, -}; +} \ No newline at end of file diff --git a/components/telnyx/common/constants.mjs b/components/telnyx/common/constants.mjs new file mode 100644 index 0000000000000..1fdd52bef7855 --- /dev/null +++ b/components/telnyx/common/constants.mjs @@ -0,0 +1,30 @@ + +const phoneNumberStatus = { + 'PURCHASE PENDING': "purchase_pending", + 'PURCHASE FAILED': "purchase_failed", + 'PORT PENDING': "port_pending", + 'ACTIVE': "active", + 'DELETED': "deleted", + 'PORT FAILED': "port_failed", + 'EMERGENCY ONLY': "emergency_only", + 'PORTED OUT': "ported_out", + 'PORT OUT PENDING': "port_out_pending", +}; + +const paymentMethods = { + 'PAY PER MINUTE': "pay-per-minute", + 'CHANNEL': "channel", +}; + +const sortPhoneNumbers = { + 'PURCHASED AT': "purchased_at", + 'PHONE NUMBER': "phone_number", + 'CONNECTION NAME': "connection_name", + 'USAGE PAYMENT METHOD': "usage_payment_method", +}; +export default { + phoneNumberStatus, + paymentMethods, + sortPhoneNumbers, +}; + \ No newline at end of file diff --git a/components/telnyx/telnyx.app.mjs b/components/telnyx/telnyx.app.mjs index c1fd76aa2abb1..3d55e958e0a41 100644 --- a/components/telnyx/telnyx.app.mjs +++ b/components/telnyx/telnyx.app.mjs @@ -21,6 +21,23 @@ export default { })); }, }, + phoneNumber: { + type: "string", + label: "Phone Number", + description: "The phone number to send the message from.", + async options({ page }) { + const params = { + 'page[number]': page || 1, + }; + const phoneNumbers = await this.getPhoneNumbers({ + params, + }); + return phoneNumbers.data.map((phoneNumber) => ({ + label: phoneNumber.phone_number, + value: phoneNumber.phone_number, + })); + } + }, }, methods: { // this.$auth contains connected account data @@ -71,5 +88,11 @@ export default { ...args, }); }, + async getPhoneNumbers(args) { + return this.makeRequest({ + path: "/phone_numbers", + ...args, + }); + }, }, }; From d6787f6a0203c3479907dcce8b2d7120790dd74a Mon Sep 17 00:00:00 2001 From: Marcelo Jabali Date: Fri, 26 Apr 2024 14:31:17 -0700 Subject: [PATCH 2/9] Adjusted component/action versions --- .../telnyx/actions/get-phone-numbers/get-phone-numbers.mjs | 2 +- components/telnyx/actions/send-message/send-message.mjs | 2 +- components/telnyx/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/telnyx/actions/get-phone-numbers/get-phone-numbers.mjs b/components/telnyx/actions/get-phone-numbers/get-phone-numbers.mjs index d011f7ceae7da..48ad9f3aa9460 100644 --- a/components/telnyx/actions/get-phone-numbers/get-phone-numbers.mjs +++ b/components/telnyx/actions/get-phone-numbers/get-phone-numbers.mjs @@ -5,7 +5,7 @@ export default { key: "telnyx-get-phone-numbers", name: "Get Phone Numbers", description: "Get a list of phone numbers. See documentation [here](https://developers.telnyx.com/api/numbers/list-phone-numbers)", - version: "0.1.8", + version: "0.0.1", type: "action", props: { telnyxApp, diff --git a/components/telnyx/actions/send-message/send-message.mjs b/components/telnyx/actions/send-message/send-message.mjs index 80429534d4813..5133e5c17bfa9 100644 --- a/components/telnyx/actions/send-message/send-message.mjs +++ b/components/telnyx/actions/send-message/send-message.mjs @@ -4,7 +4,7 @@ export default { key: "telnyx-send-message", name: "Send Message", description: "Send an SMS or MMS message. See documentation [here](https://developers.telnyx.com/docs/messaging/messages/send-message)", - version: "0.1.14", + version: "0.0.2", type: "action", props: { telnyxApp, diff --git a/components/telnyx/package.json b/components/telnyx/package.json index ecf3b91d43af0..0d577ce6505ee 100644 --- a/components/telnyx/package.json +++ b/components/telnyx/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/telnyx", - "version": "0.1.0", + "version": "0.2.0", "description": "Pipedream Telnyx Components", "main": "telnyx.app.mjs", "keywords": [ From 59041dd88ed85b07014ecbda7464b70a71cf54a0 Mon Sep 17 00:00:00 2001 From: Marcelo Jabali Date: Fri, 26 Apr 2024 14:52:19 -0700 Subject: [PATCH 3/9] eslint --- .../get-phone-numbers/get-phone-numbers.mjs | 34 ++-- .../actions/send-message/send-message.mjs | 191 +++++++++--------- components/telnyx/telnyx.app.mjs | 4 +- 3 files changed, 116 insertions(+), 113 deletions(-) diff --git a/components/telnyx/actions/get-phone-numbers/get-phone-numbers.mjs b/components/telnyx/actions/get-phone-numbers/get-phone-numbers.mjs index 48ad9f3aa9460..2ffac21b05411 100644 --- a/components/telnyx/actions/get-phone-numbers/get-phone-numbers.mjs +++ b/components/telnyx/actions/get-phone-numbers/get-phone-numbers.mjs @@ -112,26 +112,26 @@ export default { const phoneNumbers = await this.telnyxApp.getPhoneNumbers({ $, params: { - 'page[size]': this.pageSize || 20, - 'page[number]': this.pageNumber || 1, - 'filter[tag]': this.tag, - 'filter[phone_number]': this.phoneNumber, - 'filter[status]': this.status, - 'filter[connection_id]': this.connectionId, - 'filter[voice.connection_name][contains]': this.contains, - 'filter[voice.connection_name][starts_with]': this.startsWith, - 'filter[voice.connection_name][ends_with]': this.endsWith, - 'filter[voice.connection_name][eq]': this.equals, - 'filter[voice.usage_payment_method]': this.paymentMethod, - 'filter[billing_group_id]': this.billingGroupId, - 'filter[emergency_address_id]': this.emergencyAddressId, - 'filter[customer_reference]': this.customerReference, - sort: this.sort, + "page[size]": this.pageSize || 20, + "page[number]": this.pageNumber || 1, + "filter[tag]": this.tag, + "filter[phone_number]": this.phoneNumber, + "filter[status]": this.status, + "filter[connection_id]": this.connectionId, + "filter[voice.connection_name][contains]": this.contains, + "filter[voice.connection_name][starts_with]": this.startsWith, + "filter[voice.connection_name][ends_with]": this.endsWith, + "filter[voice.connection_name][eq]": this.equals, + "filter[voice.usage_payment_method]": this.paymentMethod, + "filter[billing_group_id]": this.billingGroupId, + "filter[emergency_address_id]": this.emergencyAddressId, + "filter[customer_reference]": this.customerReference, + "sort": this.sort, }, }); $.export("$summary", `Successfully retrieved ${phoneNumbers.data.length} phone number${phoneNumbers.data.length === 1 - ? "" - : "s"}.`); + ? "" + : "s"}.`); return phoneNumbers; }, }; diff --git a/components/telnyx/actions/send-message/send-message.mjs b/components/telnyx/actions/send-message/send-message.mjs index 5133e5c17bfa9..dce66dda9e876 100644 --- a/components/telnyx/actions/send-message/send-message.mjs +++ b/components/telnyx/actions/send-message/send-message.mjs @@ -1,100 +1,103 @@ import telnyxApp from "../../telnyx.app.mjs"; export default { - key: "telnyx-send-message", - name: "Send Message", - description: "Send an SMS or MMS message. See documentation [here](https://developers.telnyx.com/docs/messaging/messages/send-message)", - version: "0.0.2", - type: "action", - props: { + key: "telnyx-send-message", + name: "Send Message", + description: "Send an SMS or MMS message. See documentation [here](https://developers.telnyx.com/docs/messaging/messages/send-message)", + version: "0.0.2", + type: "action", + props: { + telnyxApp, + messagingProfileId: { + optional: true, + propDefinition: [ telnyxApp, - messagingProfileId: { - optional: true, - propDefinition: [ - telnyxApp, - "messagingProfileId", - ], - }, - phoneNumber: { - optional: true, - propDefinition: [ - telnyxApp, - "phoneNumber", - ], - }, - to: { - type: "string", - label: "To", - description: "Receiving address (+E.164 formatted phone number or short code).", - }, - text: { - type: "string", - label: "Text", - description: "Message content. Must be a valid UTF-8 string, and no longer than 1600 characters for SMS or 5MB for MMS. Required if sending an SMS message.", - optional: true, - }, - subject: { - type: "string", - label: "Subject", - description: "Subject of the MMS message.", - optional: true, - }, - mediaUrls: { - type: "string[]", - label: "Media URLs", - description: "URLs of media files to send with the message.", - optional: true, - }, - webhookUrl: { - type: "string", - label: "Webhook URL", - description: "URL to send delivery receipts to. Must be a valid URL.", - optional: true, - }, - webhookFailoverUrl: { - type: "string", - label: "Webhook Failover URL", - description: "URL to send delivery receipts to if the primary webhook fails. Must be a valid URL.", - optional: true, - }, - useProfileWebhooks: { - type: "boolean", - label: "Use Profile Webhooks", - description: "Whether to use the messaging profile's webhook URL for delivery receipts.", - optional: true, - }, - type: { - type: "string", - label: "Type", - description: "Type of message to sent.", - optional: true, - options: ["SMS", "MMS"], - }, - autoDetect: { - type: "boolean", - label: "Auto Detect", - description: "Automatically detect if an SMS message is unusually long and exceeds a recommended limit of message parts.", - optional: true, - }, + "messagingProfileId", + ], }, - async run({ $ }) { - const response = await this.telnyxApp.sendMessage({ - $, - data: { - to: this.to, - from: this.phoneNumber, - text: this.text, - messaging_profile_id: this.messagingProfileId, - subject: this.subject, - media_urls: this.mediaUrls, - webhook_url: this.webhookUrl, - webhook_failover_url: this.webhookFailoverUrl, - use_profile_webhooks: this.useProfileWebhooks, - type: this.type, - auto_detect: this.autoDetect, - }, - }); - $.export("$summary", `Successfully sent SMS/MMS message with Id: ${response.data.id}`); - return response; + phoneNumber: { + optional: true, + propDefinition: [ + telnyxApp, + "phoneNumber", + ], + }, + to: { + type: "string", + label: "To", + description: "Receiving address (+E.164 formatted phone number or short code).", + }, + text: { + type: "string", + label: "Text", + description: "Message content. Must be a valid UTF-8 string, and no longer than 1600 characters for SMS or 5MB for MMS. Required if sending an SMS message.", + optional: true, + }, + subject: { + type: "string", + label: "Subject", + description: "Subject of the MMS message.", + optional: true, + }, + mediaUrls: { + type: "string[]", + label: "Media URLs", + description: "URLs of media files to send with the message.", + optional: true, + }, + webhookUrl: { + type: "string", + label: "Webhook URL", + description: "URL to send delivery receipts to. Must be a valid URL.", + optional: true, + }, + webhookFailoverUrl: { + type: "string", + label: "Webhook Failover URL", + description: "URL to send delivery receipts to if the primary webhook fails. Must be a valid URL.", + optional: true, + }, + useProfileWebhooks: { + type: "boolean", + label: "Use Profile Webhooks", + description: "Whether to use the messaging profile's webhook URL for delivery receipts.", + optional: true, + }, + type: { + type: "string", + label: "Type", + description: "Type of message to sent.", + optional: true, + options: [ + "SMS", + "MMS", + ], + }, + autoDetect: { + type: "boolean", + label: "Auto Detect", + description: "Automatically detect if an SMS message is unusually long and exceeds a recommended limit of message parts.", + optional: true, }, -} \ No newline at end of file + }, + async run({ $ }) { + const response = await this.telnyxApp.sendMessage({ + $, + data: { + to: this.to, + from: this.phoneNumber, + text: this.text, + messaging_profile_id: this.messagingProfileId, + subject: this.subject, + media_urls: this.mediaUrls, + webhook_url: this.webhookUrl, + webhook_failover_url: this.webhookFailoverUrl, + use_profile_webhooks: this.useProfileWebhooks, + type: this.type, + auto_detect: this.autoDetect, + }, + }); + $.export("$summary", `Successfully sent SMS/MMS message with Id: ${response.data.id}`); + return response; + }, +}; diff --git a/components/telnyx/telnyx.app.mjs b/components/telnyx/telnyx.app.mjs index 3d55e958e0a41..6c5792098e4dc 100644 --- a/components/telnyx/telnyx.app.mjs +++ b/components/telnyx/telnyx.app.mjs @@ -27,7 +27,7 @@ export default { description: "The phone number to send the message from.", async options({ page }) { const params = { - 'page[number]': page || 1, + "page[number]": page || 1, }; const phoneNumbers = await this.getPhoneNumbers({ params, @@ -36,7 +36,7 @@ export default { label: phoneNumber.phone_number, value: phoneNumber.phone_number, })); - } + }, }, }, methods: { From 1062ac8cade9e956af5f8465ac7c6b5e7cd39bcb Mon Sep 17 00:00:00 2001 From: Marcelo Jabali Date: Fri, 26 Apr 2024 16:33:19 -0700 Subject: [PATCH 4/9] Updated constants file --- components/telnyx/telnyx.app.mjs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/components/telnyx/telnyx.app.mjs b/components/telnyx/telnyx.app.mjs index 6c5792098e4dc..37de1151876dd 100644 --- a/components/telnyx/telnyx.app.mjs +++ b/components/telnyx/telnyx.app.mjs @@ -10,7 +10,7 @@ export default { description: "The Id of the messaging profile to use for sending the message.", async options({ page }) { const params = { - "page[number]": page || 1, + "page[number]": page + 1, }; const profiles = await this.getMessagingProfiles({ params, @@ -27,7 +27,7 @@ export default { description: "The phone number to send the message from.", async options({ page }) { const params = { - "page[number]": page || 1, + "page[number]": page + 1, }; const phoneNumbers = await this.getPhoneNumbers({ params, @@ -40,10 +40,6 @@ export default { }, }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); - }, getHeaders() { return { "Content-Type": "application/json", From 2a82c3750ddb28eb83d098b08223236ba991407e Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 29 Apr 2024 10:57:06 -0400 Subject: [PATCH 5/9] constants.mjs --- components/telnyx/common/constants.mjs | 38 ++++++++++++-------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/components/telnyx/common/constants.mjs b/components/telnyx/common/constants.mjs index 1fdd52bef7855..c0f1ce71481f3 100644 --- a/components/telnyx/common/constants.mjs +++ b/components/telnyx/common/constants.mjs @@ -1,30 +1,28 @@ - const phoneNumberStatus = { - 'PURCHASE PENDING': "purchase_pending", - 'PURCHASE FAILED': "purchase_failed", - 'PORT PENDING': "port_pending", - 'ACTIVE': "active", - 'DELETED': "deleted", - 'PORT FAILED': "port_failed", - 'EMERGENCY ONLY': "emergency_only", - 'PORTED OUT': "ported_out", - 'PORT OUT PENDING': "port_out_pending", + "PURCHASE PENDING": "purchase_pending", + "PURCHASE FAILED": "purchase_failed", + "PORT PENDING": "port_pending", + "ACTIVE": "active", + "DELETED": "deleted", + "PORT FAILED": "port_failed", + "EMERGENCY ONLY": "emergency_only", + "PORTED OUT": "ported_out", + "PORT OUT PENDING": "port_out_pending", }; const paymentMethods = { - 'PAY PER MINUTE': "pay-per-minute", - 'CHANNEL': "channel", + "PAY PER MINUTE": "pay-per-minute", + "CHANNEL": "channel", }; const sortPhoneNumbers = { - 'PURCHASED AT': "purchased_at", - 'PHONE NUMBER': "phone_number", - 'CONNECTION NAME': "connection_name", - 'USAGE PAYMENT METHOD': "usage_payment_method", + "PURCHASED AT": "purchased_at", + "PHONE NUMBER": "phone_number", + "CONNECTION NAME": "connection_name", + "USAGE PAYMENT METHOD": "usage_payment_method", }; export default { - phoneNumberStatus, - paymentMethods, - sortPhoneNumbers, + phoneNumberStatus, + paymentMethods, + sortPhoneNumbers, }; - \ No newline at end of file From 8a09c1a2002fcd15fea16bbf1c54b85af295da75 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Mon, 29 Apr 2024 11:02:17 -0400 Subject: [PATCH 6/9] version --- .../actions/get-messaging-profiles/get-messaging-profiles.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/telnyx/actions/get-messaging-profiles/get-messaging-profiles.mjs b/components/telnyx/actions/get-messaging-profiles/get-messaging-profiles.mjs index 11e8b7534927a..fea939174410f 100644 --- a/components/telnyx/actions/get-messaging-profiles/get-messaging-profiles.mjs +++ b/components/telnyx/actions/get-messaging-profiles/get-messaging-profiles.mjs @@ -4,7 +4,7 @@ export default { key: "telnyx-get-messaging-profiles", name: "Get Messaging Profiles", description: "Get a list of messaging profiles. See documentation [here](https://developers.telnyx.com/api/messaging/list-messaging-profiles)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { telnyxApp, From 3a41581e774e88d6c4a52a09eab44f78355a098e Mon Sep 17 00:00:00 2001 From: Marcelo Jabali Date: Tue, 30 Apr 2024 10:07:05 -0700 Subject: [PATCH 7/9] Added Retrieve Message action --- .../actions/get-message/get-message.mjs | 27 +++++++++++++++++++ components/telnyx/telnyx.app.mjs | 5 ++++ 2 files changed, 32 insertions(+) create mode 100644 components/telnyx/actions/get-message/get-message.mjs diff --git a/components/telnyx/actions/get-message/get-message.mjs b/components/telnyx/actions/get-message/get-message.mjs new file mode 100644 index 0000000000000..750be59c35406 --- /dev/null +++ b/components/telnyx/actions/get-message/get-message.mjs @@ -0,0 +1,27 @@ +import telnyxApp from "../../telnyx.app.mjs"; + +export default { + key: "telnyx-get-message", + name: "Retrieve a Message", + description: "Retrieve a message. See documentation [here](https://developers.telnyx.com/api/messaging/get-message)", + version: "0.0.1", + type: "action", + props: { + telnyxApp, + id: { + type: "string", + label: "Message Id", + description: "The id of the message.", + }, + }, + async run({ $ }) { + const message = await this.telnyxApp.getMessage({ + $, + params: { + id: this.id, + }, + }); + $.export("$summary", `Successfully retrieved message ${message.data.id}.`); + return message; + }, +}; diff --git a/components/telnyx/telnyx.app.mjs b/components/telnyx/telnyx.app.mjs index 37de1151876dd..6d5e05e04a68d 100644 --- a/components/telnyx/telnyx.app.mjs +++ b/components/telnyx/telnyx.app.mjs @@ -90,5 +90,10 @@ export default { ...args, }); }, + async getMessage(args) { + return this.makeRequest({ + path: `/messages/${args.params.id}`, + }); + }, }, }; From 5375d8153b97fdb88fc50888fba541a1067bacf7 Mon Sep 17 00:00:00 2001 From: Marcelo Jabali Date: Thu, 2 May 2024 08:50:30 -0700 Subject: [PATCH 8/9] Fixed error message details --- components/telnyx/telnyx.app.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/telnyx/telnyx.app.mjs b/components/telnyx/telnyx.app.mjs index 6d5e05e04a68d..0246607d12197 100644 --- a/components/telnyx/telnyx.app.mjs +++ b/components/telnyx/telnyx.app.mjs @@ -69,7 +69,7 @@ export default { }, throwFormattedError(error) { error = error.response; - throw new Error(`${error.status} - ${error.statusText} - ${error.data.message}`); + throw new Error(`${error.status} - ${error.statusText} - ${error.data.errors[0].detail}`); }, async sendMessage(args) { return this.makeRequest({ From fbea0b1eb11c57a5e6f26a1e4424fc1bcc398a4c Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Fri, 3 May 2024 11:46:08 -0400 Subject: [PATCH 9/9] versions --- components/telnyx/actions/get-message/get-message.mjs | 2 +- .../telnyx/actions/send-group-message/send-group-message.mjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/telnyx/actions/get-message/get-message.mjs b/components/telnyx/actions/get-message/get-message.mjs index 750be59c35406..504602a73e211 100644 --- a/components/telnyx/actions/get-message/get-message.mjs +++ b/components/telnyx/actions/get-message/get-message.mjs @@ -4,7 +4,7 @@ export default { key: "telnyx-get-message", name: "Retrieve a Message", description: "Retrieve a message. See documentation [here](https://developers.telnyx.com/api/messaging/get-message)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { telnyxApp, diff --git a/components/telnyx/actions/send-group-message/send-group-message.mjs b/components/telnyx/actions/send-group-message/send-group-message.mjs index b1079effe0944..ab22be9c28196 100644 --- a/components/telnyx/actions/send-group-message/send-group-message.mjs +++ b/components/telnyx/actions/send-group-message/send-group-message.mjs @@ -4,7 +4,7 @@ export default { key: "telnyx-send-group-message", name: "Send Group Message", description: "Send a group MMS message. See documentation [here](https://developers.telnyx.com/api/messaging/create-group-mms-message)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { telnyxApp,