New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

termii-nodejs-client

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

termii-nodejs-client - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

dist/services/messaging/index.d.ts

2

dist/services/index.d.ts

@@ -1,1 +0,1 @@

export * from './message/message';
export * from './messaging/';

@@ -500,3 +500,4 @@ 'use strict';

var handleErrors = function handleErrors(error) {
return error.response.data;
var _error$response;
return error == null || (_error$response = error.response) == null ? void 0 : _error$response.data;
};

@@ -534,3 +535,3 @@

var _useRequest = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
var method, url, data;
var method, url, data, page, params;
return _regeneratorRuntime().wrap(function _callee$(_context) {

@@ -540,17 +541,21 @@ while (1) switch (_context.prev = _context.next) {

_context.prev = 0;
method = req.method, url = req.url, data = req.data;
method = req.method, url = req.url, data = req.data, page = req.page;
if (!(method === 'GET' || method === 'DELETE')) {
_context.next = 6;
_context.next = 8;
break;
}
params = {
api_key: this.apiKey
}; // Add 'page' to the params if it's provided in the request
if (method === 'GET' && page !== undefined) {
params.page = page;
}
return _context.abrupt("return", this.request({
method: method,
url: url,
params: {
api_key: this.apiKey
}
params: params
}));
case 6:
case 8:
if (!(method === 'POST' || method === 'PUT')) {
_context.next = 10;
_context.next = 12;
break;

@@ -565,11 +570,11 @@ }

}));
case 10:
case 12:
throw new BaseError({
message: 'Invalid HTTP method'
});
case 11:
_context.next = 16;
case 13:
_context.next = 18;
break;
case 13:
_context.prev = 13;
case 15:
_context.prev = 15;
_context.t0 = _context["catch"](0);

@@ -579,7 +584,7 @@ throw new BaseError({

});
case 16:
case 18:
case "end":
return _context.stop();
}
}, _callee, this, [[0, 13]]);
}, _callee, this, [[0, 15]]);
}));

@@ -623,3 +628,3 @@ function useRequest(_x) {

case 0:
// try {
_context.prev = 0;
requestObj = {

@@ -630,12 +635,16 @@ method: 'POST',

};
_context.next = 3;
_context.next = 4;
return this.useRequest(requestObj);
case 3:
case 4:
response = _context.sent;
return _context.abrupt("return", response == null ? void 0 : response.data);
case 5:
case 8:
_context.prev = 8;
_context.t0 = _context["catch"](0);
return _context.abrupt("return", handleErrors(_context.t0));
case 11:
case "end":
return _context.stop();
}
}, _callee, this);
}, _callee, this, [[0, 8]]);
}));

@@ -661,2 +670,3 @@ function sendMessage(_x) {

case 0:
_context2.prev = 0;
requestObj = {

@@ -667,12 +677,16 @@ method: 'POST',

};
_context2.next = 3;
_context2.next = 4;
return this.useRequest(requestObj);
case 3:
case 4:
response = _context2.sent;
return _context2.abrupt("return", response == null ? void 0 : response.data);
case 5:
case 8:
_context2.prev = 8;
_context2.t0 = _context2["catch"](0);
return _context2.abrupt("return", handleErrors(_context2.t0));
case 11:
case "end":
return _context2.stop();
}
}, _callee2, this);
}, _callee2, this, [[0, 8]]);
}));

