Skip to content

Vonage Users

github-actions edited this page Nov 12, 2024 · 62 revisions

Vonage UsersDocs


Documentation / Vonage Users

Vonage Users

Enumerations

SortOrder

Enum representing the sorting order.

Enumeration Members

Enumeration Member Value Description Defined in
ASC "ASC" Ascending order. users/lib/enums/userSort.ts:8
DESC "DESC" Descending order. users/lib/enums/userSort.ts:13

Classes

Users

The Users class provides methods for managing user data through API requests.

Vonage API responses and requests use snake_case for property names, but this class performs the necessary key transformations to work with camelCase property names in your application.

Extends

Constructors

new Users()
new Users(credentials, options?): Users

Creates a new instance of the Client.

Parameters

credentials: AuthInterface | AuthParams

The authentication credentials or an authentication instance.

options?: ConfigParams

Optional configuration settings for the client.

Returns

Users

Inherited from

Client.constructor

Defined in

server-client/dist/lib/client.d.ts:35

Properties

auth
protected auth: AuthInterface;

The authentication instance responsible for generating authentication headers and query parameters.

Inherited from

Client.auth

Defined in

server-client/dist/lib/client.d.ts:24

authType
protected authType: AuthenticationType = AuthenticationType.JWT;

The type of authentication used for the client's requests.

Overrides

Client.authType

Defined in

users/lib/user.ts:94

config
protected config: ConfigParams;

Configuration settings for the client, including default hosts for various services and other request settings.

Inherited from

Client.config

Defined in

server-client/dist/lib/client.d.ts:28

transformers
static transformers: object;

Static property containing utility transformers.

camelCaseObjectKeys
camelCaseObjectKeys: PartialTransformFunction;
kebabCaseObjectKeys
kebabCaseObjectKeys: PartialTransformFunction;
omit()
omit: (keys, obj) => TransformedObject;
Parameters

keys: string[]

obj: ObjectToTransform

Returns

TransformedObject

snakeCaseObjectKeys
snakeCaseObjectKeys: PartialTransformFunction;
Inherited from

Client.transformers

Defined in

server-client/dist/lib/client.d.ts:11

Methods

addAuthenticationToRequest()
addAuthenticationToRequest(request): Promise<VetchOptions>

Adds the appropriate authentication headers or parameters to the request based on the authentication type.

Parameters

request: VetchOptions

The request options to which authentication needs to be added.

Returns

Promise<VetchOptions>

  • The request options with the added authentication.
Inherited from

Client.addAuthenticationToRequest

Defined in

server-client/dist/lib/client.d.ts:43

addBasicAuthToRequest()
protected addBasicAuthToRequest(request): Promise<VetchOptions>

Adds basic authentication headers to the request.

Parameters

request: VetchOptions

The request options to which authentication needs to be added.

Returns

Promise<VetchOptions>

  • The request options with the added authentication.
Inherited from

Client.addBasicAuthToRequest

Defined in

server-client/dist/lib/client.d.ts:71

addJWTToRequest()
protected addJWTToRequest(request): Promise<VetchOptions>

Adds a JWT to the request.

Parameters

request: VetchOptions

The request options to which authentication needs to be added.

Returns

Promise<VetchOptions>

  • The request options with the added authentication.
Inherited from

Client.addJWTToRequest

Defined in

server-client/dist/lib/client.d.ts:64

addQueryKeySecretToRequest()
protected addQueryKeySecretToRequest(request): Promise<VetchOptions>

Adds API key and secret to the request.

Parameters

request: VetchOptions

The request options to which authentication needs to be added.

Returns

Promise<VetchOptions>

  • The request options with the added authentication.
Inherited from

Client.addQueryKeySecretToRequest

Defined in

server-client/dist/lib/client.d.ts:57

addQueryKeySecretToRequestBody()
protected addQueryKeySecretToRequestBody(request): Promise<VetchOptions>

Adds API key and secret to the request body.

Parameters

request: VetchOptions

The request options to which authentication needs to be added.

Returns

Promise<VetchOptions>

  • The request options with the added authentication.
Inherited from

Client.addQueryKeySecretToRequestBody

Defined in

server-client/dist/lib/client.d.ts:50

createUser()
createUser(user): Promise<UserType>

Creates a new user with the provided user data.

Parameters

user: UserType

The user data to create a new user.

Returns

Promise<UserType>

A Promise that resolves to the newly created user.

Throws

If there is an issue with the request or response.

Defined in

users/lib/user.ts:152

deleteUser()
deleteUser(userId): Promise<void>

Deletes the user with the specified user ID.

Parameters

userId: string

The unique ID of the user to be deleted.

Returns

Promise<void>

A Promise that resolves once the user is successfully deleted.

Throws

If there is an issue with the request or response, or if the user with the specified ID is not found.

Defined in

