@nabcellent/textsms
v0.0.4
Published
TextSMS API Library
Downloads
1
Readme
TextSMS Api
This is a Typescript package that interfaces with the TextSMS Api. The API enables you to initiate mobile Sms notifications.
Documentation
Installation
You can install the package via npm or yarn:
yarn add @nabcellent/textsmsGetting Started
Initialize the TextSMS class with your config.
import {TextSMS, TextSMSConfig} from '@nabcellent/textsms';
let config: TextSMSConfig = {
apiKey: process.env.TEXTSMS_API_KEY,
partnerId: process.env.TEXTSMS_PARTNER_ID,
senderId: process.env.TEXTSMS_SENDER_ID
};
const textsms = new TextSMS(config);Sms
Enables you to send text messages
1. Send Sms
const data = {
message: 'Reminder for your appointment',
mobile: '254110039317',
}
const response = await textsms.sendSms(data);
// Expected responses
[
{
message_id: "7444f504-6760-43fd-9b40-2708da61d114",
code: 0,
description: "Success",
phone: "254123456789",
custom: ""
},
{
message_id: "",
code: 801,
description: "Country not found in master data",
phone: "89254736388405", // Invalid phone number
custom: ""
}
]2. Schedule Sms
Provide a Moment or Date instance to the send method.
import moment from "moment";
const response = await textsms.scheduleSms(data, moment().add(30, 'minutes'));PS: The date must be after current time.🌚
Account
Enables you to check the balance of your account
- Account balance
const balance = await textsms.getAccountBalance();
// Expected response
{
response_code: 200,
credit: 136,
partner_id: "12475"
}Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.
