diff --git a/README.md b/README.md index 9f75b93..7447b31 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,8 @@ await msg91otp.retry("919999999999",true) **userip** : `string` User IP +**extra_param** : Here you can pass the variables created in the SendOTP template. + ### Licence: (MIT License) **Copyright (c) 2018 Sumeet Bhardwaj** diff --git a/package.json b/package.json index 5a8f093..e55db6c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "msg91-lib", - "version": "2.0.1", + "version": "2.0.2", "description": "Unofficial msg91 library to send OTP & messages", "main": "index.js", "scripts": { @@ -11,6 +11,7 @@ "url": "git+https://github.com/sumitsk20/msg91-lib.git" }, "homepage": "https://github.com/sumitsk20/msg91-lib/tree/v2.x", + "types": "./types/index.d.ts", "keywords": [ "msg91", "otp", diff --git a/src/msg91OTP.js b/src/msg91OTP.js index 7c2addf..22568a0 100644 --- a/src/msg91OTP.js +++ b/src/msg91OTP.js @@ -55,7 +55,8 @@ class Msg91Otp { otp_expiry: args.expiry || this.defaultOtpExpiry, otp_length: args.otpLength || this.defaultOtpLength, email: args.email || '', - invisible: args.invisible || 1 + invisible: args.invisible || 1, + extra_param: args.extra_param || '' } }; return await makeRequest(options); diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..55cf151 --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,29 @@ +interface IMsg91OtpConstructorArgs { + authKey: string; + templateId: string; + baseUrl?: string; + apiVersion?: string; + otpExpiry?: number; + otpLength?: number; +} + +interface IMsg91SendOtpArgs { + templateId?: string; + expiry?: number; + otpLength?: number; + email?: string; + invisible?: 0 | 1; + extra_param: any; +} + +declare class Msg91Otp { + constructor(args: IMsg91OtpConstructorArgs); + + send(contactNumber: string | number, args?: IMsg91SendOtpArgs): Promise; + + retry(contactNumber: string | number, retryType?: string): Promise; + + verify(contactNumber: string | number, otp: number | string): Promise; +} + +export { Msg91Otp as msg91OTP };