users/lib/user.ts:199

getConfig()
getConfig(): ConfigParams
Returns

ConfigParams

Inherited from

Client.getConfig

Defined in

server-client/dist/lib/client.d.ts:36

getUser()
getUser(userId): Promise<UserType>

Retrieves user information for the specified user ID.

Parameters

userId: string

The unique identifier of the user to retrieve.

Returns

Promise<UserType>

A Promise that resolves to the user information for the specified user ID.

Throws

If there is an issue with the request or response, or if the user with the specified ID is not found.

Defined in

users/lib/user.ts:168

getUserPage()
getUserPage(params?): Promise<UserPageResponse>

Retrieves a page of users based on the provided parameters, such as pagination and filtering.

Parameters

params?: UserListParameters = {}

Optional parameters to filter and paginate the list of users.

Returns

Promise<UserPageResponse>

A Promise that resolves to a UserPageResponse object containing the user page data.

Throws

If there is an issue with the request or response.

Defined in

users/lib/user.ts:134

listAllUsers()
listAllUsers(params): AsyncGenerator<UserType, void & UserType, undefined>

Retrieves a list of users, optionally paginated, based on the provided parameters.

Parameters

params: UserListParameters = {}

Optional parameters to filter and paginate the list of users.

Returns

AsyncGenerator<UserType, undefined>

An async generator that yields user objects.

Defined in

users/lib/user.ts:102

parseResponse()
protected parseResponse<T>(request, response): Promise<VetchResponse<T>>

Parses the response based on its content type.

Type Parameters

T

The expected type of the parsed response data.

Parameters

request: VetchOptions

The request options.

response: Response

The raw response from the request.

Returns

Promise<VetchResponse<T>>

  • The parsed response.
Inherited from

Client.parseResponse

Defined in

server-client/dist/lib/client.d.ts:168

prepareBody()
protected prepareBody(request): undefined | string

Prepares the body for the request based on the content type.

Parameters

request: VetchOptions

The request options.

Returns

undefined | string

  • The prepared request body as a string or undefined.
Inherited from

Client.prepareBody

Defined in

server-client/dist/lib/client.d.ts:158

prepareRequest()
protected prepareRequest(request): Promise<VetchOptions>

Prepares the request with necessary headers, authentication, and query parameters.

Parameters

request: VetchOptions

The initial request options.

Returns

Promise<VetchOptions>

  • The modified request options.
Inherited from

Client.prepareRequest

Defined in

server-client/dist/lib/client.d.ts:151

sendDeleteRequest()
sendDeleteRequest<T>(url): Promise<VetchResponse<T>>

Sends a DELETE request to the specified URL.

Type Parameters

T

Parameters

url: string

The URL endpoint for the DELETE request.

Returns

Promise<VetchResponse<T>>

  • The response from the DELETE request.
Inherited from

Client.sendDeleteRequest

Defined in

server-client/dist/lib/client.d.ts:78

sendFormSubmitRequest()
sendFormSubmitRequest<T>(url, payload?): Promise<VetchResponse<T>>

Sends a POST request with form data to the specified URL.

Type Parameters

T

Parameters

url: string

The URL endpoint for the POST request.

payload?: Record<string, undefined | string>

Optional payload containing form data to send with the POST request.

Returns

Promise<VetchResponse<T>>

  • The response from the POST request.
Inherited from

Client.sendFormSubmitRequest

Defined in

server-client/dist/lib/client.d.ts:86

sendGetRequest()
sendGetRequest<T>(url, queryParams?): Promise<VetchResponse<T>>

Sends a GET request to the specified URL with optional query parameters.

Type Parameters

T

Parameters

url: string

The URL endpoint for the GET request.

queryParams?

Optional query parameters to append to the URL. These should be compatible with Node's URLSearchParams.

Returns

Promise<VetchResponse<T>>

  • The response from the GET request.
Inherited from

Client.sendGetRequest

Defined in

server-client/dist/lib/client.d.ts:94

sendPatchRequest()
sendPatchRequest<T>(url, payload?): Promise<VetchResponse<T>>

Sends a PATCH request to the specified URL with an optional payload.

Type Parameters

T

Parameters

url: string

The URL endpoint for the PATCH request.

payload?

Optional payload to be sent as the body of the PATCH request.

Returns

Promise<VetchResponse<T>>

  • The response from the PATCH request.
Inherited from

Client.sendPatchRequest

Defined in

server-client/dist/lib/client.d.ts:104

sendPostRequest()
sendPostRequest<T>(url, payload?): Promise<VetchResponse<T>>

Sends a POST request to the specified URL with an optional payload.

Type Parameters

T

Parameters

url: string

The URL endpoint for the POST request.

payload?

Optional payload to be sent as the body of the POST request.

Returns

Promise<VetchResponse<T>>

  • The response from the POST request.
