@sinch/voice 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 +17 -11
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -41,15 +41,20 @@ import {
41
41
  TtsCalloutRequestData,
42
42
  GetCalloutResponseObj,
43
43
  SinchClient,
44
- ApplicationCredentials,
44
+ ApplicationCredentials,
45
+ VoiceService,
45
46
  } from '@sinch/sdk-core';
46
47
 
47
48
  const credentials: ApplicationCredentials = {
48
49
  applicationKey: 'APPLICATION_ID',
49
50
  applicationSecret: 'APPLICATION_SECRET',
50
51
  };
52
+
53
+ // Access the 'voice' service registered on the Sinch Client
51
54
  const sinch = new SinchClient(credentials);
55
+ const voiceService: VoiceService = sinch.voice;
52
56
 
57
+ // Build the request data
53
58
  const requestData: TtsCalloutRequestData = {
54
59
  ttsCalloutRequestBody: {
55
60
  method: 'ttsCallout',
@@ -65,9 +70,9 @@ const requestData: TtsCalloutRequestData = {
65
70
  },
66
71
  };
67
72
 
68
- // Access the 'voice' controller registered on the Sinch Client
69
- const calloutResponse: GetCalloutResponseObj
70
- = await sinch.voice.callouts.tts(requestData);
73
+ // Use the 'voice' service registered on the Sinch client
74
+ const calloutResponse: GetCalloutResponseObj
75
+ = await voiceService.callouts.tts(requestData);
71
76
  ```
72
77
 
73
78
  ### Standalone
@@ -81,7 +86,7 @@ import {
81
86
  import {
82
87
  TtsCalloutRequestData,
83
88
  GetCalloutResponseObj,
84
- Voice,
89
+ VoiceService,
85
90
  } from '@sinch/voice';
86
91
 
87
92
  const credentials: ApplicationCredentials = {
@@ -89,9 +94,10 @@ const credentials: ApplicationCredentials = {
89
94
  applicationSecret: 'APPLICATION_SECRET',
90
95
  };
91
96
 
92
- // Declare the 'voice' controller in a standalone way
93
- const voice = new Voice(credentials);
97
+ // Declare the 'voice' service in a standalone way
98
+ const voiceService = new VoiceService(credentials);
94
99
 
100
+ // Build the request data
95
101
  const requestData: TtsCalloutRequestData = {
96
102
  ttsCalloutRequestBody: {
97
103
  method: 'ttsCallout',
@@ -107,9 +113,9 @@ const requestData: TtsCalloutRequestData = {
107
113
  },
108
114
  };
109
115
 
110
- // Use the standalone declaration of the 'voice' controller
116
+ // Use the standalone declaration of the 'voice' service
111
117
  const calloutResponse: GetCalloutResponseObj
112
- = await voice.callouts.tts(requestData);
118
+ = await voiceService.callouts.tts(requestData);
113
119
  ```
114
120
 
115
121
  ## Promises
@@ -120,14 +126,14 @@ All the methods that interact with the Sinch APIs use Promises. You can use `awa
120
126
  // Method 1: Wait for the Promise to complete (you need to be in an 'async' method)
121
127
  let calloutResponse: GetCalloutResponseObj;
122
128
  try {
123
- calloutResponse = await sinch.voice.callouts.tts(requestData);
129
+ calloutResponse = await voiceService.callouts.tts(requestData);
124
130
  console.log(`callId = ${calloutResponse.callId}`);
125
131
  } catch (error: any) {
126
132
  console.error(`ERROR ${error.statusCode}: Impossible to make a TTS callout to the number ${requestData.ttsCalloutRequestBody.ttsCallout.destination.endpoint}`);
127
133
  }
128
134
 
129
135
  // Method 2: Resolve the promise
130
- sinch.voice.callouts.tts(requestData)
136
+ voiceService.callouts.tts(requestData)
131
137
  .then(response => console.log(`callId = ${response.callId}`))
132
138
  .catch(error => console.error(`ERROR ${error.statusCode}: Impossible to make a TTS call out to the number ${requestData.ttsCalloutRequestBody.ttsCallout.destination.endpoint}`));
133
139
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sinch/voice",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Sinch Voice 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 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": {