Gathering detailed insights and metrics for termii-nest-sdk
Gathering detailed insights and metrics for termii-nest-sdk
Gathering detailed insights and metrics for termii-nest-sdk
Gathering detailed insights and metrics for termii-nest-sdk
npm install termii-nest-sdk
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
7
21
The termii-nest-sdk is a NestJS-based software development kit (SDK) designed to simplify the integration of Termii APIs into NestJS projects. It provides a structured and efficient way to interact with Termii's messaging and authentication services.
To install the SDK, run the following command:
1npm install termii-nest-sdk
or with Yarn:
1yarn add termii-nest-sdk
To set up the SDK, import the module into your AppModule
and pass the required configuration options.
1import { Module } from '@nestjs/common'; 2import { TermiiSDKModule } from 'termii-nest-sdk'; 3 4@Module({ 5 imports: [ 6 TermiiSDKModule.register({ 7 apiKey: process.env.API_KEY, // Ensure API_KEY is set in your environment variables 8 baseUrl: 'https://v3.api.termii.com', 9 isGlobal: true // Optional flag (default: false). If false, you must import it into each module that needs it. 10 }), 11 ], 12}) 13export class AppModule {}
Ensure the following environment variables are set:
1API_KEY=[your_api_key] 2BASE_URL=https://v3.api.termii.com
Some Termii API requests require authentication. The SDK manages authentication using an API key, which must be provided during module registration.
Once configured, the SDK can be utilized in any service or controller.
1import { Injectable } from '@nestjs/common'; 2import { AbstractMessagingService } from 'termii-nest-sdk'; 3 4@Injectable() 5export class NotificationService { 6 constructor(private readonly messagingService: AbstractMessagingService) {} 7 8 async sendSMSMessage() { 9 const samplePayload = { 10 to: '[recipient]', // Recipient's phone number 11 from: '[sender_id]', // Approved sender ID 12 sms: 'Hi there, testing Termii', 13 type: '[message_type]', // Message type (e.g., plain) 14 channel: '[channel_type]', // Channel type (e.g., dnd, whatsapp, generic) 15 }; 16 17 return this.messagingService.sendSingleMessage(samplePayload); 18 } 19}
AbstractMessagingService
Handles sending text messages across different messaging channels.
AbstractNumberService
Manages sending messages using Termii's auto-generated messaging numbers.
AbstractSenderIDService
Retrieves registered business statuses and requests sender ID registration.
AbstractTokenService
Facilitates OTP (One-Time Password) sending and verification.
sendSingleMessage(payload: TmSingleMessageRequestPayload)
: Sends a message to a single recipient.sendBulkMessage(payload: TmBulkMessageRequestPayload)
: Sends messages to multiple recipients.sendMessage(payload: TmNumberPayload)
: Sends messages using Termii's generated numbers.fetchSenderId()
: Retrieves details of registered sender IDs.requestSenderId(payload: TmRequestSenderIDPayload)
: Requests a sender ID.sendToken(payload: TmSendTokenPayload)
: Sends OTPs across multiple channels.verifyToken(payload: TmVerifyTokenPayload)
: Verifies sent tokens.All SDK methods return structured responses. Errors can be managed using try-catch
blocks.
1try { 2 const response = await messagingService.sendSingleMessage(payload); 3 console.log(response); 4} catch (error) { 5 console.error('Error:', error.message); 6}
Enable verbose logging by setting the following environment variable:
1DEBUG=sdk:* npm start
This SDK is licensed under the MIT License. See the LICENSE
file for details.
We welcome contributions! Follow these steps to contribute:
For issues or questions, please open an issue on the GitHub repository or contact via email: osahondevengine@gmail.com.
No vulnerabilities found.
No security vulnerabilities found.