Inherited from

Client.sendPostRequest

Defined in

server-client/dist/lib/client.d.ts:114

sendPutRequest()
sendPutRequest<T>(url, payload?): Promise<VetchResponse<T>>

Sends a PUT request to the specified URL with an optional payload.

Type Parameters

T

Parameters

url: string

The URL endpoint for the PUT request.

payload?

Optional payload to be sent as the body of the PUT request.

Returns

Promise<VetchResponse<T>>

  • The response from the PUT request.
Inherited from

Client.sendPutRequest

Defined in

server-client/dist/lib/client.d.ts:124

sendRequest()
sendRequest<T>(request): Promise<VetchResponse<T>>

Sends a request adding necessary headers, handling authentication, and parsing the response.

Type Parameters

T

Parameters

request: VetchOptions

The options defining the request, including URL, method, headers, and data.

Returns

Promise<VetchResponse<T>>

  • The parsed response from the request.
Inherited from

Client.sendRequest

Defined in

server-client/dist/lib/client.d.ts:144

sendRequestWithData()
sendRequestWithData<T>(
   method, 
   url, 
payload?): Promise<VetchResponse<T>>

Sends a request with JSON-encoded data to the specified URL using the provided HTTP method.

Type Parameters

T

Parameters

method: POST | PUT | PATCH

The HTTP method to be used for the request (only POST, PATCH, or PUT are acceptable).

url: string

The URL endpoint for the request.

payload?

Optional payload to be sent as the body of the request, JSON-encoded.

Returns

Promise<VetchResponse<T>>

  • The response from the request.
Inherited from

Client.sendRequestWithData

Defined in

server-client/dist/lib/client.d.ts:135

updateUser()
updateUser(user): Promise<UserType>

Updates the user information for the specified user.

Parameters

user: UserType

The user object containing the updated information.

Returns

Promise<UserType>

A Promise that resolves to the updated user information.

Throws

If there is an issue with the request or response, or if the user with the specified ID is not found.

Defined in

users/lib/user.ts:183

Type Aliases

MessengerChannel

type MessengerChannel: object;

Represents a Messenger channel with an ID.

Type declaration

id
id: string;

The unique ID associated with the Messenger channel.

Defined in

users/lib/types/messengerChannel.ts:4


MmsChannel

type MmsChannel: object;

Represents an MMS (Multimedia Messaging Service) channel with a phone number.

Type declaration

number
number: string;

The phone number associated with the MMS channel.

Defined in

users/lib/types/mmsChannel.ts:4


PstnChannel

type PstnChannel: object;

Represents a PSTN (Public Switched Telephone Network) channel with a phone number.

Type declaration

number
number: number;

The phone number associated with the PSTN channel.

Defined in

users/lib/types/pstnChannel.ts:4


SipChannel

type SipChannel: object;

Represents a SIP (Session Initiation Protocol) channel with the URI, username, and password.

Type declaration

password
password: string;

The password for authentication with the SIP channel.

uri
uri: string;

The SIP URI associated with the channel.

username
username: string;

The username for authentication with the SIP channel.

Defined in

users/lib/types/sipChannel.ts:4


SmsChannel

type SmsChannel: object;

Represents an SMS (Short Message Service) channel with a phone number.

Type declaration

number
number: string;

The phone number associated with the SMS channel.

Defined in

users/lib/types/smsChannel.ts:4


UserChannelsRequest

type UserChannelsRequest: object & Omit<Pick<UserType, "channels">, "websocket">;

Represents a request to create or update a user's channels.

Type declaration

websocket
websocket: WebSocketChannelRequest[];

An array of WebSocket channel requests.

Remarks

Vonage API's will return information using snake_case. This represents the pure response before the client will transform the keys into camelCase.

Defined in

users/lib/types/requests/userRequest.ts:27


UserListParameters

type UserListParameters: object;

Parameters for listing users.

Type declaration

cursor?
optional cursor: string;

The cursor to start returning results from. You are not expected to provide this manually, but to follow the URL provided in _links.next.href or _links.prev.href in the response which contains a cursor value.

name?
optional name: string;

Unique name for a user. Example: 'my_user_name'.

order?
optional order: SortOrder;

The sorting order for the records. Must be one of: 'ASC' (Ascending) or 'DESC' (Descending).

pageSize?
optional pageSize: number;

The number of records to return in the response. Minimum: 1, Maximum: 100, Default: 10. Example: 10

Defined in

users/lib/types/parameters/userListParameters.ts:6


UserPageResponse

type UserPageResponse: object & APILinks;

Represents a page response containing a list of users.

Type declaration

_embedded
_embedded: object;

An object containing an array of user responses.

_embedded.users
_embedded.users: UserResponse[];
page_size
page_size: number;

The number of records returned in this response.

Remarks

