Skip to main content

Providers

Providers ⇐ APIClient

Use Fonoster Providers, a capability of Fonoster SIP Proxy subsystem, to create, update, get and delete providers. Fonoster Providers requires of a running Fonosterdeployment.

Kind: global class
Extends: APIClient
See: module:core:APIClient

new Providers(options)

Constructs a new Providers object.

ParamTypeDescription
optionsClientOptionsOptions to indicate the objects endpoint

Example

const Fonoster = require("@fonoster/sdk");
const providers = new Fonoster.Providers();

const request = {
name: "SIP Provider",
username: "trunk001",
secret: "secretkey",
host: "sip.provider.net"
};

providers.createProvider(request)
.then(result => {
console.log(result) // successful response
}).catch(e => console.error(e)); // an error occurred

providers.createProvider(request) ⇒ Promise.<Object>

Creates a new Provider on the SIP Proxy subsystem.

Kind: instance method of Providers

ParamTypeDescription
requestObjectRequest for the provision of a new Provider
request.namestringFriendly name to the Provider
request.usernamestringUsername for the trunk. No required for static IP authentication
request.secretstringPassword for the trunk. No required for static IP authentication
request.hoststringHostname or IP of the Provider
request.transportstringThe transport for the Provider. Fonoster will use TCP if none is provided
request.expiresstringExpiration time for the registration.
request.registerbooleanIndicates if the Provider should be registered Fonoster will use 600 if non is provided

Example

const request = {
name: "Provider Name",
username: "trunk001",
secret: "secretkey",
host: "sip.provider.net",
register: true
};

providers.createProvider(request)
.then(result => {
console.log(result) // returns the Provider object
}).catch(e => console.error(e)); // an error occurred

providers.getProvider(ref) ⇒ Promise.<Object>

Retrieves a Provider by its reference.

Kind: instance method of Providers
Returns: Promise.<Object> - The provider
Throws:

  • if ref is null or Provider does not exist
ParamTypeDescription
refstringReference to Provider

Example

providers.getProvider(ref)
.then(result => {
console.log(result) // returns the Provider object
}).catch(e => console.error(e)); // an error occurred

providers.updateProvider(request) ⇒ Promise.<Object>

Update a Provider at the SIP Proxy subsystem.

Kind: instance method of Providers

ParamTypeDescription
requestObjectRequest to update a Provider
request.refstringProviders reference
request.namestringFriendly name to the Provider
request.usernamestringUsername for the trunk. No required for static IP authentication
request.secretstringPassword for the trunk. No required for static IP authentication
request.hoststringHostname or IP of the Provider
request.transportstringThe transport for the Provider. Fonoster will use TCP if none is provided
request.expiresstringExpiration time for the registration.
request.registerbooleanIndicates if the Provider should be registered Fonoster will use 600 if non is provided

Example

const request = {
ref: "hYTHYCYv_U",
host: "sip.provider.net"
};

providers.updateProvider(request)
.then(result => {
console.log(result) // returns the Provider from the DB
}).catch(e => console.error(e)); // an error occurred

providers.listProviders(request) ⇒ Promise.<ListProvidersResponse>

List the Providers registered in Fonoster SIP Proxy subsystem.

Kind: instance method of Providers
Returns: Promise.<ListProvidersResponse> - List of Providers

ParamTypeDescription
requestObject
request.pageSizeproviderProvider of element per page (defaults to 20)
request.pageTokenstringThe next_page_token value returned from a previous List request, if any

Example

const request = {
pageSize: 20,
pageToken: 2
};

providers.listProviders(request)
.then(() => {
console.log(result) // returns a ListProvidersResponse object
}).catch(e => console.error(e)); // an error occurred

providers.deleteProvider(ref)

Deletes a Provider from SIP Proxy subsystem. Notice, that in order to delete a Provider, you must first delete all it"s Agents.

Kind: instance method of Providers

ParamTypeDescription
refstringReference to the Provider

Example

const ref = "hYTHYCYv_U";

providers.deleteProvider(ref)
.then(() => {
console.log("done") // returns an empty object
}).catch(e => console.error(e)); // an error occurred