diff --git a/list-numbers/Changelog.md b/list-numbers/Changelog.md new file mode 100644 index 00000000..b213e60f --- /dev/null +++ b/list-numbers/Changelog.md @@ -0,0 +1,9 @@ +# Changelog + +## [Unreleased] + +## [1.1.0] +### Added +- Added the feature to extract the list of numbers from all subaccounts and Main account at the same time +- Added the option to select the downloaded file format + diff --git a/list-numbers/assets/index.html b/list-numbers/assets/index.html index 1e3841f2..e05276d0 100644 --- a/list-numbers/assets/index.html +++ b/list-numbers/assets/index.html @@ -10,34 +10,8 @@ rel="icon" href="https://twilio-labs.github.io/function-templates/static/v1/favicon.ico" /> - - - - +
@@ -105,9 +79,9 @@

List Active numbers on your main accounts or subaccount

If you have a large amount of numbers on your account, the "List Numbers" request might timeout. Use Pagination if you have thousands of numbers on your account, and rely on the "Download - without listing numbers" button. Results listed on this page will be - limited to 200 numbers. "Download without listing numbers" button - has no limits. + without listing numbers" button. Results listed on this page will be + limited to 200 numbers. "Download without listing numbers" button has + no limits.

@@ -118,235 +92,326 @@

List Active numbers on your main accounts or subaccount

>Function - open the Function and click on "Environment Variables" in the bottom - left corner, and change the value of Password. Click "Deploy All" afterwards in the bottom left corner. + left corner, and change the value of Password. Click + "Deploy All" afterwards in the bottom left corner.
- The default Password is 1.

Password:
-

You are working with account:

-
-
-
-
- Select the Number Properties you want to see in the results: -
-
- accountSid - addressSid - addressRequirements - beta - bundleSid - capabilities - fax - capabilities voice - capabilities sms - capabilities - mms - dateCreated - dateUpdated - friendlyName - phoneNumber - sid - smsApplicationSid - smsFallbackMethod - smsFallbackUrl - smsMethod - smsUrl - status - statusCallback - statusCallbackMethod - trunkSid uri - voiceApplicationSid - voiceCallerIdLookup - voiceFallbackMethod - voiceFallbackUrl - voiceMethod - voiceUrl - emergencyStatus - emergencyAddressSid -
-
-

- Enter the subaccount SID. Leave empty if you want the list of - numbers on your main account. -

- -

- Only show results for numbers that start with (filter based on country-code): -

- -
+

You are working with account:

+
+
+
+
- Use Pagination? - - Maximum amount of numbers returned per page (1-1000): - +
+ Select the Number Properties you want to see in the results: +
+
+ accountSid + addressSid + addressRequirements + beta + bundleSid + capabilities fax + capabilities voice + capabilities sms + capabilities mms + dateCreated + dateUpdated + friendlyName + phoneNumber + sid + smsApplicationSid + smsFallbackMethod + smsFallbackUrl + smsMethod + smsUrl + status + statusCallback + statusCallbackMethod + trunkSid + uri + voiceApplicationSid + voiceCallerIdLookup + voiceFallbackMethod + voiceFallbackUrl + voiceMethod + voiceUrl + emergencyStatus + emergencyAddressSid
-
-
  - +
+

+ Enter the subaccount SID. Leave empty if you want the list of + numbers on your main account. +

+ +
+ +
+

+ Only show results for numbers that start with (filter based on + country-code): +

+ +
+
+ Use Pagination? + + Maximum amount of numbers returned per page (1-1000): + +
+

+
+ Select the format that will be used when the data is downloaded: +
+ +
+ +
+
+
+
+   + +
+
+
+ + +
+

+              
+ +
-

- -
-

