# wildix-pbx-sdk

> Wildix PBX SDK

Latest version **1.11.0** (published 2024-10-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install wildix-pbx-sdk
pnpm add wildix-pbx-sdk
yarn add wildix-pbx-sdk
bun add wildix-pbx-sdk
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.11.0 |
| Published | 2024-10-04 |
| First published | 2023-11-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.0.0 |
| Dependencies | 1 |
| Unpacked size | 117.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Wildix Web Team |
| Maintainers | vladimir.gorobets |
| Keywords | wildix, authorization, s2s, collaboration, sdk |

## Links

- npm: https://www.npmjs.com/package/wildix-pbx-sdk
- npm.io page: https://npm.io/package/wildix-pbx-sdk

## Dependencies (1)

- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^9.0.2

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 1.11.0 (latest) — 2024-10-04
- 1.10.2 — 2023-11-10
- 1.10.0 — 2023-11-06
- 1.9.1 — 2023-11-06
- 1.9.0 — 2023-11-05
- 1.8.1 — 2023-11-05
- 1.8.0 — 2023-11-05
- 1.7.0 — 2023-11-05
- 1.6.0 — 2023-11-05
- 1.5.0 — 2023-11-05
- 1.4.0 — 2023-11-04
- 1.3.0 — 2023-11-04
- 1.2.0 — 2023-11-04
- 1.1.0 — 2023-11-04

## README

# Wildix PBX SDK

Wildix PBX API library

### install

```bash
npm i wildix-pbx-sdk
```
or

```bash
yarn add wildix-pbx-sdk
```

### import classes

```ts
import {
  AuthService,
  BasicAuth,
  ColleagueFields,
  GetColleagueByIdRequest,
  GetColleaguesRequest,
  GetUserPersonalInfoRequest,
  GetUserPersonalTokenRequest,
  JwtTokenAuth,
  PbxClient,
  PbxFetchError,
  S2sAuth,
  UpdateColleagueByIdRequest,
  AuthDomains
} from 'wildix-pbx-sdk';
```

### Create PbxClient instance

with **Basic** authorization

```ts
const pbxClient = new PbxClient({
    pbxDomain: 'pbx-domain',
    userAuth: new BasicAuth({
        extension: '100',
        password: 'password',
    })
});
```

or **JWT token** authorization

```ts
const pbxClient = new PbxClient({
    pbxDomain: 'pbx-domain',
    userAuth: new JwtTokenAuth({
        token: 'access_JPn9oXg8LDVSdcwsCpeKqFXL89.....',
        type: 'simple',
    })
});
```

or **Server2Server** (s2s) authorization

```ts
const pbxClient = new PbxClient({
    pbxDomain: 'pbx-domain',
    userAuth: new S2sAuth({
        appId: 's2s-app-id',
        appSecret: 's2s-app-secret',
        appName: 's2s-app-name',
    })
});
```

### Usage

```ts
try {
    // get personal user info
    const personalInfo = await pbxClient.apiRequest(new GetUserPersonalInfoRequest([
        ColleagueFields.ID,
        ColleagueFields.NAME,
    ]));
    console.log({personalInfo})

    // get personal user token
    const personalToken = await pbxClient.apiRequest(new GetUserPersonalTokenRequest(AuthDomains.STAGE));
    console.log({personalToken})

    // get colleaguse
    const colleagues: GetColleaguesResponse = await pbxClient.apiRequest(new GetColleaguesRequest({
        count: 2,
        fields: [
            ColleagueFields.ID,
            ColleagueFields.EXTENSION,
            ColleagueFields.EMAIL,
        ]
    }));
    console.log(colleagues.records)

    // get colleague by id
    const colleague: GetColleagueResponse = await pbxClient.apiRequest(new GetColleagueByIdRequest({
        id: '1135500',
        fields: [
            ColleagueFields.ID,
            ColleagueFields.EXTENSION,
            ColleagueFields.EMAIL,
        ]
    }));
    console.log({colleague})

    // colleague update
    const colleagueUpdated: UpdateColleagueResponse = await pbxClient.apiRequest(new UpdateColleagueByIdRequest({
        id: '1135500',
        fields: {
            [ColleagueFields.NAME]: 'test_' + Date.now(),
        }
    }));
    console.log({colleagueUpdated})

} catch (e) {
    console.error(e.message);
}
```
or you can make any other authorized request to the PBX

```js
    const conferenceResponse = await pbxClient.authorizedPbxRequest(
    '/api/v1/VideoConference/Rooms/',
    {
        method: 'post',
        body: JSON.stringify({
            'subject': 'Test Conference - ' + new Date().toISOString(),
            'participants': [{
                'type': 'colleague',
                'name': 'my test',
                'jid': '999@x-hoppers-us.wildixin.com',
                'email': 'vladimir.gorobets@gmail.com'
            }],
            'schedule': {
                'enabled': true,
                'start': '20\/10\/2023 09:00',
                'end': '20\/10\/2023 10:00',
                'timezone': 'Europe\/Kiev',
                'recurrence': '',
                'description': 'x-streamConnect Test Conference',
                'country': 'US',
                'lang': 'en-us',
                'dialInNumbers': ['en-us']
            }
        })
    }
)
console.log({conferenceResponse});
```

## Wildix Authorization service

If you want to receive OpenId JWT token for Wildix microservices

```ts
const authService: AuthService = new AuthService({
  authDomain: AuthDomains.STAGE
});

// get token for Wildix microservice
const serviceToken = await authService.getOpenIdTokenForService(pbxClient, 'https://geo.wildix.com', 'get all');
console.log({serviceToken});
```

---
_Source: https://npm.io/package/wildix-pbx-sdk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
