From bf4f74f48d84aa7fdff238b88e5ccf3235329689 Mon Sep 17 00:00:00 2001 From: Sree Teja Date: Wed, 27 Jan 2021 18:50:33 +0530 Subject: [PATCH 1/3] extra_param parameter in send request. extra_param option added in send request, which is used for setting variables that are set in SendOTP template. --- src/msg91OTP.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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); From 628b3fc68658e47af4582514f550f0faae7990fa Mon Sep 17 00:00:00 2001 From: Sree Teja Date: Wed, 27 Jan 2021 19:39:53 +0530 Subject: [PATCH 2/3] update readme updated readme to the pull request #9 added extra_param in optional parameters, did not specify the type as obj or string can be passed --- README.md | 2 ++ 1 file changed, 2 insertions(+) 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** From 9aac70eb96c5e3e41dfd8b960ce02cd339a0b6aa Mon Sep 17 00:00:00 2001 From: Sree Teja Date: Thu, 28 Jan 2021 08:56:25 +0530 Subject: [PATCH 3/3] added types --- package.json | 3 ++- types/index.d.ts | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 types/index.d.ts 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/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 };