-
Notifications
You must be signed in to change notification settings - Fork 2
/
list-organizations.js
40 lines (32 loc) · 1.08 KB
/
list-organizations.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// The following import statements show how the API client code
// can be imported when using mix-cli as a dependency.
import {createMixClient} from '@nuance-mix/mix-cli/lib/mix/client.js'
import * as OrganizationsAPI from '@nuance-mix/mix-cli/lib/mix/api/organizations.js'
const mixAPIServer = 'mix.api.nuance.com'
// The access token needs to be provided.
// A library like simple-oauth2 available on npm can help with that.
const token = 'your_token_here'
const options = {
// Replace the value of userAgent with one relevant to your application.
userAgent: 'sdk-sample-client',
server: mixAPIServer,
}
const client = createMixClient(options)
client.setToken(token)
const response = await OrganizationsAPI.listOrganizations(client, {
showAll: true,
type: 'PERSONAL',
view: 'FULL',
})
switch (response._state) {
case 'success':
console.log(JSON.stringify(response.data, null, 2))
break
case 'mixFailure':
console.error(response.error.statusCode, response.error.message)
break
case 'connectionFailure':
default:
console.error(response.message)
break
}