-          
- -
-
- -
We can't wait to see what you build.
- - + \ No newline at end of file diff --git a/list-numbers/assets/styles.css b/list-numbers/assets/styles.css index de92476a..e8d43a22 100644 --- a/list-numbers/assets/styles.css +++ b/list-numbers/assets/styles.css @@ -22,3 +22,470 @@ pre { background-color: #f2dede; border-color: #ebccd1; } + +body { + margin: 0; + font-family: 'Inter var experimental', 'Inter var', -apple-system, + BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, + 'Helvetica Neue', sans-serif; + font-size: 16px; + line-height: 1.5rem; + color: rgb(18, 28, 45); + min-height: 100vh; + display: flex; + flex-direction: column; + justify-content: space-between; +} + +a { + color: rgb(2, 99, 224); +} + +a:visited { + color: rgb(2, 99, 224); +} + +ul { + padding: 0; + list-style-type: none; +} + +ol.steps { + counter-reset: step; + list-style-type: none; +} + +ol.steps > li::before { + counter-increment: step; + content: 'Step ' counter(step) ': '; + font-weight: 700; +} + +header { + display: flex; + color: white; + background: rgb(6, 3, 58); + width: 100%; + box-shadow: 0px 2px 6px 0px rgba(75, 86, 113, 0.2); + align-content: center; +} + +header > nav { + display: flex; + flex-direction: column; + padding-left: 2rem; + border-left: 1px solid rgba(255, 255, 255, 0.2); + padding-top: 0.75rem; + padding-bottom: 0.75rem; +} + +header > nav span { + font-weight: 400; +} + +header > nav aside { + color: rgb(200, 175, 240); + font-size: 0.75rem; +} + +header > nav svg { + width: 1rem; + height: 1rem; +} + +main { + display: flex; + flex-direction: row; + justify-content: center; + font-size: 0.875rem; +} + +div.page-top { + display: flex; + flex-direction: column; + width: 100%; +} + +div.content { + display: flex; + flex-direction: column; + max-width: 75%; +} + +footer { + display: flex; + flex-direction: row; + justify-content: center; + color: #94979b; + background: rgb(6, 3, 58); + box-shadow: 0px 2px 6px 0px rgba(75, 86, 113, 0.2); + padding: 50px 0; + margin-top: 2rem; +} + +footer .statement { + font-size: 45px; + font-style: italic; + line-height: 1.2; + text-align: center; +} + +form { + display: flex; + flex-direction: column; + justify-content: start; + margin-bottom: 0.5em; + padding: 0.5rem 0; +} + +label { + font-weight: 600; +} + +input[type='text'], +input[type='password'] { + font: inherit; + border-radius: 4px; + border: 1px solid rgb(136, 145, 170); + padding: 0.5rem; + width: 50%; +} + +input[type='tel'] { + padding-top: 0.5rem; + padding-bottom: 0.5rem; +} + +input[readonly='true'] { + background-color: rgb(244, 244, 246); +} + +input[type='submit'] { + cursor: pointer; + padding-top: 0.5rem; + padding-bottom: 0.5rem; + padding-left: 0.75rem; + padding-right: 0.75rem; + border: 1px solid; + border-radius: 4px; + margin-top: 1em; + font-size: 0.875rem; + line-height: 1.25rem; +} + +input.phone-number { + width: 15rem; +} + +#twilio-logo { + display: flex; + justify-content: center; + align-items: center; +} + +#twilio-logo > a { + display: block; + width: 50px; + height: 50px; + padding-left: 0.5rem; + padding-right: 0.5rem; +} + +#success-alert { + display: flex; + flex-direction: row; + justify-content: space-between; + background-color: rgb(235, 244, 255); + border-bottom: 2px solid rgb(2, 99, 224); + padding: 1em; + margin-top: 3em; + width: 75%; + align-self: center; +} + +h1, +h2, +h3, +h4, +h5, +h6 { + margin-bottom: 0; +} + +h1 { + display: flex; + flex-direction: row; + align-items: center; +} + +h1 > img { + margin: 2rem; +} + +.alert-title { + font-weight: 700; +} + +svg.icon { + display: inline-block; + width: 1rem; + height: 1rem; + vertical-align: -0.125rem; +} + +svg.information { + color: rgb(96, 107, 133); +} + +svg.close { + color: rgb(102, 106, 109); +} + +svg.logo { + fill: white; +} + +.button-primary { + box-sizing: border-box; + width: auto; + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + background: none; + background-color: rgba(0, 0, 0, 0); + display: inline-block; + border: none; + outline: none; + -webkit-transition: background-color 100ms ease-in, box-shadow 100ms ease-in, + color 100ms ease-in; + transition: background-color 100ms ease-in, box-shadow 100ms ease-in, + color 100ms ease-in; + font-family: 'Inter var experimental', 'Inter var', -apple-system, + BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, + 'Helvetica Neue', sans-serif; + font-weight: 600; + -webkit-text-decoration: none; + text-decoration: none; + position: relative; + margin: 0; + cursor: pointer; + color: rgb(255, 255, 255); + background-color: rgb(2, 99, 224); + box-shadow: 0 0 0 1px #0263e0; + padding-top: 0.5rem; + padding-bottom: 0.5rem; + padding-left: 0.75rem; + padding-right: 0.75rem; + border-radius: 4px; + font-size: 0.875rem; + line-height: 1.25rem; +} + +.button-primary:hover, +.button-primary:focus { + -webkit-text-decoration: none; + text-decoration: none; + color: rgb(255, 255, 255); + background-color: rgb(3, 11, 93); + box-shadow: 0 0 0 1px #030b5d; +} + +.button-destructive { + box-sizing: border-box; + width: auto; + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + background: none; + background-color: rgba(0, 0, 0, 0); + display: inline-block; + border: none; + outline: none; + -webkit-transition: background-color 100ms ease-in, box-shadow 100ms ease-in, + color 100ms ease-in; + transition: background-color 100ms ease-in, box-shadow 100ms ease-in, + color 100ms ease-in; + font-family: 'Inter var experimental', 'Inter var', -apple-system, + BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, + 'Helvetica Neue', sans-serif; + font-weight: 600; + -webkit-text-decoration: none; + text-decoration: none; + position: relative; + margin: 0; + cursor: pointer; + color: rgb(255, 255, 255); + background-color: rgba(214, 31, 31, 1); + box-shadow: 0 0 0 1px rgba(214, 31, 31, 1); + padding-top: 0.5rem; + padding-bottom: 0.5rem; + padding-left: 0.75rem; + padding-right: 0.75rem; + border-radius: 4px; + font-size: 0.875rem; + line-height: 1.25rem; +} + +.button-destructive:hover, +.button-destructive:focus { + -webkit-text-decoration: none; + text-decoration: none; + color: rgb(255, 255, 255); + background-color: rgb(156, 23, 23); + box-shadow: 0 0 0 1px rgb(156, 23, 23); +} + +/* + * From the Inter font CSS declaration file + */ + +/* ------------------------------------------------------- +Variable font. +Usage: + + html { font-family: 'Inter', sans-serif; } + @supports (font-variation-settings: normal) { + html { font-family: 'Inter var', sans-serif; } + } +*/ +@font-face { + font-family: 'Inter var'; + font-weight: 100 900; + font-display: swap; + font-style: normal; + font-named-instance: 'Regular'; + src: url('Inter-roman.var.woff2?v=3.15') format('woff2'); +} +@font-face { + font-family: 'Inter var'; + font-weight: 100 900; + font-display: swap; + font-style: italic; + font-named-instance: 'Italic'; + src: url('Inter-italic.var.woff2?v=3.15') format('woff2'); +} + +/* -------------------------------------------------------------------------- +[EXPERIMENTAL] Multi-axis, single variable font. + +Slant axis is not yet widely supported (as of February 2019) and thus this +multi-axis single variable font is opt-in rather than the default. + +When using this, you will probably need to set font-variation-settings +explicitly, e.g. + + * { font-variation-settings: "slnt" 0deg } + .italic { font-variation-settings: "slnt" 10deg } + +*/ +@font-face { + font-family: 'Inter var experimental'; + font-weight: 100 900; + font-display: swap; + font-style: oblique 0deg 10deg; + src: url('Inter.var.woff2?v=3.15') format('woff2'); +} + +/* +* Input Copy to Clipboard feature +*/ +.copy-input-wrapper { + -webkit-box-sizing: border-box; + box-sizing: border-box; + display: -webkit-box; + display: -ms-flexbox; + display: flex; + width: 100%; + background-color: rgb(244, 244, 246); + -webkit-box-shadow: rgb(136, 145, 170) 0px 0px 0px 1px; + box-shadow: rgb(136, 145, 170) 0px 0px 0px 1px; + border-radius: 4px; + -webkit-transition: -webkit-box-shadow 100ms ease-in 0s; + transition: -webkit-box-shadow 100ms ease-in 0s; + -o-transition: box-shadow 100ms ease-in 0s; + transition: box-shadow 100ms ease-in 0s; + transition: box-shadow 100ms ease-in 0s, -webkit-box-shadow 100ms ease-in 0s; + cursor: text; +} + +.copy-input-wrapper input { + -webkit-box-sizing: border-box; + box-sizing: border-box; + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + background-color: transparent; + border: none; + border-radius: 4px 0px 0px 4px; + display: block; + font-size: 0.875rem; + line-height: 1.25rem; + margin: 0px; + outline: none; + padding: 0.25rem 0.75rem; + resize: none; + width: 100%; + border-right: 1px solid rgb(225, 227, 234); +} + +.copy-input-wrapper button { + -webkit-box-sizing: border-box; + box-sizing: border-box; + position: relative; + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + width: auto; + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + background: rgba(0, 0, 0, 0) none repeat scroll 0% 0%; + border: none; + outline: currentcolor none medium; + margin: 0px; + cursor: pointer; + color: rgb(2, 99, 224); + padding: 0.6rem; + border-radius: 4px; +} + +.copy-input-wrapper button:hover { + cursor: pointer; + color: black; +} + +.copy-input-wrapper button:hover:before { + content: 'Copy'; + position: absolute; + top: -35px; + left: -5px; + padding: 6px 10px 7px; + color: white; + background-color: #141f2d; + border-radius: 4px; +} + +.copy-input-wrapper button:hover:after { + content: ''; + position: absolute; + top: -6px; + left: 15px; + display: block; + width: 0; + height: 0; + border-style: solid; + border-width: 5px 5px 0 5px; + border-color: #141f2d transparent transparent; +} + +.copy-input-wrapper.copied button:hover:before { + content: 'Copied!'; +} + +.copy-input-wrapper svg { + width: 22px; + height: 22px; +} diff --git a/list-numbers/functions/list_accounts.js b/list-numbers/functions/list_accounts.js new file mode 100644 index 00000000..50e43000 --- /dev/null +++ b/list-numbers/functions/list_accounts.js @@ -0,0 +1,56 @@ +exports.handler = async function (context, event, callback) { + let finalData = null; + let i = 0; + + const accountSid = process.env.ACCOUNT_SID; + const authToken = process.env.AUTH_TOKEN; + const client = require('twilio')(accountSid, authToken); + const response = new Twilio.Response(); + const allAccounts = []; + + response.appendHeader('Content-Type', 'application/json'); + + if (event.request.headers.authorization !== process.env.Password) { + finalData = { er: 0 }; + return callback(null, finalData); + } + + try { + if (event.pageSize > 0) { + sub = await client.api.v2010.accounts + .page({ + pageSize: event.pageSize, + Page: event.page, + pageToken: event.pageToken, + }) + .then((accounts) => { + for (a = 0; a < accounts.instances.length; a++) { + allAccounts[i] = accounts.instances[a].sid; + i += 1; + } + if (accounts.nextPageUrl === undefined) { + allAccounts[i] = 'end'; + } else { + allAccounts[i] = accounts.nextPageUrl.split('PageToken=')[1]; + } + }); + response.setStatusCode(200); + response.setBody(allAccounts); + } else { + sub = await client.api.v2010.accounts.list().then((accounts) => + accounts.forEach((a) => { + allAccounts[i] = a.sid; + i += 1; + }) + ); + response.setStatusCode(200); + response.setBody(allAccounts); + } + return callback(null, response); + } catch (error) { + console.error(error.message); + response.setStatusCode(error.status || 400); + response.setBody({ error: error.message }); + return callback(null, response); + } +}; diff --git a/list_accounts.js b/list_accounts.js new file mode 100644 index 00000000..50e43000 --- /dev/null +++ b/list_accounts.js @@ -0,0 +1,56 @@ +exports.handler = async function (context, event, callback) { + let finalData = null; + let i = 0; + + const accountSid = process.env.ACCOUNT_SID; + const authToken = process.env.AUTH_TOKEN; + const client = require('twilio')(accountSid, authToken); + const response = new Twilio.Response(); + const allAccounts = []; + + response.appendHeader('Content-Type', 'application/json'); + + if (event.request.headers.authorization !== process.env.Password) { + finalData = { er: 0 }; + return callback(null, finalData); + } + + try { + if (event.pageSize > 0) { + sub = await client.api.v2010.accounts + .page({ + pageSize: event.pageSize, + Page: event.page, + pageToken: event.pageToken, + }) + .then((accounts) => { + for (a = 0; a < accounts.instances.length; a++) { + allAccounts[i] = accounts.instances[a].sid; + i += 1; + } + if (accounts.nextPageUrl === undefined) { + allAccounts[i] = 'end'; + } else { + allAccounts[i] = accounts.nextPageUrl.split('PageToken=')[1]; + } + }); + response.setStatusCode(200); + response.setBody(allAccounts); + } else { + sub = await client.api.v2010.accounts.list().then((accounts) => + accounts.forEach((a) => { + allAccounts[i] = a.sid; + i += 1; + }) + ); + response.setStatusCode(200); + response.setBody(allAccounts); + } + return callback(null, response); + } catch (error) { + console.error(error.message); + response.setStatusCode(error.status || 400); + response.setBody({ error: error.message }); + return callback(null, response); + } +}; diff --git a/transfers/assets/index.html b/transfers/assets/index.html index c52e160e..b2c35c3a 100644 --- a/transfers/assets/index.html +++ b/transfers/assets/index.html @@ -10,22 +10,8 @@ rel="icon" href="https://twilio-labs.github.io/function-templates/static/v1/favicon.ico" /> - + - -