msg91
Advanced tools
Comparing version 2.1.4 to 2.2.4
@@ -1,6 +0,6 @@ | ||
declare type Options = { | ||
type Options = { | ||
authKey: string; | ||
[key: string]: any; | ||
}; | ||
declare type Type = "voice" | "text"; | ||
type Type = "voice" | "text"; | ||
declare class Msg91 { | ||
@@ -16,2 +16,3 @@ private authKey?; | ||
authKey?: string; | ||
length?: number; | ||
}): Otp; | ||
@@ -22,7 +23,7 @@ getSMS(options?: { | ||
} | ||
declare type SmsOptions = { | ||
type SmsOptions = { | ||
senderId?: string; | ||
shortURL?: boolean; | ||
}; | ||
declare type SmsRecipients = { | ||
type SmsRecipients = { | ||
mobile: string; | ||
@@ -36,3 +37,3 @@ [key: string]: string; | ||
} | ||
declare type Channel = { | ||
type Channel = { | ||
campaign_id: number; | ||
@@ -42,3 +43,3 @@ channel_id: number; | ||
}; | ||
declare type CampaignType = { | ||
type CampaignType = { | ||
id: number; | ||
@@ -50,3 +51,3 @@ name: string; | ||
}; | ||
declare type Field = { | ||
type Field = { | ||
mapping: [{ | ||
@@ -66,5 +67,6 @@ [key: string]: any; | ||
} | ||
declare type OtpOptions = { | ||
type OtpOptions = { | ||
templateId?: string; | ||
expiry?: number; | ||
length?: number; | ||
}; | ||
@@ -74,3 +76,6 @@ declare class Otp { | ||
private authkey; | ||
constructor(templateId: string, authkey: string); | ||
private length; | ||
constructor(templateId: string, authkey: string, options?: { | ||
length?: number; | ||
}); | ||
retry(mobileNumber: string, type?: Type): Promise<unknown>; | ||
@@ -77,0 +82,0 @@ verify(mobileNumber: string, otp: string): Promise<unknown>; |
@@ -36,3 +36,3 @@ "use strict"; | ||
this.validateInit(); | ||
return new Otp(templateId, (options === null || options === void 0 ? void 0 : options.authKey) || this.authKey || ""); | ||
return new Otp(templateId, (options === null || options === void 0 ? void 0 : options.authKey) || this.authKey || "", { length: options === null || options === void 0 ? void 0 : options.length }); | ||
}; | ||
@@ -243,5 +243,7 @@ Msg91.prototype.getSMS = function (options) { | ||
var Otp = /** @class */ (function () { | ||
function Otp(templateId, authkey) { | ||
function Otp(templateId, authkey, options) { | ||
this.length = 4; | ||
this.templateId = templateId; | ||
this.authkey = authkey; | ||
this.length = (options === null || options === void 0 ? void 0 : options.length) || this.length; | ||
} | ||
@@ -256,2 +258,3 @@ Otp.prototype.retry = function (mobileNumber, type) { | ||
url.searchParams.append("authkey", _this.authkey); | ||
url.searchParams.append("otp_length", String(_this.length)); | ||
var config = { | ||
@@ -326,2 +329,3 @@ method: 'post', | ||
url.searchParams.append("authkey", _this.authkey); | ||
url.searchParams.append("otp_length", String((options === null || options === void 0 ? void 0 : options.length) || _this.length)); | ||
var config = { | ||
@@ -328,0 +332,0 @@ method: 'post', |
{ | ||
"name": "msg91", | ||
"version": "2.1.4", | ||
"version": "2.2.4", | ||
"description": "Official NodeJS package for msg91 services.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/src/index.js", |
@@ -24,3 +24,3 @@ # MSG91 | ||
```js | ||
let otp = msg91.getOTP("otpTemplateId"); | ||
let otp = msg91.getOTP("otpTemplateId", { length: 6 }); | ||
// Send OTP | ||
@@ -27,0 +27,0 @@ otp.send("MOBILE_NUMBER_WITH_COUNTRY_CODE"); |
20165
477