@verdocs/js-sdk 3.8.4 → 3.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,11 +20,11 @@ export declare const deleteOrganization: (endpoint: VerdocsEndpoint, organizatio
20
20
  /**
21
21
  * Get an organization by ID.
22
22
  */
23
- export declare const getOrganization: (endpoint: VerdocsEndpoint, organizationId: string) => Promise<any>;
23
+ export declare const getOrganization: (endpoint: VerdocsEndpoint, organizationId: string) => Promise<IOrganization>;
24
24
  /**
25
25
  * Update an organization.
26
26
  */
27
- export declare const updateOrganization: (endpoint: VerdocsEndpoint, organizationId: string, params: any) => Promise<any>;
27
+ export declare const updateOrganization: (endpoint: VerdocsEndpoint, organizationId: string, params: any) => Promise<IOrganization>;
28
28
  /**
29
29
  * Check if an organization name is available. Typically used during the sign-up process. This endpoint is rate-limited
30
30
  * to prevent abuse. Developers experiencing problems with testing new applications should contact support.
@@ -2,3 +2,8 @@
2
2
  * Capitalize the first letter of a string.
3
3
  */
4
4
  export declare const capitalize: (str: string) => string;
5
+ /**
6
+ * Convert a phone-number-like string to E164 format.
7
+ * @see https://46elks.com/kb/e164
8
+ */
9
+ export declare const convertToE164: (input: string) => string;
package/Utils/Strings.js CHANGED
@@ -2,3 +2,27 @@
2
2
  * Capitalize the first letter of a string.
3
3
  */
4
4
  export var capitalize = function (str) { return str.charAt(0).toUpperCase() + str.slice(1); };
5
+ /**
6
+ * Convert a phone-number-like string to E164 format.
7
+ * @see https://46elks.com/kb/e164
8
+ */
9
+ export var convertToE164 = function (input) {
10
+ // "(212) 555-1212" => +12125551212
11
+ // "+46766861004" => "+46766861004"
12
+ // "212-555-1212" => +12125551212
13
+ // "212.555.1212" => +12125551212
14
+ // "212 555 1212" => +12125551212
15
+ var temp = (input || '').trim();
16
+ // If we are already prefixed, assume the user did it deliberately and attempt to use what they entered. We also short-circuit blanks.
17
+ if (!temp || temp.startsWith('+')) {
18
+ return temp;
19
+ }
20
+ // Remove any spaces, parenthesis or other punctuation.
21
+ temp = temp.replace(/[^0-9]/g, '');
22
+ // If the number begins with a zero, remove the leading zero. Do not combine this with the previous step because it needs to be removed
23
+ // whether it's the actual first character e.g. `0(5)` or just the first digit e.g. `(05`.
24
+ temp = temp.replace(/^0/g, '');
25
+ // Prepend the country code and +. We're assuming US in this case given the target demographic. Users in other countries would/should be
26
+ // already entering a prefix so they'd shortcut out of this routine via the + prefix check.
27
+ return "+1".concat(temp);
28
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdocs/js-sdk",
3
- "version": "3.8.4",
3
+ "version": "3.8.6",
4
4
  "private": false,
5
5
  "homepage": "https://github.com/Verdocs/js-sdk",
6
6
  "description": "Verdocs JS SDK",