Vonage API's will return information using snake_case. This represents the pure response before the client will transform the keys into camelCase.

Defined in

users/lib/types/responses/userPageResponse.ts:11


UserPropertiesRequest

type UserPropertiesRequest: object;

Represents a request to create or update a user's properties.

Type declaration

custom_data
custom_data: Record<string, string>;

Custom key-value pairs associated with the user.

Remarks

Data here will not have their properties transformed

Remarks

Vonage API's will return information using snake_case. This represents the pure response before the client will transform the keys into camelCase.

Defined in

users/lib/types/requests/userRequest.ts:11


UserRequest

type UserRequest: object & Omit<UserType, "imageUrl" | "properties">;

Represents a request to create or update a user.

Type declaration

channels
channels: UserChannelsRequest;

Channels for communication, specifically WebSocket channels.

image_url
image_url: string;

The URL of the user's image.

properties
properties: UserPropertiesRequest;

User properties including custom data.

Remarks

Vonage API's will return information using snake_case. This represents the pure response before the client will transform the keys into camelCase.

Defined in

users/lib/types/requests/userRequest.ts:41


UserResponse

type UserResponse: UserRequest & APILinks;

Represents a response containing user information.

Remarks

Vonage API's will return information using snake_case. This represents the pure response before the client will transform the keys into camelCase.

Defined in

users/lib/types/responses/userResponse.ts:11


UserType

type UserType: object;

Represents a user with various properties and communication channels.

Type declaration

channels?
optional channels: object;

Communication channels associated with the user.

channels.messenger?
optional channels.messenger: MessengerChannel[];

Messenger channels.

channels.mms?
optional channels.mms: MmsChannel[];

MMS (Multimedia Messaging Service) channels.

channels.pstn?
optional channels.pstn: PstnChannel[];

PSTN (Public Switched Telephone Network) channels.

channels.sip?
optional channels.sip: SipChannel[];

SIP (Session Initiation Protocol) channels.

channels.sms?
optional channels.sms: SmsChannel[];

SMS (Short Message Service) channels.

channels.vbc?
optional channels.vbc: VbcChannel[];

VBC (Voice Business Communication) channels.

channels.viber?
optional channels.viber: ViberChannel[];

Viber channels.

channels.websocket?
optional channels.websocket: WebsocketChannel[];

WebSocket channels.

channels.whatsapp?
optional channels.whatsapp: WhatsappChannel[];

WhatsApp channels.

displayName?
optional displayName: string;

The display name of the user.

id?
optional id: string;

The unique ID associated with the user.

imageUrl?
optional imageUrl: string;

The URL of the user's image.

name?
optional name: string;

The name of the user.

properties?
optional properties: object;

Custom data associated with the user.

properties.customData
properties.customData: Record<string, string>;

Custom key-value pairs for user data.

Defined in

users/lib/types/userType.ts:14


VbcChannel

type VbcChannel: object;

Represents a VBC (Voice Business Communication) channel with an extension.

Type declaration

extension
extension: string;

The extension associated with the VBC channel.

Defined in

users/lib/types/vbcChannel.ts:4


ViberChannel

type ViberChannel: object;

Represents a Viber channel with a phone number.

Type declaration

number
number: string;

The phone number associated with the Viber channel.

Defined in

users/lib/types/viberChannel.ts:4


WebsocketChannel

type WebsocketChannel: object;

Represents a WebSocket channel configuration.

Type declaration

contentType?
optional contentType: string;

Optional content type for WebSocket channel data.

headers?
optional headers: Record<string, string>;

Optional headers for WebSocket channel configuration.

uri
uri: string;

The WebSocket URI for the channel.

Defined in

users/lib/types/websocketChannel.ts:4


WebSocketChannelRequest

type WebSocketChannelRequest: object & Omit<WebsocketChannel, "contentType">;

Represents a request to create or update a WebSocket channel.

Type declaration

content-type
content-type: string;

The content type associated with the WebSocket channel.

Remarks

Vonage API's will return information using snake_case. This represents the pure response before the client will transform the keys into camelCase.

Defined in

users/lib/types/requests/websocketChannelRequest.ts:10


WebSocketChannelResponse

type WebSocketChannelResponse: object & Omit<WebsocketChannel, "contentType">;

Represents a response containing WebSocket channel information.

Type declaration

content-type
content-type: string;

The content type associated with the WebSocket channel.

Remarks

Vonage API's will return information using snake_case. This represents the pure response before the client will transform the keys into camelCase.

Defined in

users/lib/types/responses/websocketChannelResponse.ts:9


WhatsappChannel

type WhatsappChannel: object;

Represents a WhatsApp channel with a phone number.

Type declaration

number
number: string;

The phone number associated with the WhatsApp channel.

Defined in

users/lib/types/whatsappChannel.ts:4

Clone this wiki locally