UNPKG

@telstra/messaging

Version:
155 lines (142 loc) 7 kB
import { HttpClient, IAuthConfigProps } from '@telstra/core'; import { TGetAll, TMessageGetResponse, TMessages, TMessageSend, TMessageSendResponse, TMessageUpdate, TMessageUpdateTags } from '../types/index.js'; export declare class Messages extends HttpClient { authConfig?: IAuthConfigProps | undefined; constructor(authConfig?: IAuthConfigProps | undefined); private validateSendUpdateMessageArgs; private validateMessageIdParam; /** * Send a Message to a single or multiple mobile number/s. * @param message.to - The destination address, expected to be a phone number of the form `+614XXXXXXXX` or `04XXXXXXXX`. * @param message.from - This will be either "privateNumber", one of your Virtual Numbers or your senderName. * @param message.messageContent - The content of the message. Either one of messageContent or multimedia is required. * @param message.multimedia - MMS multimedia content. * @param message.retryTimeout - How many minutes you asked the server to keep trying to send the message. * @param message.scheduled - The time (in Central Standard Time) the message is scheduled to send. * @param message.deliveryNotification - If set to true, you will receive a notification to the statusCallbackUrl when your SMS or MMS is delivered (paid feature). * @param message.statusCallbackUrl - The URL the API will call when the status of the message changes. * @param message.tags - Any customisable tags assigned to the message. * @link https://dev.telstra.com/docs/messaging-api/apiReference/apiReferenceOverviewEndpoints?version=3.x#SendanSMSorMMS * @example ```typescript import { Message } from '@telstra/messaging' const message = new Message(); message.send({ to: '+61000000000', body: 'Hello from Messaging SDK' }) .then(result => { console.log(result); }) .catch(error => { console.error(error); }); ``` */ send(message: TMessageSend): Promise<TMessageSendResponse>; /** * Update a message that's scheduled for sending, you can change any of the below parameters, as long as the message hasn't been sent yet. * @param message.messageId - (Required) Unique identifier for the message. * @param message.to - The destination address, expected to be a phone number of the form `+614XXXXXXXX` or `04XXXXXXXX`. * @param message.from - This will be either "privateNumber", one of your Virtual Numbers or your senderName. * @param message.messageContent - The content of the message. Either one of messageContent or multimedia is required. * @param message.multimedia - MMS multimedia content. * @param message.retryTimeout - How many minutes you asked the server to keep trying to send the message. * @param message.scheduled - The time (in Central Standard Time) the message is scheduled to send. * @param message.deliveryNotification - If set to true, you will receive a notification to the statusCallbackUrl when your SMS or MMS is delivered (paid feature). * @param message.statusCallbackUrl - The URL the API will call when the status of the message changes. * @param message.tags - Any customisable tags assigned to the message. * @link https://dev.telstra.com/docs/messaging-api/apiReference/apiReferenceOverviewEndpoints?version=3.x#Updateamessage * @example ```typescript import { Message } from '@telstra/messaging' const message = new Message(); message.update( ) .then(result => { console.log(result); }) .catch(error => { console.error(error); }); ``` */ update(message: TMessageUpdate): Promise<TMessageSendResponse>; /** * Update message tags, you can update them even after your message has been delivered. * @param message.messageId - (Required) Unique identifier for the message. * @param message.tags - Any customisable tags assigned to the message. * @link https://dev.telstra.com/docs/messaging-api/apiReference/apiReferenceOverviewEndpoints?version=3.x#Updatemessagetags * @example ```typescript import { Message } from '@telstra/messaging' const message = new Message(); message.updateTags({ messageId: '<MESSAGE_ID>', tags: ['tag1', 'tag2'] } ) .then(result => { console.log(result); }) .catch(error => { console.error(error); }); ``` */ updateTags(message: TMessageUpdateTags): Promise<void>; /** * Use the messageId to fetch a message that's been sent from/to your account within the last 30 days. * @param messageId - (Required) Unique identifier for the message. * @link https://dev.telstra.com/docs/messaging-api/apiReference/apiReferenceOverviewEndpoints?version=3.x#Fetchamessage * @example ```typescript import { Message } from '@telstra/messaging' const message = new Message(); message.get('<MESSAGE_ID>') .then(result => { console.log(result); }) .catch(error => { console.error(error); }); ``` */ get(messageId: string): Promise<TMessageGetResponse>; /** * Fetch messages that have been sent from/to your account in the last 30 days. * @param messageId - (Required) Unique identifier for the message. * @link https://dev.telstra.com/docs/messaging-api/apiReference/apiReferenceOverviewEndpoints?version=3.x#Fetchallsent/receivedmessages * @example ```typescript import { Message } from '@telstra/messaging' const message = new Message(); message.getAll() .then(result => { console.log(result); }) .catch(error => { console.error(error); }); ``` */ getAll(data?: TGetAll): Promise<TMessages>; /** * Delete a scheduled message, but hasn't yet sent. * @param messageId - (Required) Unique identifier for the message. * @link https://dev.telstra.com/docs/messaging-api/apiReference/apiReferenceOverviewEndpoints?version=3.x#Deleteamessage * @example ```typescript import { Message } from '@telstra/messaging' const message = new Message(); message.delete('<MESSAGE_ID>') .then(result => { console.log(result); }) .catch(error => { console.error(error); }); ``` */ delete(messageId: string): Promise<void>; }