vesal
Version:
Armaghan Vesal SMS API client for JS/TS/ESM/Node.js
129 lines (128 loc) • 5.44 kB
TypeScript
/**
* The Vesal API Class
* @author Shahab Movahhedi
* @see {@link https://shmovahhedi.com Shahab Movahhedi's Website}
* @see {@link https://github.com/movahhedi/vesal vesal's Repository}
* @license MIT
*/
export declare class Vesal {
readonly apiUrl = "http://vesal.armaghan.net:8080/rest";
private username;
private password;
private from;
constructor(username: string, password: string, from: string);
/**
* Make an API request to the Vesal API
* @private
* @param {string} urlSuffix - The URL suffix for the API endpoint
* @param {("GET"|"POST")} [method="GET"] - The HTTP method to use for the request
* @param {object|null} [data=null] - The data to send with the request
* @returns {Promise} The response from the API
*/
private Api;
Send({ recipients, messages, from, }: {
recipients: string | string[];
messages: string | string[];
from?: string | string[];
}): Promise<IVesalResponse_Send_WithCount>;
GetMessageStatus(referencesIds: number[]): Promise<IVesalResponse_MessageState>;
GetReceivedMessages(): Promise<IVesalResponse_ReceivedMessages>;
GetReceivedMessagesCount(): Promise<IVesalResponse_ReceivedMessagesCount>;
GetUserInfo(): Promise<IVesalResponse_UserInfo>;
}
export declare class VesalError extends Error {
status: keyof typeof vesalErrors | undefined;
constructor(statusParam: number | undefined, messageParam?: string);
}
interface IVesalResponse_Base {
errorModel: {
errorCode: number;
timestamp: string | number | null;
};
}
interface IVesalResponse_Send extends IVesalResponse_Base {
references: (number | Omit<keyof typeof vesalErrors, 0>)[];
}
interface IVesalResponse_Send_WithCount extends IVesalResponse_Send {
count: {
success: number;
fail: number;
};
}
interface IVesalResponse_MessageState extends IVesalResponse_Base {
states: {
id: number;
state: number;
}[];
}
interface IVesalResponse_ReceivedMessages extends IVesalResponse_Base {
messageModels: {
originator: string;
destination: string;
content: string;
}[];
}
interface IVesalResponse_ReceivedMessagesCount extends IVesalResponse_Base {
count: number;
}
interface IVesalResponse_UserInfo extends IVesalResponse_Base {
user: {
credit: number;
deliveryUrl: unknown;
receiveUrl: unknown;
iPs: string[];
numbers: string[];
id: number;
username: string;
password: unknown;
firstName: unknown;
lastName: unknown;
mobile: unknown;
email: unknown;
nationalId: number;
expirationDate: string;
active: boolean;
deleted: boolean;
dbProxyStandalone: boolean;
insertDate: unknown;
updateDate: unknown;
customer: unknown;
roles: unknown;
};
}
export declare function GetStatusText(status: number): any;
export declare const messageStates: {
readonly 0: "پیامک در صف ارسال قرار دارد";
readonly 1: "ارسال شده";
readonly 2: "پیامک به موبایل گیرنده تحویل شده است";
readonly 3: "پیامک به موبایل گیرنده تحویل نشده است";
readonly 4: "وضعیت نامشخص";
readonly 5: "پیامک توسط وب سرویس به شرکت ارمغان راه طلایی رسیده است";
readonly 6: "پیام از سمت اپراتور لغو شده است";
readonly 7: "پیام از سمت اپراتور منقضی شده است";
readonly 8: "پیام از سمت اپراتور reject شده است";
};
export declare const vesalErrors: {
readonly 0: "عملیات با موفقیت انجام شد";
readonly [-100]: "refrenceId مورد نظر یافت نشد";
readonly [-101]: "احراز هویت کاربر موفقیت آمیز نبود";
readonly [-102]: "نام کاربری یافت نشد";
readonly [-103]: "شماره originator اشتباه یا در بازه شماره های کاربر نیست";
readonly [-104]: "اعتبار کم است";
readonly [-105]: "فرمت درخواست اشتباه است";
readonly [-106]: "تعداد refrenceId ها بیش از 1000 عدد است";
readonly [-107]: "شماره گیرنده پیامک اشتباه است";
readonly [-109]: "تاریخ انقضای حساب کاربری فرارسیده است";
readonly [-110]: "درخواست از ip مجاز کاربر ارسال نشده است";
readonly [-111]: "شماره گیرنده در بلک لیست قرار دارد";
readonly [-112]: "حساب مشتری فعال نیست";
readonly [-115]: "فرمت UDH اشتباه است";
readonly [-117]: "مقدار mclass وارد شده اشتباه است";
readonly [-118]: "شماره پورت وارد شده صحیح نیست";
readonly [-119]: "کاربر به سرویس مورد نظر دسترسی ندارد";
readonly [-120]: "پیام ارسال شده دارای هیچ شماره معتبری نیست";
readonly [-200]: "خطای داخلی در پایگاه داده رخ داده است";
readonly [-201]: "خطای نامشخص داخل پایگاه داده";
readonly [-137]: "پیام نباید حاوی کلمات غیرمجاز می باشد";
};
export {};