From e4cffc728257c286ade21a602bb64fa913afe3b9 Mon Sep 17 00:00:00 2001 From: Preeti Rawat Date: Wed, 29 Jul 2020 22:29:04 +0400 Subject: [PATCH] website(II) website (II) with documentation --- whatsapp-web.js/src/businessLogic/logic.js | 172 ++++++++++++++++-- .../src/userInteraction/messages.js | 122 +++++++------ 2 files changed, 228 insertions(+), 66 deletions(-) diff --git a/whatsapp-web.js/src/businessLogic/logic.js b/whatsapp-web.js/src/businessLogic/logic.js index 5e665e5..4259ab9 100644 --- a/whatsapp-web.js/src/businessLogic/logic.js +++ b/whatsapp-web.js/src/businessLogic/logic.js @@ -21,6 +21,12 @@ module.exports.onCreate = (id, companyName) => { +/** + * A help function + * @param {void} nothing + * @return {help_signal} details on how to use the website + */ + module.exports.help = () => { let help_signal = [ @@ -45,7 +51,11 @@ module.exports.help = () => return help_signal; } - +/** + * wg create + * @param {string} input of the company name + * @return {void} gives information on how to add details to website + */ module.exports.comp = (input) => { let create_company = [ @@ -70,13 +80,17 @@ module.exports.comp = (input) => } - -module.exports.fn = (fdata) => +/** + * wg website firstname + * @param {string} input of the firstname for website + * @return {void} informs you that first name has been added + */ +module.exports.firstName = (fdata) => { - let info = [`your first name is:` + fdata + let info = [`your first name is:` + fdata ]; @@ -95,13 +109,17 @@ module.exports.fn = (fdata) => return info; } - -module.exports.ln = (ldata) => +/** + * wg website lastname + * @param {string} input of the last name for website + * @return {void} informs you that last name has been added + */ +module.exports.lastName = (ldata) => { let info = - [`your last name is: ` + ldata + [`your last name is: ` + ldata ]; if(Website.companyName == null) @@ -121,11 +139,16 @@ module.exports.ln = (ldata) => return info; } -module.exports.cn = (cdata) => +/** + * wg website companyname + * @param {string} input of the companyname for website. In case you want to change the company name, you can do so here. + * @return {void} informs you that company name has been updated + */ +module.exports.CompanyName_website = (cdata) => { - let info = [`your company name is: ` + cdata + let info = [`your company name is: ` + cdata ]; if(Website.firstname == null) @@ -139,18 +162,23 @@ module.exports.cn = (cdata) => else(Website.companyName != cdata) { Website.companyName = cdata; - info = [`your company name has been changed to` +cdata]; + info = [`your company name has been changed to ` +cdata]; console.log('this is data ' +Website.companyName); } return info; } +/** + * wg website logo + * @param {string} input of the logo URL for website + * @return {void} informs you that logo URL has been added + */ + module.exports.logourl = (ldata) => { - let info = [`the data that you added are as follow:`, - `company Name: ` + ldata + let info = [`your logo is: ` + ldata ]; if(Website.companyName == null) { @@ -169,4 +197,124 @@ module.exports.logourl = (ldata) => Website.logoUrl = ldata } return info; +} + + +/** + * wg website banner + * @param {string} input of the banner URL for website + * @return {void} informs you that banner URL has been added + */ +module.exports.bannerurl = (bannerdata) => +{ + + let info = [`your banner is: ` + bannerdata + ]; + if(Website.companyName == null) + { + info = [`you have not input your company name. Please try again.`] + } + else if(Website.firstname == null) + { + info = [`you have not insert first name.`]; + } + else if(Website.lastname == null) + { + info = [`you have not insert last name.`]; + } + else if(Website.logoUrl == null) + { + info = [`you have not insert logo url`]; + } + else + { + Website.bannerUrl = bannerdata + } + return info; +} + + +/** + * wg website description + * @param {string} input of the company description for website + * @return {void} informs you that description has been added + */ +module.exports.company_description = (descriptiondata) => +{ + + let info = [`your company description is: ` + descriptiondata + ]; + if(Website.companyName == null) + { + info = [`you have not input your company name. Please try again.`] + } + else if(Website.firstname == null) + { + info = [`you have not insert first name.`]; + } + else if(Website.lastname == null) + { + info = [`you have not insert last name.`]; + } + else if(Website.logoUrl == null) + { + info = [`you have not insert logo url`]; + } + else if(Website.bannerUrl == null) + { + info = [`you have not insert banner url`]; + } + else + { + Website.desc = descriptiondata + } + return info; +} + + + + + +/** + * wg website email + * @param {string} input of the email for website + * @return {void} informs you that email has been added + * + */ + + +module.exports.email = (email_data) => +{ + + let info = [`your email is: `+ email_data + ]; + if(Website.companyName == null) + { + info = [`you have not input your company name. Please try again.`] + } + else if(Website.firstname == null) + { + info = [`you have not insert first name.`]; + } + else if(Website.lastname == null) + { + info = [`you have not insert last name.`]; + } + else if(Website.logoUrl == null) + { + info = [`you have not insert logo url`]; + } + else if(Website.bannerUrl == null) + { + info = [`you have not insert banner url`]; + } + else if(Website.desc == null) + { + info = [`you have not insert the description`]; + } + else + { + Website.email = email_data + } + return info; } \ No newline at end of file diff --git a/whatsapp-web.js/src/userInteraction/messages.js b/whatsapp-web.js/src/userInteraction/messages.js index abd9914..a6cfb5b 100644 --- a/whatsapp-web.js/src/userInteraction/messages.js +++ b/whatsapp-web.js/src/userInteraction/messages.js @@ -5,6 +5,8 @@ const logic = require("../businessLogic/logic"); /////////// //add the commands here /////////// + + const commands = [ new Command({ //User command @@ -25,8 +27,10 @@ const commands = [ }), + //gives user information on how to create website new Command({ //User command + command: 'wg help', //function to be executed @@ -41,6 +45,7 @@ const commands = [ } }), + //helps user to create a website. The first step. new Command({ //User command @@ -60,6 +65,7 @@ const commands = [ } }), + //Inputs user's first name for website new Command({ //User command @@ -75,28 +81,14 @@ const commands = [ fdata = input['firstName']; - info = logic.fn(fdata); + info = logic.firstName(fdata); return info; } }), - // new Command({ - // //User command - // command: 'wg website firstname ', - // //function to be executed - // callback : (input) => - // { - - // logic.onWG(); - - // inputting = input['f_name']; - // fname = logic.fn(input); - // return fname; - - // } - // }), + //inputs user last name in website new Command({ //User command @@ -112,12 +104,14 @@ const commands = [ ldata = input['lastname']; - info = logic.ln(ldata); + info = logic.lastName(ldata); return info; } }), + + //inputs user companyname;in case they want to update the name new Command({ //User command @@ -133,12 +127,13 @@ const commands = [ cdata = input['cname']; - info = logic.cn(cdata); + info = logic.CompanyName_website(cdata); return info; } }), + //inputs the logo of the company to website using url of logo new Command({ //User command @@ -160,50 +155,69 @@ const commands = [ } }), - // new Command({ - // //User command - // command: 'wg website logo ', + //inputs the banner for the company to website using url of banner + new Command({ + //User command - // //function to be executed - // callback : (input) => - // { - - // logic.onWG(); - - - - // inputting = input['logo_name']; - - // logoURL = logic.logo(input); - // return logoURL; - - - // } - // }), + command: 'wg website banner ', - // new Command({ - // //User command - - // command: 'wg website ', - - // //function to be executed - // callback : (input) => - // { + //function to be executed + callback : (input) => + { - // logic.onWG(); + logic.onWG(); - // //cdata = input['company']; - // fdata = input['firstName']; - // ldata = input['lastname']; - // cdata = input['Cname']; + bannerU = input['bannerURL']; - // info = logic.comdetails(fdata, ldata, cdata); - // return info; + info = logic.bannerurl(bannerU); + return info; - // } - // }), + } + }), + + //inputs the description of the company to be seen in the website + new Command({ + //User command + + command: 'wg website description ', + + //function to be executed + callback : (input) => + { + + logic.onWG(); + + websiteDescription = input['descript']; + + + info = logic.company_description(websiteDescription); + return info; + + } + }), + + //inputs the email of the company for contacting. + new Command({ + //User command + + command: 'wg website email ', + + //function to be executed + callback : (input) => + { + + logic.onWG(); + + mail = input['Email']; + + + info = logic.email(mail); + return info; + + } + }), ];