@vonage/applications
Version:
Vonage Applications API
224 lines (221 loc) • 7.97 kB
TypeScript
import { Client, AuthenticationType } from '@vonage/server-client';
import { Application } from './types/Application.js';
import { ApplicationPageList } from './types/ApplicationPageList.js';
import { ListApplicationParams } from './types/ListApplicationParams.js';
import { ApplicationResponse } from './types/Response/ApplicationResponse.js';
import './types/CapabilityBulk.js';
import './types/CapabilityWebhook.js';
import './types/CapabilityMeetings.js';
import './types/CapabilityMessages.js';
import './types/CapabilityRTC.js';
import './types/CapabilityVerify.js';
import './types/CapabilityVoice.js';
import './enums/VoiceRegions.js';
import './types/Response/ApplicationPageResponse.js';
import './types/Response/CapabilityBulkResponse.js';
import './types/Response/CapabilityWebhookResponse.js';
import './types/Response/CapabilityMeetingsResponse.js';
import './types/Response/CapabilityMessagesResponse.js';
import './types/Response/CapabilityRTCResponse.js';
import './types/Response/CapabilityVerifyResponse.js';
import './types/Response/CapabilityVoiceResponse.js';
/**
* Represents the application with both the `snake_case` and the `camelCase` keys.
*
* @remarks
* This is used for backward compatibility with an earlier release of the SDK
* which was not transforming the application correctly.
* Using `snake_case` is considered deprecated
*
* @example
* Create a standalone Application client
*
* ```ts
* import { Applications } from '@vonage/application';
*
* const applicationClient = new Applications({
* apiKey: VONAGE_API_KEY,
* apiSecret: VONAGE_API_SECRET
* });
* ```
*
* @example
* Create an Application client from the Vonage client
*
* ```ts
* import { Vonage } from '@vonage/server-client';
*
* const vonage = new Vonage({
* apiKey: VONAGE_API_KEY,
* apiSecret: VONAGE_API_SECRET
* });
*
* const applicationClient = vonage.application
* ```
*/
type MergedApplication = Application & ApplicationResponse;
declare class Applications extends Client {
authType: AuthenticationType;
/**
* Retrieves a list of applications with optional pagination parameters.
*
* @remarks
* This is used to get a specific page of applications. This will
* return the `snake_case` and the `camelCase` response. Using `snake_case`
* is considered deprecated
*
* @see API Specification {@link https://developer.vonage.com/en/api/application.v2#listApplication}
*
* @param {ListApplicationParams} params - The filter parameters.
* @return {Promise<ApplicationPageResponse>} - A promise resolving to the list of applications.
*
* @example
* List a single page of applications
*
* ```ts
* const applications = await applicationClient.listApplications({});
*
* applications.applications.forEach(application => {
* console.log(application.name);
* });
* ```
*/
listApplications(params: ListApplicationParams): Promise<ApplicationPageList>;
/**
* Retrieves all applications, iterating over paginated results.
*
* @remarks
* This will keep calling the API until there are no pages left. This will
* return the `snake_case` and the `camelCase` response. Using `snake_case`
* is considered deprecated
*
* @param {ListApplicationParams} [params={}] - Optional filter parameters.
* @yields {MergedApplication} - Yields application items.
* @return {AsyncGenerator<MergedApplication, void, undefined>} - An asynchronous generator.
*
* @example
* List applications with pagination using an iterator
*
* ```ts
* for await (const application of applicationClient.listAllApplications()) {
* console.log(application.name);
* }
* ```
*/
listAllApplications(params?: ListApplicationParams): AsyncGenerator<MergedApplication, void & MergedApplication, undefined>;
/**
* Retrieves a page of applications based on filter parameters.
*
* @param {ListApplicationParams} filter - The filter parameters for pagination.
* @return {Promise<ApplicationPageList>} - A promise resolving to a page of applications.
*
* @remarks
* This will return the `snake_case` and the `camelCase` response. Using
* `snake_case` is considered deprecated
*
* @see API Specification {@link https://developer.vonage.com/en/api/application.v2#listApplication}
*
* @example
* Get a single page of applications
*
* ```ts
* const applications = await applicationClient.getApplicationPage({
* page: 1,
* size: 10
* });
*
* applications.applications.forEach(application => {
* console.log(application.name);
* });
* ```
*/
getApplicationPage(filter: ListApplicationParams): Promise<ApplicationPageList>;
/**
* Creates a new application with the provided details.
*
* @see API Specification {@link https://developer.vonage.com/en/api/application.v2#createApplication}
*
* @param {Application} application - The application details to be created.
* @return {Promise<MergedApplication>} - A promise resolving to the created application.
*
* @example
* Create a new application
*
* ```ts
* const application = await applicationClient.createApplication({
* name: 'My Application',
* capabilities: {
* voice: {
* webhooks: {
* answerUrl: {
* address: 'https://example.com/answer',
* httpMethod: 'GET'
* },
* eventUrl: {
* address: 'https://example.com/event',
* httpMethod: 'POST'
* }
* }
* }
* }
* });
*
* console.log(application.id);
* ```
*/
createApplication(application: Application): Promise<MergedApplication>;
/**
* Retrieves an application by its unique identifier.
*
* @see API Specification {@link https://developer.vonage.com/en/api/application.v2#getApplication}
*
* @param {string} applicationId - The unique identifier of the application to retrieve.
* @return {Promise<MergedApplication>} - A promise resolving to the retrieved application.
*
* @example
* Retrieve an application
*
* ```ts
* const application = await applicationClient.getApplication(APPLICATION_ID);
* console.log(application.name);
* ```
*/
getApplication(applicationId: string): Promise<MergedApplication>;
/**
* Updates an existing application with the provided details.
*
* @see API Specification {@link https://developer.vonage.com/en/api/application.v2#updateApplication}
*
* @param {Application} application - The application details to be updated.
* @return {Promise<MergedApplication>} - A promise resolving to the updated application.
*
* @example
* Update an application
*
* ```ts
* const application = await applicationClient.updateApplication({
* id: APPLICATION_ID,
* name: 'My Application',
* });
* console.log(application.name);
* ```
*/
updateApplication(application: Application): Promise<MergedApplication>;
/**
* Deletes an application by its unique identifier.
*
* @see API Specification {@link https://developer.vonage.com/en/api/application.v2#deleteApplication}
*
* @param {string} applicationId - The unique identifier of the application to delete.
* @return {Promise<void>} - A promise indicating the successful deletion of the application.
*
* @example
* Delete an application
*
* ```ts
* await applicationClient.deleteApplication(APPLICATION_ID);
* ```
*/
deleteApplication(applicationId: string): Promise<void>;
}
export { Applications, type MergedApplication };