@bdcode/sms
Version:
Unified (BD) SMS Providers client package for all TS/JS applications
96 lines • 4.05 kB
TypeScript
import { z } from "zod";
export declare const SmsNetBdEndpoints: {
readonly SEND_SMS: "/sendsms";
readonly GET_BALANCE: "/user/balance/";
readonly GET_REPORT: "/report/request/{id}/";
};
export declare const validatePayloadWithReqID: z.ZodObject<{
request_id: z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>;
}, z.core.$strip>;
export declare const validateSendSmsPayload: z.ZodObject<{
msg: z.ZodString;
to: z.ZodString;
schedule: z.ZodOptional<z.ZodString>;
sender_id: z.ZodOptional<z.ZodString>;
content_id: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
/**
* Configuration options for the SmsNetBd adapter.
*
* @property api_key - API key for authentication. **Required.**
* @property base - Base URL for the API. Defaults to `"https://api.sms.net.bd"` if not provided.
*/
export interface SmsNetBdConfig {
api_key: string;
base?: string;
}
/**
* SmsNetBd Adapter Class
*
* This class provides methods to interact with the SmsNetBd API for sending SMS, checking balance, and getting delivery reports.
* It uses the `axios` library for HTTP requests and `zod` for payload validation.
*
* @class SmsNetBd
* @param {SmsNetBdConfig} config - Configuration options for the adapter.
* @property {string} base - Base URL for the API, defaults to "https://api.sms.net.bd".
* @property {string} api_key - API key for authentication.
* @throws {Error} If the payload validation fails or if the API response indicates an error.
*/
export declare class SmsNetBd {
protected config: SmsNetBdConfig;
private base;
private api_key;
constructor(config: SmsNetBdConfig);
sendSms(payload: SmsNetBdRequestProps): Promise<SmsNetBdResponseProps>;
getBalance(): Promise<SmsNetBdResponseProps>;
getReport(request_id: string | number): Promise<SmsNetBdResponseProps>;
}
/**
* Represents the properties required to send an SMS request via SmsNetBd.
*
* @property {string} msg - The body content of your message.
* @property {string} to - The recipient numbers. Multiple numbers must be separated by comma (,) (applicable for only campaign SMS). The number must start with country code (880) or standard 01X.
* @property {string} [schedule] - (Optional) The schedule date and time to send your message. Date and time must be formatted as Y-m-d H:i:s (e.g., 2021-10-13 16:00:52).
* @property {string} [sender_id] - (Optional) If you have an approved Sender ID, you can use this parameter to set your Sender ID as the sender in your messages.
* @property {string} [content_id] - (Required for bulk SMS) If you have an approved campaign content, you can use this parameter to set the ID of the content to use.
*/
export interface SmsNetBdRequestProps {
msg: string;
to: string;
schedule?: string;
sender_id?: string;
content_id?: string;
}
export interface SmsNetBdResponseProps {
error: number;
msg: string;
data: {
balance?: string;
request_id?: number;
request_status?: string;
request_charge?: string;
recipients?: {
number: string;
charge: string;
status: string;
}[];
};
}
export declare const SmsNetBdErrors: {
readonly 0: "Success. Everything worked as expected.";
readonly 400: "The request was rejected, due to a missing or invalid parameter.";
readonly 403: "You don't have permissions to perform the request.";
readonly 404: "The requested resource not found.";
readonly 405: "Authorization required.";
readonly 409: "Unknown error occurred on Server end.";
readonly 410: "Account expired";
readonly 411: "Reseller Account expired or suspended";
readonly 412: "Invalid Schedule";
readonly 413: "Invalid Sender ID";
readonly 414: "Message is empty";
readonly 415: "Message is too long";
readonly 416: "No valid number found";
readonly 417: "Insufficient balance";
readonly 420: "Content Blocked";
};
//# sourceMappingURL=smsnetbd.d.ts.map