releans
v1.0.4
Published
A node library to implement Releans SMS Api Service
Downloads
9
Maintainers
Readme
Releans
A node library to implement Releans SMS API. License MIT
Releans Docs
SMS API
Send a message
import { SMS } from 'releans';
const config: IConfig = {
apiKey: 'your-key',
}
const data: IMessageData = {
sender: 'SenderName',
mobile: 'E164FormatNumber',
content: 'Your content'
};
const sms = new SMS(config);
const result = await sms.send(data);
if (result.data) {
console.dir(result.data)
}
if(result.error) {
console.log(result.error);
}
Retrieve all messages
import { SMS } from 'releans';
const config: IConfig = {
apiKey: 'your-key',
}
const sms = new SMS(config);
const result = await sms.retrieveAll();
if (result.data) {
console.dir(result.data)
}
if(result.error) {
console.log(result.error);
}
Retrieve messages by date
import { SMS } from 'releans';
const config: IConfig = {
apiKey: 'your-key',
}
const date = '2023-05-16' //'yyyy-MM-dd'
const sms = new SMS(config);
const result = await sms.retrieveByDate(date);
if (result.data) {
console.dir(result.data)
}
if(result.error) {
console.log(result.error);
}
Retrieve a message by messageId
import { SMS } from 'releans';
const config: IConfig = {
apiKey: 'your-key',
}
const messageId = 12345678
const sms = new SMS(config);
const result = await sms.retrieveByMessageId(messageId);
if (result.data) {
console.dir(result.data)
}
if(result.error) {
console.log(result.error);
}
OTP / Verify API
Send OTP Code
import { OTP } from 'releans';
const config: IConfig = {
apiKey: 'your-key',
}
const data: IOTPSendData = {
sender: 'Sender Name',
mobile: 'E164FormatNumber',
channel: 'sms' // sms or voice
};
const otp = new OTP(config);
const result = await otp.send(data);
if (result.data) {
console.dir(result.data)
}
if(result.error) {
console.log(result.error);
}
Verify OTP Code
import { OTP } from 'releans';
const config: IConfig = {
apiKey: 'your-key',
}
const data: IOTPVerifyData = {
mobile: 'E164FormatNumber',
code: '123456'
};
const otp = new OTP(config);
const result = await otp.verify(data);
if (result.data) {
console.dir(result.data)
}
if(result.error) {
console.log(result.error);
}
Balance API
import { Balance } from 'releans';
const config: IConfig = {
apiKey: 'your-key',
}
const balance = new Balance(config);
const result = await balance.retrieve();
if (result.data) {
console.dir(result.data)
}
if(result.error) {
console.log(result.error);
}