@vonage/messages
Version:
Multi-channel messaging that integrates WhatsApp, Facebook, Viber, SMS, and MMS
88 lines (87 loc) • 3.06 kB
TypeScript
import { Client } from '@vonage/server-client';
import { VetchOptions } from '@vonage/vetch';
import { MessageSuccess, SendMessageParams, AnyChannel } from './types';
import { UpdateMessageStatus } from './enums/UpdateMessageStatus';
/**
* Client class to interact with the Messages API which enables users to manage
* send messages through various channels programmatically.
* @see {@link https://developer.nexmo.com/en/messages/overview}
* @group Client
*
* @example
* Create a standalone Messages client
*
* ```ts
* import { Messages } from '@vonage/messages';
*
* const messagesClient = new Messages({
* apiKey: VONAGE_API_KEY,
* apiSecret: VONAGE_API_SECRET
* });
* ```
*
* @example
* Create an Messages 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 messagesClient = vonage.messages;
* ```
*/
export declare class Messages extends Client {
/**
* Adds authentication details to the given request based on the configured
* authentication type. Handle various ways the Messages API handles auth
* The Messages API handles both JWT (preferred) as well as Basic so we
* cannot just set a local authType
*
* @param {VetchOptions} request - The request to which authentication should be added.
* @return {Promise<VetchOptions>} A promise that resolves to the request with added authentication.
*/
addAuthenticationToRequest(request: VetchOptions): Promise<VetchOptions>;
/**
* Sends a message using the Vonage API.
*
* @param {SendMessageParams} message - The message to be sent.
* @return {Promise<MessageSuccess>} A promise that resolves to a success response with a message UUID.
*/
send(message: SendMessageParams | AnyChannel): Promise<MessageSuccess>;
/**
* Update the status of outbound and/or inbound messages for certain
* channels. For example, you can revoke outbound messages or mark inbound
* messages as read.
*
* Please not that this endpoint is region specifc. You will need to set the
* region when you create the client.
*
* @example
* Update the status of a WhatsApp message to "read"
* ```ts
* const vonage = new Vonage(
* {
* applicationId: myAppId,
* privateKey: myPrivateKey
* },
* {
* apiHost: 'https://api-eu.vonage.com'
* }
* )
*
* await vonage.messages.updateMessage(messageId, UpdateMessageStatus.READ);
* ```
*
* @param {string} messageId - The ID of the message to update.
* @param {UpdateMessageStatus | string} status - The status to update the message to.
*
* @return {Promise<true>} A promise that resolves to true if the message was
* updated successfully.
*/
updateMessage(messageId: string, status: UpdateMessageStatus | string): Promise<true>;
}
//# sourceMappingURL=messages.d.ts.map