forked from PipedreamHQ/pipedream
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
List Telnyx phone numbers (PipedreamHQ#11681)
- Loading branch information
Showing
6 changed files
with
201 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
components/telnyx/actions/get-phone-numbers/get-phone-numbers.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.0.1", | ||
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; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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", | ||
}; | ||
|
||
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, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters