@netgsm/sms
Version:
Netgsm API Client for SMS sending and reporting
160 lines (159 loc) • 3.28 kB
TypeScript
import { ApiErrorCode, BalanceType } from "./enums";
/**
* @module Types
* @description Type definitions for Netgsm API
*/
/**
* Configuration interface for Netgsm client
*/
export interface NetgsmConfig {
/** Netgsm API username */
username: string;
/** Netgsm API password */
password: string;
/** Optional application name for tracking */
appname?: string;
}
/**
* Base payload interface for API requests
*/
export interface BasePayload {
startdate?: string;
stopdate?: string;
appname?: string;
}
/**
* Payload for sending SMS via REST v2 API
*/
export interface RestSmsPayload {
msgheader: string;
appname?: string;
iysfilter?: string;
partnercode?: string;
encoding?: string;
startdate?: string;
stopdate?: string;
messages: {
msg: string;
no: string;
}[];
}
/**
* API error response structure
*/
export interface ApiError extends Error {
status: number;
statusText: string;
code?: string;
description?: string;
headers?: Headers;
url?: string;
}
/**
* API response structure for sending SMS.
*/
export interface ApiResponse {
code: ApiErrorCode;
description?: string;
jobid?: string;
}
/**
* API response structure for sending SMS via REST v2 API.
*/
export interface RestSmsResponse {
code: string;
description: string;
jobid?: string;
}
/**
* Payload for fetching SMS reports via Netgsm API.
*/
export interface ReportPayload extends BasePayload {
bulkIds?: string[];
pageNumber?: number;
pageSize?: number;
}
/**
* API response structure for fetching SMS reports.
*/
export interface ReportResponse {
code?: string;
description?: string;
jobs?: {
jobid: string;
number: string;
status: number;
operator: number;
msglen: number;
deliveredDate?: string;
errorCode?: number;
referansID?: string;
}[];
}
/**
* Payload for querying sender IDs/headers
*/
export interface HeaderQueryPayload {
appname?: string;
}
/**
* Response type for header query
*/
export interface HeaderQueryResponse {
msgheader?: string[];
code?: string;
description?: string;
msgheaders?: string[];
}
/**
* Payload for cancelling SMS
*/
export interface CancelSmsPayload {
jobid: string;
appname?: string;
}
/**
* Response type for SMS cancellation
*/
export interface CancelSmsResponse {
code: string;
description: string;
jobid?: string;
}
/**
* Payload for querying inbox messages
*/
export interface SmsInboxPayload {
appname?: string;
startdate?: string;
stopdate?: string;
}
/**
* Response type for inbox messages query
*/
export interface SmsInboxResponse {
code: string;
description: string;
messages?: {
message: string;
sender: string;
receiver: string;
datetime: string;
}[];
}
export interface BalancePayload {
stip: BalanceType;
appkey?: string;
}
/**
* API response structure for balance query
* stip=1: Package/campaign information
* stip=2: Credit information
*/
export interface BalanceResponse {
code?: string;
balance?: string | Array<{
amount: number;
balance_name: string;
}>;
}