messageway
Version:
MessageWay nodeJS library
61 lines (60 loc) • 2.48 kB
TypeScript
import { SendInput, SendManuallyInput, SendAutomaticInput, VerifyRequest, StatusRequest, StatusResponse, MessageError, BalanceResponse } from './types';
export { SendInput, SendManuallyInput as SendManuallyInput, SendAutomaticInput, VerifyRequest, StatusRequest, StatusResponse, MessageError as OTPError };
export { MessageMethod as OTPMethod, MessageStatus as OTPStatus } from './types';
/**
* Check whether an error is a MessageWay standard error or not<br>
* These objects have two fields: `code` and `message`
* @param error The error object to check
* @returns `error` is a standard MessageWay error
*/
export declare function isMessageWayError(error: any): error is MessageError;
export declare class MessageWay<IsManual extends boolean = false> {
private readonly apiKey;
private readonly language;
/**
* @param apiKey Your API key in MsgWay.com.
* @param manual Generate OTP code automatically or you gonna to enter it manually. <br>Default is `false`.
* @param language Target language for showing error messages.
*/
constructor(apiKey: string, manual?: IsManual, language?: string);
private request;
private send;
/**
* Send OTP Code via SMS
* @param options Send options
* @returns Reference ID
*/
sendSMS(options: SendInput<IsManual>): Promise<string>;
/**
* Send OTP Code via IVR (Interactive voice response)
* @param options Send options
* @returns Reference ID
*/
sendIVR(options: SendInput<IsManual>): Promise<string>;
/**
* Send OTP Code via Gap Messenger ([gap.im](https://gap.im))
* @returns Reference ID
*/
sendGapMessage(options: SendInput<IsManual>): Promise<string>;
/**
* Send OTP Code via WhatsApp Messenger ([whatsapp.com](https://www.whatsapp.com))
* @returns Reference ID
*/
sendWhatsAppMessage(options: SendInput<IsManual>): Promise<string>;
/**
* Verify the user entered code.
* @returns If the code is correct the promise resolves.
*/
verify(options: VerifyRequest): Promise<void>;
/**
* Get status of the sent OTP.
* @param referenceID
*/
getStatus(options: StatusRequest): Promise<StatusResponse>;
/**
* Get account balance.
* @returns A promise that resolves to the account balance as a number.
* @author amirmm4d
*/
getBalance(): Promise<BalanceResponse>;
}