@sinch/numbers 0.0.2 → 0.0.3

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.
Files changed (2) hide show
  1. package/README.md +14 -9
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -40,6 +40,7 @@ If you are using this SDK as part of the Sinch SDK (`@sinch/sdk-core`) you can a
40
40
  import {
41
41
  AvailableNumber,
42
42
  GetAvailableNumberRequestData,
43
+ NumbersService,
43
44
  SinchClient,
44
45
  UnifiedCredentials,
45
46
  } from '@sinch/sdk-core';
@@ -50,15 +51,18 @@ const credentials: UnifiedCredentials = {
50
51
  keySecret: 'KEY_SECRET',
51
52
  };
52
53
 
54
+ // Access the 'numbers' service registered on the Sinch Client
53
55
  const sinch = new SinchClient(credentials);
56
+ const numbersService: NumbersService = sinch.numbers;
54
57
 
58
+ // Build the request data
55
59
  const requestData: GetAvailableNumberRequestData = {
56
60
  phoneNumber: '+17813334444',
57
61
  };
58
62
 
59
- // Access the 'numbers' domain registered on the Sinch Client
63
+ // Use the 'numbers' service registered on the Sinch client
60
64
  const availabilityResult: AvailableNumber
61
- = await sinch.numbers.availableNumber.checkAvailability(requestData);
65
+ = await numbersService.availableNumber.checkAvailability(requestData);
62
66
  ```
63
67
 
64
68
  ### Standalone
@@ -72,7 +76,7 @@ import {
72
76
  import {
73
77
  AvailableNumber,
74
78
  GetAvailableNumberRequestData,
75
- Numbers,
79
+ NumbersService,
76
80
  } from '@sinch/numbers';
77
81
 
78
82
  const credentials: UnifiedCredentials = {
@@ -81,16 +85,17 @@ const credentials: UnifiedCredentials = {
81
85
  keySecret: 'KEY_SECRET',
82
86
  };
83
87
 
84
- // Declare the 'numbers' controller in a standalone way
85
- const numbers = new Numbers(credentials);
88
+ // Declare the 'numbers' service in a standalone way
89
+ const numbersService = new NumbersService(credentials);
86
90
 
91
+ // Build the request data
87
92
  const requestData: GetAvailableNumberRequestData = {
88
93
  phoneNumber: '+17813334444',
89
94
  };
90
95
 
91
- // Use the standalone declaration of the 'numbers' controller
96
+ // Use the standalone declaration of the 'numbers' service
92
97
  const availabilityResult: AvailableNumber
93
- = await numbers.availableNumber.checkAvailability(requestData);
98
+ = await numbersService.availableNumber.checkAvailability(requestData);
94
99
  ```
95
100
 
96
101
  ## Promises
@@ -101,14 +106,14 @@ All the methods that interact with the Sinch APIs use Promises. You can use `awa
101
106
  // Method 1: Wait for the Promise to complete (you need to be in an 'async' method)
102
107
  let availabilityResult: AvailableNumber;
103
108
  try {
104
- availabilityResult = await sinch.numbers.availableNumber.checkAvailability(requestData);
109
+ availabilityResult = await numbersService.availableNumber.checkAvailability(requestData);
105
110
  console.log(`Phone number: ${availabilityResult.phoneNumber} - Type: ${availabilityResult.type}`);
106
111
  } catch (error: any) {
107
112
  console.error(`ERROR ${error.statusCode}: the phone number ${requestData.phoneNumber} is not available`);
108
113
  }
109
114
 
110
115
  // Method 2: Resolve the promise
111
- sinch.numbers.availableNumber.checkAvailability(requestData)
116
+ numbersService.availableNumber.checkAvailability(requestData)
112
117
  .then(response => console.log(`Phone number: ${response.phoneNumber} - Type: ${response.type}`))
113
118
  .catch(error => console.error(`ERROR ${error.statusCode}: the phone number ${requestData.phoneNumber} is not available`));
114
119
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinch/numbers",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Sinch Numbers API",
5
5
  "homepage": "",
6
6
  "repository": {
@@ -28,7 +28,7 @@
28
28
  "compile": "tsc -p tsconfig.build.json && tsc -p tsconfig.tests.json && rimraf dist/tests && rimraf tsconfig.build.tsbuildinfo"
29
29
  },
30
30
  "dependencies": {
31
- "@sinch/sdk-client": "^0.0.2"
31
+ "@sinch/sdk-client": "^0.0.3"
32
32
  },
33
33
  "devDependencies": {},
34
34
  "publishConfig": {