@@ -688,2 +702,134 @@ function sendBulkMessage(_x2) {

/**
* A class handling Sender ID functionalities, extends TermiiCore.
*/
var SenderId = /*#__PURE__*/function (_TermiiCore) {
_inheritsLoose(SenderId, _TermiiCore);
function SenderId(apiKey) {
return _TermiiCore.call(this, apiKey) || this;
}
/**
* Fetches sender IDs.
* @param {number} [page] - Optional page number for pagination.
* @returns {Promise<ISenderIDResponse>} - A promise containing the response with sender IDs.
*/
var _proto = SenderId.prototype;
_proto.fetchSenderIDs =
/*#__PURE__*/
function () {
var _fetchSenderIDs = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(page) {
var requestObj, response;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
_context.prev = 0;
requestObj = {
method: 'GET',
url: "/sender-id",
page: page
};
_context.next = 4;
return this.useRequest(requestObj);
case 4:
response = _context.sent;
return _context.abrupt("return", response == null ? void 0 : response.data);
case 8:
_context.prev = 8;
_context.t0 = _context["catch"](0);
return _context.abrupt("return", handleErrors(_context.t0));
case 11:
case "end":
return _context.stop();
}
}, _callee, this, [[0, 8]]);
}));
function fetchSenderIDs(_x) {
return _fetchSenderIDs.apply(this, arguments);
}
return fetchSenderIDs;
}()
/**
* Requests a new Sender ID.
* @param {IRequestSenderID} data - Data for requesting a new Sender ID.
* @returns {Promise<IRequestSenderIDResponse>} - A promise containing the response to the Sender ID request.
*/
;
_proto.requestSenderID =
/*#__PURE__*/
function () {
var _requestSenderID = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data) {
var requestObj, response;
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
_context2.prev = 0;
requestObj = {
method: 'POST',
url: "/sender-id/request",
data: data
};
_context2.next = 4;
return this.useRequest(requestObj);
case 4:
response = _context2.sent;
return _context2.abrupt("return", response == null ? void 0 : response.data);
case 8:
_context2.prev = 8;
_context2.t0 = _context2["catch"](0);
return _context2.abrupt("return", handleErrors(_context2.t0));
case 11:
case "end":
return _context2.stop();
}
}, _callee2, this, [[0, 8]]);
}));
function requestSenderID(_x2) {
return _requestSenderID.apply(this, arguments);
}
return requestSenderID;
}();
return SenderId;
}(TermiiCore);
/**
* The MessageHandler class handles message-related functionalities by providing access to message and sender ID instances.
*/
var MessageHandler = /*#__PURE__*/function () {
/**
* Constructs a MessageHandler instance.
* @constructor
* @param {string} apiKey - The API key used for authorization.
*/
function MessageHandler(apiKey) {
// Initialize the message and sender ID instances with the provided API key.
this.messageInstance = new Message(apiKey);
this.senderIdInstance = new SenderId(apiKey);
}
/**
* Provides access to message-related methods.
* @type {Object}
* @property {Function} sendMessage - Sends a single message.
* @property {Function} sendBulkMessage - Sends messages in bulk.
* @property {Function} fetchSenderIDs - Retrieves sender IDs.
* @property {Function} requestSenderID - Requests a sender ID.
* @returns {Object} - Object containing methods related to messages and sender IDs.
*/
_createClass(MessageHandler, [{
key: "message",
get: function get() {
return {
// Method to send a single message
sendMessage: this.messageInstance.sendMessage.bind(this.messageInstance),
// Method to send messages in bulk
sendBulkMessage: this.messageInstance.sendBulkMessage.bind(this.messageInstance),
// Method to fetch sender IDs
fetchSenderIDs: this.senderIdInstance.fetchSenderIDs.bind(this.senderIdInstance),
// Method to request a sender ID
requestSenderID: this.senderIdInstance.requestSenderID.bind(this.senderIdInstance)
};
}
}]);
return MessageHandler;
}();
/**
* The Termii class is the main class used to access the other classes in the Termii library.

@@ -697,12 +843,15 @@ * @class Termii

var Termii = /*#__PURE__*/function () {
/**
* Creates an instance of Termii.
* @constructor
* @param {string} apiKey - The API key used for authorization.
*/
function Termii(apiKey) {
this.apiKey = apiKey;
// Initialize the Message instance with the API key.
this.messageInstance = new Message(apiKey);
// Initialize the MessageHandler instance with the API key.
this.messageInstance = new MessageHandler(apiKey);
}
/**
* Provides access to methods related to sending messages.
* @type {Object}
* @property {Function} sendMessage - Sends a single message.
* @property {Function} sendBulkMessage - Sends messages in bulk.
* Provides access to the MessageHandler instance for sending messages.
* @type {MessageHandler}
* @example

@@ -713,8 +862,5 @@ * const termii = new Termii('pk_NjI3ZmVmYmU1YTY1ZWM5OWJhOWFmMGJlOjoxMjE2NzA');

_createClass(Termii, [{
key: "switch",
key: "message",
get: function get() {
return {
sendMessage: this.messageInstance.sendMessage.bind(this.messageInstance),
sendBulkMessage: this.messageInstance.sendBulkMessage.bind(this.messageInstance)
};
return this.messageInstance.message;
}

@@ -721,0 +867,0 @@ }]);

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=(t=require("axios"))&&"object"==typeof t&&"default"in t?t.default:t;function r(){r=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=Object.create((e&&e.prototype instanceof h?e:h).prototype),a=new _(n||[]);return o(i,"_invoke",{value:O(t,r,a)}),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var p={};function h(){}function v(){}function y(){}var d={};s(d,a,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(P([])));m&&m!==e&&n.call(m,a)&&(d=m);var b=y.prototype=h.prototype=Object.create(d);function w(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){var r;o(this,"_invoke",{value:function(o,i){function a(){return new e((function(r,a){!function r(o,i,a,u){var c=l(t[o],t,i);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==typeof f&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,u)}))}u(c.arg)}(o,i,r,a)}))}return r=r?r.then(a,a):a()}})}function O(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=j(a,r);if(u){if(u===p)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=l(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function j(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,j(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var o=l(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function _(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function P(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:k}}function k(){return{value:void 0,done:!0}}return v.prototype=y,o(b,"constructor",{value:y,configurable:!0}),o(y,"constructor",{value:v,configurable:!0}),v.displayName=s(y,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,s(t,c,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(x.prototype),s(x.prototype,u,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(f(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),s(b,c,"Generator"),s(b,a,(function(){return this})),s(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=P,_.prototype={constructor:_,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function n(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function o(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function u(t){n(a,o,i,u,c,"next",t)}function c(t){n(a,o,i,u,c,"throw",t)}u(void 0)}))}}function i(){return(i=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function a(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,c(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(t,e){return(c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function s(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function f(t,e,r){return(f=s()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&c(o,r.prototype),o}).apply(null,arguments)}function l(t){var e="function"==typeof Map?new Map:void 0;return(l=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return f(t,arguments,u(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),c(r,t)})(t)}var p=function(t){function e(e){var r;return void 0===e&&(e={}),r=t.call(this)||this,Error.captureStackTrace(function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(r),r.constructor),r.name=r.constructor.name,r.message=e.message,r}return a(e,t),e}(l(Error)),h=function(t){function e(e){return t.call(this,e)||this}a(e,t);var n=e.prototype;return n.sendMessage=function(){var t=o(r().mark((function t(e){var n,o;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={method:"POST",url:"/sms/send",data:e},t.next=3,this.useRequest(n);case 3:return t.abrupt("return",null==(o=t.sent)?void 0:o.data);case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.sendBulkMessage=function(){var t=o(r().mark((function t(e){var n,o;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={method:"POST",url:"/sms/send/bulk",data:e},t.next=3,this.useRequest(n);case 3:return t.abrupt("return",null==(o=t.sent)?void 0:o.data);case 5:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e}(function(){function t(t){this.apiKey=t,this.apiKey=t,this.request=e.create({baseURL:"https://api.ng.termii.com/api",headers:{Accept:"application/json","Content-Type":"application/json"}})}return t.prototype.useRequest=function(){var t=o(r().mark((function t(e){var n,o,a;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,o=e.url,a=e.data,"GET"!==(n=e.method)&&"DELETE"!==n){t.next=6;break}return t.abrupt("return",this.request({method:n,url:o,params:{api_key:this.apiKey}}));case 6:if("POST"!==n&&"PUT"!==n){t.next=10;break}return t.abrupt("return",this.request({method:n,url:o,data:i({},a,{api_key:this.apiKey})}));case 10:throw new p({message:"Invalid HTTP method"});case 11:t.next=16;break;case 13:throw t.prev=13,t.t0=t.catch(0),new p({message:(r=t.t0,r.response.data)});case 16:case"end":return t.stop()}var r}),t,this,[[0,13]])})));return function(e){return t.apply(this,arguments)}}(),t}());exports.Termii=function(){function t(t){this.apiKey=t,this.messageInstance=new h(t)}var e,r;return e=t,(r=[{key:"switch",get:function(){return{sendMessage:this.messageInstance.sendMessage.bind(this.messageInstance),sendBulkMessage:this.messageInstance.sendBulkMessage.bind(this.messageInstance)}}}])&&function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,"symbol"==typeof(o=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key))?o:String(o),n)}var o}(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}();
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=(t=require("axios"))&&"object"==typeof t&&"default"in t?t.default:t;function r(){r=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=Object.create((e&&e.prototype instanceof h?e:h).prototype),a=new I(n||[]);return o(i,"_invoke",{value:O(t,r,a)}),i}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=f;var p={};function h(){}function d(){}function v(){}var y={};s(y,a,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(P([])));m&&m!==e&&n.call(m,a)&&(y=m);var b=v.prototype=h.prototype=Object.create(y);function w(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){var r;o(this,"_invoke",{value:function(o,i){function a(){return new e((function(r,a){!function r(o,i,a,u){var c=l(t[o],t,i);if("throw"!==c.type){var s=c.arg,f=s.value;return f&&"object"==typeof f&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,u)}),(function(t){r("throw",t,a,u)})):e.resolve(f).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,u)}))}u(c.arg)}(o,i,r,a)}))}return r=r?r.then(a,a):a()}})}function O(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=E(a,r);if(u){if(u===p)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=l(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===p)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var o=l(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,p;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function j(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(j,this),this.reset(!0)}function P(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:_}}function _(){return{value:void 0,done:!0}}return d.prototype=v,o(b,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:d,configurable:!0}),d.displayName=s(v,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,s(t,c,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},w(x.prototype),s(x.prototype,u,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new x(f(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(b),s(b,c,"Generator"),s(b,a,(function(){return this})),s(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=P,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function n(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function o(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function u(t){n(a,o,i,u,c,"next",t)}function c(t){n(a,o,i,u,c,"throw",t)}u(void 0)}))}}function i(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,"symbol"==typeof(o=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key))?o:String(o),n)}var o}function a(t,e,r){return e&&i(t.prototype,e),r&&i(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function u(){return(u=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function c(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,f(t,e)}function s(t){return(s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function f(t,e){return(f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function p(t,e,r){return(p=l()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&f(o,r.prototype),o}).apply(null,arguments)}function h(t){var e="function"==typeof Map?new Map:void 0;return(h=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return p(t,arguments,s(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),f(r,t)})(t)}var d=function(t){function e(e){var r;return void 0===e&&(e={}),r=t.call(this)||this,Error.captureStackTrace(function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(r),r.constructor),r.name=r.constructor.name,r.message=e.message,r}return c(e,t),e}(h(Error)),v=function(t){var e;return null==t||null==(e=t.response)?void 0:e.data},y=function(){function t(t){this.apiKey=t,this.apiKey=t,this.request=e.create({baseURL:"https://api.ng.termii.com/api",headers:{Accept:"application/json","Content-Type":"application/json"}})}return t.prototype.useRequest=function(){var t=o(r().mark((function t(e){var n,o,i,a,c;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,o=e.url,i=e.data,a=e.page,"GET"!==(n=e.method)&&"DELETE"!==n){t.next=8;break}return c={api_key:this.apiKey},"GET"===n&&void 0!==a&&(c.page=a),t.abrupt("return",this.request({method:n,url:o,params:c}));case 8:if("POST"!==n&&"PUT"!==n){t.next=12;break}return t.abrupt("return",this.request({method:n,url:o,data:u({},i,{api_key:this.apiKey})}));case 12:throw new d({message:"Invalid HTTP method"});case 13:t.next=18;break;case 15:throw t.prev=15,t.t0=t.catch(0),new d({message:v(t.t0)});case 18:case"end":return t.stop()}}),t,this,[[0,15]])})));return function(e){return t.apply(this,arguments)}}(),t}(),g=function(t){function e(e){return t.call(this,e)||this}c(e,t);var n=e.prototype;return n.sendMessage=function(){var t=o(r().mark((function t(e){var n,o;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,n={method:"POST",url:"/sms/send",data:e},t.next=4,this.useRequest(n);case 4:return t.abrupt("return",null==(o=t.sent)?void 0:o.data);case 8:return t.prev=8,t.t0=t.catch(0),t.abrupt("return",v(t.t0));case 11:case"end":return t.stop()}}),t,this,[[0,8]])})));return function(e){return t.apply(this,arguments)}}(),n.sendBulkMessage=function(){var t=o(r().mark((function t(e){var n,o;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,n={method:"POST",url:"/sms/send/bulk",data:e},t.next=4,this.useRequest(n);case 4:return t.abrupt("return",null==(o=t.sent)?void 0:o.data);case 8:return t.prev=8,t.t0=t.catch(0),t.abrupt("return",v(t.t0));case 11:case"end":return t.stop()}}),t,this,[[0,8]])})));return function(e){return t.apply(this,arguments)}}(),e}(y),m=function(t){function e(e){return t.call(this,e)||this}c(e,t);var n=e.prototype;return n.fetchSenderIDs=function(){var t=o(r().mark((function t(e){var n,o;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,n={method:"GET",url:"/sender-id",page:e},t.next=4,this.useRequest(n);case 4:return t.abrupt("return",null==(o=t.sent)?void 0:o.data);case 8:return t.prev=8,t.t0=t.catch(0),t.abrupt("return",v(t.t0));case 11:case"end":return t.stop()}}),t,this,[[0,8]])})));return function(e){return t.apply(this,arguments)}}(),n.requestSenderID=function(){var t=o(r().mark((function t(e){var n,o;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,n={method:"POST",url:"/sender-id/request",data:e},t.next=4,this.useRequest(n);case 4:return t.abrupt("return",null==(o=t.sent)?void 0:o.data);case 8:return t.prev=8,t.t0=t.catch(0),t.abrupt("return",v(t.t0));case 11:case"end":return t.stop()}}),t,this,[[0,8]])})));return function(e){return t.apply(this,arguments)}}(),e}(y),b=function(){function t(t){this.messageInstance=new g(t),this.senderIdInstance=new m(t)}return a(t,[{key:"message",get:function(){return{sendMessage:this.messageInstance.sendMessage.bind(this.messageInstance),sendBulkMessage:this.messageInstance.sendBulkMessage.bind(this.messageInstance),fetchSenderIDs:this.senderIdInstance.fetchSenderIDs.bind(this.senderIdInstance),requestSenderID:this.senderIdInstance.requestSenderID.bind(this.senderIdInstance)}}}]),t}();exports.Termii=function(){function t(t){this.apiKey=t,this.messageInstance=new b(t)}return a(t,[{key:"message",get:function(){return this.messageInstance.message}}]),t}();
//# sourceMappingURL=termii-nodejs-client.cjs.production.min.js.map

@@ -494,3 +494,4 @@ import axios from 'axios';

var handleErrors = function handleErrors(error) {
return error.response.data;
var _error$response;
return error == null || (_error$response = error.response) == null ? void 0 : _error$response.data;
};

@@ -528,3 +529,3 @@

var _useRequest = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
var method, url, data;
var method, url, data, page, params;
return _regeneratorRuntime().wrap(function _callee$(_context) {

@@ -534,17 +535,21 @@ while (1) switch (_context.prev = _context.next) {

_context.prev = 0;
method = req.method, url = req.url, data = req.data;
method = req.method, url = req.url, data = req.data, page = req.page;
if (!(method === 'GET' || method === 'DELETE')) {
_context.next = 6;
_context.next = 8;
break;
}
params = {
api_key: this.apiKey
}; // Add 'page' to the params if it's provided in the request
if (method === 'GET' && page !== undefined) {
params.page = page;
}
return _context.abrupt("return", this.request({
method: method,
url: url,
params: {
api_key: this.apiKey
}
params: params
}));
case 6:
case 8:
if (!(method === 'POST' || method === 'PUT')) {
_context.next = 10;
_context.next = 12;
break;

@@ -559,11 +564,11 @@ }

}));
case 10:
case 12:
throw new BaseError({
message: 'Invalid HTTP method'
});
case 11:
_context.next = 16;
case 13:
_context.next = 18;
break;
case 13:
_context.prev = 13;
case 15:
_context.prev = 15;
_context.t0 = _context["catch"](0);

@@ -573,7 +578,7 @@ throw new BaseError({

});
case 16:
case 18:
case "end":
return _context.stop();
}
}, _callee, this, [[0, 13]]);
}, _callee, this, [[0, 15]]);
}));

@@ -617,3 +622,3 @@ function useRequest(_x) {

case 0:
// try {
_context.prev = 0;
requestObj = {

@@ -624,12 +629,16 @@ method: 'POST',

};
_context.next = 3;
_context.next = 4;
return this.useRequest(requestObj);
case 3:
case 4:
response = _context.sent;
return _context.abrupt("return", response == null ? void 0 : response.data);
case 5:
case 8:
_context.prev = 8;
_context.t0 = _context["catch"](0);
return _context.abrupt("return", handleErrors(_context.t0));
case 11:
case "end":
return _context.stop();
}
}, _callee, this);
}, _callee, this, [[0, 8]]);
}));

@@ -655,2 +664,3 @@ function sendMessage(_x) {

case 0:
_context2.prev = 0;
requestObj = {

@@ -661,12 +671,16 @@ method: 'POST',

};
_context2.next = 3;
_context2.next = 4;
return this.useRequest(requestObj);
case 3:
case 4:
response = _context2.sent;
return _context2.abrupt("return", response == null ? void 0 : response.data);
case 5:
case 8:
_context2.prev = 8;
_context2.t0 = _context2["catch"](0);
return _context2.abrupt("return", handleErrors(_context2.t0));
case 11:
case "end":
return _context2.stop();
}
}, _callee2, this);
}, _callee2, this, [[0, 8]]);
}));

@@ -682,2 +696,134 @@ function sendBulkMessage(_x2) {

/**
* A class handling Sender ID functionalities, extends TermiiCore.
*/
var SenderId = /*#__PURE__*/function (_TermiiCore) {
_inheritsLoose(SenderId, _TermiiCore);
function SenderId(apiKey) {
return _TermiiCore.call(this, apiKey) || this;
}
/**
* Fetches sender IDs.
* @param {number} [page] - Optional page number for pagination.
* @returns {Promise<ISenderIDResponse>} - A promise containing the response with sender IDs.
*/
var _proto = SenderId.prototype;
_proto.fetchSenderIDs =
/*#__PURE__*/
function () {
var _fetchSenderIDs = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(page) {
var requestObj, response;
return _regeneratorRuntime().wrap(function _callee$(_context) {
while (1) switch (_context.prev = _context.next) {
case 0:
_context.prev = 0;
requestObj = {
method: 'GET',
url: "/sender-id",
page: page
};
_context.next = 4;
return this.useRequest(requestObj);
case 4:
response = _context.sent;
return _context.abrupt("return", response == null ? void 0 : response.data);
case 8:
_context.prev = 8;
_context.t0 = _context["catch"](0);
return _context.abrupt("return", handleErrors(_context.t0));
case 11:
case "end":
return _context.stop();
}
}, _callee, this, [[0, 8]]);
}));
function fetchSenderIDs(_x) {
return _fetchSenderIDs.apply(this, arguments);
}
return fetchSenderIDs;
}()
/**
* Requests a new Sender ID.
* @param {IRequestSenderID} data - Data for requesting a new Sender ID.
* @returns {Promise<IRequestSenderIDResponse>} - A promise containing the response to the Sender ID request.
*/
;
_proto.requestSenderID =
/*#__PURE__*/
function () {
var _requestSenderID = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data) {
var requestObj, response;
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
while (1) switch (_context2.prev = _context2.next) {
case 0:
_context2.prev = 0;
requestObj = {
method: 'POST',
url: "/sender-id/request",
data: data
};
_context2.next = 4;
return this.useRequest(requestObj);
case 4:
response = _context2.sent;
return _context2.abrupt("return", response == null ? void 0 : response.data);
case 8:
_context2.prev = 8;
_context2.t0 = _context2["catch"](0);
return _context2.abrupt("return", handleErrors(_context2.t0));
case 11:
case "end":
return _context2.stop();
}
}, _callee2, this, [[0, 8]]);
}));
function requestSenderID(_x2) {
return _requestSenderID.apply(this, arguments);
}
return requestSenderID;
}();
return SenderId;
}(TermiiCore);
/**
* The MessageHandler class handles message-related functionalities by providing access to message and sender ID instances.
*/
var MessageHandler = /*#__PURE__*/function () {
/**
* Constructs a MessageHandler instance.
* @constructor
* @param {string} apiKey - The API key used for authorization.
*/
function MessageHandler(apiKey) {
// Initialize the message and sender ID instances with the provided API key.
this.messageInstance = new Message(apiKey);
this.senderIdInstance = new SenderId(apiKey);
}
/**
* Provides access to message-related methods.
* @type {Object}
* @property {Function} sendMessage - Sends a single message.
* @property {Function} sendBulkMessage - Sends messages in bulk.
* @property {Function} fetchSenderIDs - Retrieves sender IDs.
* @property {Function} requestSenderID - Requests a sender ID.
* @returns {Object} - Object containing methods related to messages and sender IDs.
*/
_createClass(MessageHandler, [{
key: "message",
get: function get() {
return {
// Method to send a single message
sendMessage: this.messageInstance.sendMessage.bind(this.messageInstance),
// Method to send messages in bulk
sendBulkMessage: this.messageInstance.sendBulkMessage.bind(this.messageInstance),
// Method to fetch sender IDs
fetchSenderIDs: this.senderIdInstance.fetchSenderIDs.bind(this.senderIdInstance),
// Method to request a sender ID
requestSenderID: this.senderIdInstance.requestSenderID.bind(this.senderIdInstance)
};
}
}]);
return MessageHandler;
}();
/**
* The Termii class is the main class used to access the other classes in the Termii library.

@@ -691,12 +837,15 @@ * @class Termii

var Termii = /*#__PURE__*/function () {
/**
* Creates an instance of Termii.
* @constructor
* @param {string} apiKey - The API key used for authorization.
*/
function Termii(apiKey) {
this.apiKey = apiKey;
// Initialize the Message instance with the API key.
this.messageInstance = new Message(apiKey);
// Initialize the MessageHandler instance with the API key.
this.messageInstance = new MessageHandler(apiKey);
}
/**
* Provides access to methods related to sending messages.
* @type {Object}
* @property {Function} sendMessage - Sends a single message.
* @property {Function} sendBulkMessage - Sends messages in bulk.
* Provides access to the MessageHandler instance for sending messages.
* @type {MessageHandler}
* @example

@@ -707,8 +856,5 @@ * const termii = new Termii('pk_NjI3ZmVmYmU1YTY1ZWM5OWJhOWFmMGJlOjoxMjE2NzA');

_createClass(Termii, [{
key: "switch",
key: "message",
get: function get() {
return {
sendMessage: this.messageInstance.sendMessage.bind(this.messageInstance),
sendBulkMessage: this.messageInstance.sendBulkMessage.bind(this.messageInstance)
};
return this.messageInstance.message;
}

@@ -715,0 +861,0 @@ }]);

@@ -12,13 +12,16 @@ /**

/**
* An instance of the Message class for sending messages.
* An instance of the MessageHandler class for sending messages.
* @private
* @type {Message}
* @type {MessageHandler}
*/
private messageInstance;
/**
* Creates an instance of Termii.
* @constructor
* @param {string} apiKey - The API key used for authorization.
*/
constructor(apiKey: string);
/**
* Provides access to methods related to sending messages.
* @type {Object}
* @property {Function} sendMessage - Sends a single message.
* @property {Function} sendBulkMessage - Sends messages in bulk.
* Provides access to the MessageHandler instance for sending messages.
* @type {MessageHandler}
* @example

@@ -28,6 +31,8 @@ * const termii = new Termii('pk_NjI3ZmVmYmU1YTY1ZWM5OWJhOWFmMGJlOjoxMjE2NzA');

*/
get switch(): {
get message(): {
sendMessage: (data: import("./types").ISendMessage) => Promise<import("./types").ISendMessageResponse>;
sendBulkMessage: (data: import("./types").ISendBulkMessage) => Promise<import("./types").ISendBulkMessageResponse>;
fetchSenderIDs: (page?: number | undefined) => Promise<import("./types").ISenderIDResponse>;
requestSenderID: (data: import("./types").IRequestSenderID) => Promise<import("./types").IRequestSenderIDResponse>;
};
}
export * from './message';
export * from './sender-id';

@@ -0,2 +1,3 @@

import { AxiosError } from 'axios';
export declare const handleErrors: (error: any) => any;
export declare const handleAxiosError: (error: any) => any;
export declare const handleAxiosError: (error: AxiosError) => string;

@@ -5,2 +5,1 @@ export * from './error';

export * from './handle-errors';
export * from './exclude-field';

@@ -5,2 +5,3 @@ export interface IAxiosStruct {

data?: any;
page?: number;
}
{
"name": "termii-nodejs-client",
"version": "0.1.2",
"version": "0.2.0",
"description": "Nodejs SDK wrapper for Termii API written with Typescript support",

@@ -22,3 +22,3 @@ "author": "Emmanuel Raymond",

"engines": {
"node": ">=18"
"node": ">=16"
},

@@ -25,0 +25,0 @@ "scripts": {

@@ -1,1 +0,150 @@

# termii-node-sdk
# Termii Node SDK
![npm (scoped)](https://img.shields.io/npm/v/termii-nodejs-client?color=%23FF7B37&style=flat-square) ![npm](https://img.shields.io/npm/dm/termii-nodejs-client?style=flat-square) ![Twitter Follow](https://img.shields.io/twitter/follow/peoray_?style=social)
Nodejs SDK for [Termii](https://termii.com) messaging platform written in typescript
## Table of content
- [Prerequisites](#prerequisites)
- [Getting started](#getting-started)
- [Installation](#installation)
- [Usage](#usage)
- [Documentation](#documentation)
- [License](#license)
## Prerequisite
Node v16 and higher is required. To make sure you have them available on your machine, try running the following command.
```sh
node -v
```
## Getting Started
To get started with this SDK, create an account on [Termii](https://accounts.termii.com/#/register) if you haven't already.
You can then retrieve your API keys from your Termii dashboard.
## Installation
This SDK can be installed with npm or yarn or pnpm.
```sh
# using npm
npm install termii-nodejs-client
# using yarn
yarn install termii-nodejs-client
# using pnpm
pnpm add termii-nodejs-client
```
## Usage
Import and Initialize the library
```ts
// use modules
import { Termii } from 'termii-nodejs-client';
// use cjs
const {Termii} = require('termii-nodejs-client')
const termii = new Termii('YOUR_API_KEY');
```
Instantiate the Termii class
```ts
const termii = new Termii('YOUR_API_KEY');
```
> **Warning**
Be sure to keep your API Credentials securely in environment variables.
## Documentation
Available Services exposed by the SDK
### Sender ID
A Sender ID is the name or number that identifies the sender of an SMS message.
#### Fetch Sender ID
```ts
// returns the first 15 sender ids
const senderIds = await termii.message.fetchSenderIDs()
// to get the next page of sender ids
const senderIds = await termii.message.fetchSenderIDs(2)
```
Find more details about the parameters and response for the above method [here](https://developers.termii.com/sender-id#fetch-sender-id)
#### Create Sender ID
```ts
// import the request sender id interface from the sdk
import { type IRequestSenderID } from 'termii-nodejs-client';
const message: IRequestSenderID = {
sender_id: 'acme',
usecase: 'Testing! Working!! This is it!!!',
company: 'Metalabs',
}
const senderIds = await termii.message.requestSenderID(payload)
```
Find more details about the parameters and response for the above method [here](https://developers.termii.com/sender-id#request-sender-id)
### Message
This API allows businesses send text messages to their customers across different messaging channels.
#### Send message
```ts
// import the request sender id interface from the sdk
import { type ISendMessage } from 'termii-nodejs-client';
const message: ISendMessage = {
to: "2347880234567",
from: "talert",
sms: "Hi there, testing Termii",
type: "plain",
channel: "generic",
api_key: "Your API Key",
media: {
url: "https://media.example.com/file",
caption: "your media file"
}
}
const senderIds = await termii.message.sendMessage(payload)
```
Find more details about the parameters and response for the above method [here](https://developers.termii.com/messaging-api#send-message)
#### Send Bulk message
```ts
// import the request sender id interface from the sdk
import { type ISendMessage } from 'termii-nodejs-client';
const message: ISendMessage = {
to: ["23490555546", "23423490126999","23490555546"],
from: "talert",
sms: "Hi there, testing Termii",
type: "plain",
channel: "generic"
}
const senderIds = await termii.message.sendBulkMessage(payload)
```
Find more details about the parameters and response for the above method [here](https://developers.termii.com/messaging-api#send-bulk-message)
## License
[MIT](https://github.com/peoray/termii-nodejs-client/blob/main/LICENSE)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc