Best JavaScript code snippet using appium-base-driver
BagController.js
Source:BagController.js
1"use strict";2/**3 * Created by thinkpad on 2015/7/23.4 */5var async = require('async');6var moment = require('moment');7var commonUtils = require('../../utils/commonUtil');8var responseObj = require('../../models/ResponseObj.js');9var bagService = require('../../services/BagService');10var userService = require('../../services/UserService');11var giftService = require('../../services/giftService');12var dateUtils = require('../../utils/dateUtils');13var bag = require('../../models/sqlFile/Bag');14var config = require('../../config/config');15var BagController = function () {};16/**17 * è·å¾èå
ä¸çå
æ¢å¸ä¿¡æ¯18 * @param req19 * @param res20 */21BagController.getTicketsInBag = function (req, res) {22 //æ£æµè¯·æ±åæ°æ¯å¦åå¨23 var checkParams = [];24 checkParams.push("userId");25 var result = commonUtils.paramsIsNull(req, res, checkParams);26 if(result) return;27 var command = req.body.command;28 var object = req.body.object;29 var params = {30 userId: object.userId31 };32 var resObj = responseObj();33 resObj.command = command;34 bagService.getTicketsInBag(params, function (err, tickets) {35 if (null == err) {36 if (null == tickets) {37 resObj.object.msg = "没æå
æ¢å¸";38 res.send(resObj);39 } else {40 var ticketArray = [];41 tickets.forEach(function (ticket) {42 var obj = {43 bagId: ticket.bag_id,44 ticketType: ticket.ticket_type,45 ticketName: ticket.ticket_name,46 ticketAmount: ticket.ticket_amount,47 ticketId: ticket.ticket_id,48 ticketPictureUrl: config.qiniu.kp_site + ticket.ticket_picture_url,49 usage: ticket.ticket_usage,50 produceDate: dateUtils.formatDate(ticket.produceDate),51 expireDate: dateUtils.formatDate(ticket.expireDate)52 };53 ticketArray.push(obj);54 });55 resObj.object = ticketArray;56 res.send(resObj);57 }58 } else {59 resObj.object.msg = "èå
æ¥è¯¢å¤±è´¥";60 resObj.status = false;61 resObj.code = '4001';62 res.send(resObj);63 }64 });65};66/**67 * 使ç¨è±å¸å¸68 * @param req69 * @param res70 */71BagController.useDouBiExchange = function (req, res) {72 var command = req.body.command;73 var object = req.body.object;74 var resObj = responseObj();75 resObj.command = command;76 checkValid(req, res, function (ret) {77 var ticketParam = {78 ticketId: object.ticketId79 };80 bagService.getTicketParValue(ticketParam, function (err, ret) {81 var integralParams = {82 userId: object.userId,83 beanValue: object.ticketAmount*ret[0].par_value,84 attributes: ['userId', 'bean']85 };86 userService.updateUserBean(integralParams, function (err,obj) {87 });88 var comsumeParams = {89 userId: object.userId,90 ticketId: object.ticketId,91 ticketAmount: object.ticketAmount92 };93 comsumeTicketInBag(comsumeParams, function (ret) {94 if (ret.exchangeStatus == "success") {95 resObj.object = {exchangeStatus: "success"};96 res.send(resObj);97 }98 });99 });100 });101};102/**103 * 使ç¨æå¡å¸104 * @param req105 * @param res106 */107BagController.useDakaExchange = function (req, res) {108 var command = req.body.command;109 var object = req.body.object;110 var resObj = responseObj();111 resObj.command = command;112 var result = checkDakaParams(req,res);113 if(result) return;114 var params = {115 userId: object.userId,116 ticketId: object.ticketId,117 ticketAmount: object.ticketAmount118 };119 bagService.freshDailyTicketofDaka(params, function () {120 bagService.getTotalTicketsofDaka(params,function(err,records){121 if(records[0].total_amount > 0){122 bagService.hasEnoughTicketofDailyDaka(params,function(err,records){123 var exchangeParams = {124 userId:params.userId,125 ticketId:params.ticketId,126 ticketAmount:params.ticketAmount127 };128 if(records.length > 0){129 exchangeParams.ticketId = bag.DAKATicketID.DailyDaka;130 }else{131 exchangeParams.ticketId = bag.DAKATicketID.Daka;132 }133 comsumeTicketInBag(exchangeParams, function (ret) {134 if (ret.exchangeStatus == "success") {135 resObj.object = {exchangeStatus: "success"};136 res.send(resObj);137 }138 });139 });140 }else{141 resObj.errMsg("4017", "å
æ¢å¸æ æ");142 resObj.status = false;143 res.send(resObj);144 }145 });146 });147};148/**149 * 使ç¨ä¸è¾å¸150 * @param req151 * @param res152 */153BagController.useZhuanjiExchange = function (req, res) {154 var command = req.body.command;155 var object = req.body.object;156 var resObj = responseObj();157 resObj.command = command;158 var result = checkZhuanjiParams(req,res);159 if(result) return;160 checkExchangeValidation(req,res,function(ret){161 var params = {162 userId: object.userId,163 ticketId: object.ticketId,164 ticketAmount: object.ticketAmount,165 exchangeType:bag.EXCHANGE_TYPE.ALBUM,166 starName:object.starName,167 albumName:object.albumName168 };169 bagService.insertExchangeInfo(params,function(records){170 comsumeTicketInBag(params, function (ret) {171 if (ret.exchangeStatus == "success") {172 resObj.object = {exchangeStatus: "success"};173 res.send(resObj);174 }175 });176 });177 });178};179/**180 * 使ç¨é²è±å¸181 * @param req182 * @param res183 */184BagController.useFlowerExchange = function (req, res) {185 var command = req.body.command;186 var object = req.body.object;187 var resObj = responseObj();188 resObj.command = command;189 checkValid(req, res, function (ret) {190 var params = {191 userId: object.userId,192 ticketId: object.ticketId,193 ticketAmount: object.ticketAmount194 };195 comsumeTicketInBag(params, function (ret) {196 if (ret.exchangeStatus == "success") {197 resObj.object = {exchangeStatus: "success"};198 res.send(resObj);199 }200 });201 });202};203var checkValid = function (req, res, callback) {204 //æ£æµè¯·æ±åæ°æ¯å¦åå¨205 var checkParams = [];206 checkParams.push("userId");207 checkParams.push("ticketId");208 checkParams.push("ticketAmount");209 var result = checkParameters(req,res,checkParams);210 if(result) return;211 var command = req.body.command;212 var object = req.body.object;213 var resObj = responseObj();214 resObj.command = command;215 var params = {216 userId: object.userId,217 ticketId: object.ticketId,218 ticketAmount: object.ticketAmount219 };220 bagService.isValidExchange(params, function (err, ret) {221 if (ret.isValid) {222 callback(ret);223 } else {224 resObj.errMsg("4017", "å
æ¢å¸æ æ");225 resObj.status = false;226 res.send(resObj);227 }228 });229};230var checkExchangeValidation = function (req, res, callback) {231 var command = req.body.command;232 var object = req.body.object;233 var resObj = responseObj();234 resObj.command = command;235 var params = {236 userId: object.userId,237 ticketId: object.ticketId,238 ticketAmount: object.ticketAmount239 };240 bagService.isValidExchange(params, function (err, ret) {241 if (ret.isValid) {242 callback(ret);243 } else {244 resObj.errMsg("4017", "å
æ¢å¸æ æ");245 resObj.status = false;246 res.send(resObj);247 }248 });249};250/**251 * æ£æ¥åæ°æå¡å¸æ¯å¦ææ252 * @param req253 * @param res254 */255var checkDakaParams = function (req, res) {256 //æ£æµè¯·æ±åæ°æ¯å¦åå¨257 var checkParams = [];258 checkParams.push("userId");259 checkParams.push("ticketId");260 checkParams.push("ticketAmount");261 return checkParameters(req,res,checkParams);262};263/**264 * æ£æ¥åæ°ä¸è¾å¸æ¯å¦ææ265 * @param req266 * @param res267 */268var checkZhuanjiParams = function (req, res) {269 //æ£æµè¯·æ±åæ°æ¯å¦åå¨270 var checkParams = [];271 checkParams.push("userId");272 checkParams.push("ticketId");273 checkParams.push("ticketAmount");274 checkParams.push("starName");275 checkParams.push("albumName");276 return checkParameters(req,res,checkParams);277};278/**279 * æ£æ¥åæ°æ¯å¦ææ280 * @param req281 * @param res282 * @param checkParams283 */284var checkParameters = function(req,res,checkParams){285 return commonUtils.paramsIsNull(req, res, checkParams);286};287/**288 * æ£é¤å
æ¢å¸289 * @param params290 * @param callback291 */292var comsumeTicketInBag = function (params, callback) {293 bagService.useTicketInBag(params, function (err, ret) {294 bagService.clearTicketInBag(params, function (err, ret) {295 });296 var ret = {exchangeStatus: "success"};297 callback(ret);298 });299};300/**301 * åç¨æ·èå
ä¸æ·»å å
æ¢å¸302 * @param req303 * @param res304 */305BagController.addTicket = function(req,res){306 //æ£æµè¯·æ±åæ°æ¯å¦åå¨307 var checkParams = [];308 checkParams.push("userId");309 checkParams.push("ticketId");310 checkParams.push("ticketAmount");311 var result = checkParameters(req,res,checkParams);312 if(result) return;313 var command = req.body.command;314 var object = req.body.object;315 var resObj = responseObj();316 resObj.command = command;317 var currentTime = new Date();318 var ticketparams = {319 userId: object.userId,320 ticketId: object.ticketId,321 ticketAmount: object.ticketAmount,322 createDate:currentTime323 };324 var params2 = {325 ticketId:object.ticketId326 };327 // æ£æµæ¯å¦æ½å°å®ç©å¥328 giftService.findOneTicketSet(params2, function(err, ticketSet){329 // æ½å°å®ç©å¥æ¶330 if(ticketSet){331 // æ½å°å¹¶ä¸å®ç©å¥æ²¡æçæ¶å332 if(ticketSet.ticketCount <= 0){333 resObj.errMsg(5007,"å½åçæ¬è¿æ§ï¼å½åæ½å¥æ æ");334 res.send(resObj);335 } else {336 bagService.addTicket(ticketparams,function(){337 resObj.object = {OperateStatus: "success"};338 res.send(resObj);339 });340 }341 } else {342 // ä¸åå¨åææ£å¸¸æµç¨èµ°343 bagService.addTicket(ticketparams,function(){344 resObj.object = {OperateStatus: "success"};345 res.send(resObj);346 });347 }348 });349};350/**351 * è·å¾å¯æ½åçå¥å¸å表352 * @param req353 * @param res354 */355BagController.getGiftTicketList = function(req,res){356 var command = req.body.command;357 var object = req.body.object;358 var resObj = responseObj();359 resObj.command = command;360 bagService.getTicketListWithoutDailyDaka(function(err,tickets){361 if (null == tickets) {362 resObj.object.msg = "没æå¥å¸";363 resObj.code = "5010";364 res.send(resObj);365 } else {366 var ticketArray = [];367 tickets.forEach(function (ticket) {368 var obj = {369 ticketId: ticket.ticket_id,370 ticketType: ticket.ticket_type,371 ticketName: ticket.ticket_name,372 parValue: ticket.par_value,373 ticketPictureUrl: ticket.ticket_picture_url,374 usage: ticket.ticket_usage,375 produceDate: dateUtils.formatDate(ticket.produceDate),376 expireDate: dateUtils.formatDate(ticket.expireDate)377 };378 ticketArray.push(obj);379 });380 resObj.object = ticketArray;381 res.send(resObj);382 }383 });384};385/**386 * è·åå¥å设置å表387 * @param {Object} req388 * @param {Object} res389 */390BagController.getTicketSet = function(req, res){391 var command = req.body.command;392 var object = req.body.object;393 var resObj = responseObj();394 resObj.command = command;395 var params = {396 userId:object.userId397 }398 giftService.getTicketSet(params, function(err, tickesetlist){399 resObj.object = tickesetlist;400 res.send(resObj);401 });402};...
WppConnect.js
Source:WppConnect.js
1/*2 * @Author: Eduardo Policarpo3 * @contact: +55 439966114374 * @Date: 2021-05-10 18:09:495 * @LastEditTime: 2021-06-07 03:18:016 */7const express = require('express');8const Router = express.Router();9const engine = require('../engines/WppConnect');10const Sessions = require('../controllers/sessions');11const Status = require('../functions/WPPConnect/status');12const Commands = require('../functions/WPPConnect/commands');13const Groups = require('../functions/WPPConnect/groups');14const Mensagens = require('../functions/WPPConnect/mensagens');15const Auth = require('../functions/WPPConnect/auth');16const config = require('../config');17const { checkParams } = require('../middlewares/validations');18const { checkNumber } = require('../middlewares/checkNumber');19const database = require('../firebase/functions');20const firebase = require('../firebase/db');21const firestore = firebase.firestore();22Router.post('/start', async (req, res) => {23 try {24 if (config.firebaseConfig.apiKey == '' &&25 config.firebaseConfig.authDomain == '' &&26 config.firebaseConfig.projectId == '' &&27 config.firebaseConfig.storageBucket == '' &&28 config.firebaseConfig.messagingSenderId == '' &&29 config.firebaseConfig.appId == '') {30 res.status(401).json({31 result: 401,32 "status": "FAIL",33 "reason": "favor preencher as credencias de acesso ao Firebase"34 })35 } else {36 if (req.headers['apitoken'] === config.token) {37 let session = req.body.session38 let existSession = Sessions.checkSession(session)39 if (!existSession) {40 init(session)41 }42 if (existSession) {43 let data = Sessions.getSession(session)44 if (data.status !== 'inChat' && data.status !== 'isLogged') {45 init(session)46 }47 else {48 res.status(400).json({49 result: 400,50 "status": "FAIL",51 "reason": "there is already a session with that name",52 "status": data.status53 })54 }55 }56 async function init(session) {57 Sessions.checkAddUser(session)58 Sessions.addInfoSession(session, {59 apitoken: req.headers['apitoken'],60 sessionkey: req.headers['sessionkey'],61 wh_status: req.body.wh_status,62 wh_message: req.body.wh_message,63 wh_qrcode: req.body.wh_qrcode,64 wh_connect: req.body.wh_connect,65 wa_browser_id: req.headers['wa_browser_id'] ? req.headers['wa_browser_id'] : '',66 wa_secret_bundle: req.headers['wa_secret_bundle'] ? req.headers['wa_secret_bundle'] : '',67 wa_token_1: req.headers['wa_token_1'] ? req.headers['wa_token_1'] : '',68 wa_token_2: req.headers['wa_token_2'] ? req.headers['wa_token_2'] : '',69 })70 let response = await engine.start(req, res, session)71 if (response != undefined) {72 let data = {73 'session': session,74 'apitoken': req.headers['apitoken'],75 'sessionkey': req.headers['sessionkey'],76 'wh_status': req.body.wh_status,77 'wh_message': req.body.wh_message,78 'wh_qrcode': req.body.wh_qrcode,79 'wh_connect': req.body.wh_connect,80 'WABrowserId': response.WABrowserId,81 'WASecretBundle': response.WASecretBundle,82 'WAToken1': response.WAToken1,83 'WAToken2': response.WAToken284 }85 await firestore.collection('Sessions').doc(session).set(data);86 res.status(200).json({87 "result": 200,88 "status": "CONNECTED",89 "response": `Sessão ${session} gravada com sucesso no Firebase`90 })91 }92 }93 }94 else {95 req.io.emit('msg', {96 result: 400,97 "status": "FAIL",98 "reason": "Unauthorized, please check the API TOKEN"99 })100 res.status(401).json({101 result: 401,102 "status": "FAIL",103 "reason": "Unauthorized, please check the API TOKEN"104 })105 }106 }107 } catch (error) {108 res.status(500).json({109 result: 500,110 "status": "FAIL",111 "reason": error.message112 })113 }114})115// Sessões 116Router.post('/logout', checkParams, Auth.logoutSession);117Router.post('/close', checkParams, Auth.closeSession);118Router.post('/SessionState', checkParams, Auth.getSessionState);119Router.post('/SessionConnect', checkParams, Auth.checkConnectionSession);120Router.post('/deleteSession', database.deleteSession);121Router.post('/getAllSessions', database.getAllSessions);122Router.get('/getQrCode', Auth.getQrCode);123// Mensagens124Router.post('/sendText', checkParams, checkNumber, Mensagens.sendText);125Router.post('/sendImage', checkParams, checkNumber, Mensagens.sendImage);126Router.post('/sendVideo', checkParams, checkNumber, Mensagens.sendVideo);127Router.post('/sendSticker', checkParams, checkNumber, Mensagens.sendSticker);128Router.post('/sendFile', checkParams, checkNumber, Mensagens.sendFile);129Router.post('/sendFile64', checkParams, checkNumber, Mensagens.sendFile64);130Router.post('/sendAudio', checkParams, checkNumber, Mensagens.sendAudio);131Router.post('/sendAudio64', checkParams, checkNumber, Mensagens.sendVoiceBase64);132Router.post('/sendLink', checkParams, checkNumber, Mensagens.sendLink);133Router.post('/sendContact', checkParams, checkNumber, Mensagens.sendContact);134Router.post('/sendLocation', checkParams, checkNumber, Mensagens.sendLocation);135Router.post('/reply', checkParams, Mensagens.reply);136Router.post('/forwardMessages', checkParams, Mensagens.forwardMessages);137Router.post('/getMessagesChat', checkParams, checkNumber, Commands.getMessagesChat);138Router.post('/getAllChats', checkParams, Commands.getAllChats);139Router.post('/getAllChatsWithMessages', checkParams, Commands.getAllChatsWithMessages);140Router.post('/getAllNewMessages', checkParams, Commands.getAllNewMessages);141Router.post('/getAllUnreadMessages', checkParams, Commands.getAllUnreadMessages);142Router.post('/getOrderbyMsg', checkParams, Mensagens.getOrderbyMsg);143// // Grupos144Router.post('/getAllGroups', checkParams, Groups.getAllGroups);145Router.post('/joinGroup', checkParams, Groups.joinGroup);146Router.post('/createGroup', checkParams, Groups.createGroup);147Router.post('/leaveGroup', checkParams, Groups.leaveGroup);148Router.post('/getGroupMembers', checkParams, checkNumber, Groups.getGroupMembers);149Router.post('/addParticipant', checkParams, checkNumber, Groups.addParticipant);150Router.post('/removeParticipant', checkParams, checkNumber, Groups.removeParticipant);151Router.post('/promoteParticipant', checkParams, checkNumber, Groups.promoteParticipant);152Router.post('/demoteParticipant', checkParams, checkNumber, Groups.demoteParticipant);153Router.post('/getGroupAdmins', checkParams, Groups.getGroupAdmins);154Router.post('/changePrivacyGroup', checkParams, Groups.changePrivacyGroup); //nova155Router.post('/getGroupInviteLink', checkParams, Groups.getGroupInviteLink);156Router.post('/setGroupPic', checkParams, Groups.setGroupPic); // ver funcao nao exite157// // Status158Router.post('/sendTextToStorie', checkParams, Status.sendTextToStorie);159Router.post('/sendImageToStorie', checkParams, Status.sendImageToStorie);160Router.post('/sendVideoToStorie', checkParams, Status.sendVideoToStorie);161// // Dispositivo, chats entre outras162Router.post('/getBatteryLevel', checkParams, Commands.getBatteryLevel);163Router.post('/getConnectionState', checkParams, Commands.getConnectionState);164Router.post('/getHostDevice', checkParams, Commands.getHostDevice);165Router.post('/getAllContacts', checkParams, Commands.getAllContacts);166Router.post('/getBlockList', checkParams, Commands.getBlockList);167Router.post('/getProfilePic', checkParams, checkNumber, Commands.getProfilePic);168Router.post('/verifyNumber', checkParams, checkNumber, Commands.verifyNumber);169Router.post('/deleteChat', checkParams, checkNumber, Commands.deleteChat);170Router.post('/clearChat', checkParams, checkNumber, Commands.clearChat);171Router.post('/archiveChat', checkParams, checkNumber, Commands.archiveChat);172Router.post('/deleteMessage', checkParams, checkNumber, Commands.deleteMessage);173Router.post('/markUnseenMessage', checkParams, checkNumber, Commands.markUnseenMessage);174Router.post('/blockContact', checkParams, checkNumber, Commands.blockContact);175Router.post('/unblockContact', checkParams, checkNumber, Commands.unblockContact);176Router.post('/getNumberProfile', checkParams, checkNumber, Commands.getNumberProfile);...
Venom.js
Source:Venom.js
1/*2 * @Author: Eduardo Policarpo3 * @contact: +55 439966114374 * @Date: 2021-06-07 03:19:365 * @LastEditTime: 2021-06-07 03:19:366 */7const express = require('express');8const Router = express.Router();9const engine = require('../engines/Venom');10const Sessions = require('../controllers/sessions');11const Status = require('../functions/Venom/status');12const Commands = require('../functions/Venom/commands');13const Groups = require('../functions/Venom/groups');14const Mensagens = require('../functions/Venom/mensagens');15const Auth = require('../functions/WPPConnect/auth');16const config = require('../config');17const { checkParams } = require('../middlewares/validations');18const { checkNumber } = require('../middlewares/checkNumber');19const database = require('../firebase/functions');20const firebase = require('../firebase/db');21const firestore = firebase.firestore();22Router.post('/start', async (req, res) => {23 try {24 if (config.firebaseConfig.apiKey == '' &&25 config.firebaseConfig.authDomain == '' &&26 config.firebaseConfig.projectId == '' &&27 config.firebaseConfig.storageBucket == '' &&28 config.firebaseConfig.messagingSenderId == '' &&29 config.firebaseConfig.appId == '') {30 res.status(401).json({31 result: 401,32 "status": "FAIL",33 "reason": "favor preencher as credencias de acesso ao Firebase"34 })35 } else {36 if (req.headers['apitoken'] === config.token) {37 let session = req.body.session38 let existSession = Sessions.checkSession(session)39 if (!existSession) {40 init(session)41 }42 if (existSession) {43 let data = Sessions.getSession(session)44 if (data.status !== 'inChat' && data.status !== 'isLogged') {45 init(session)46 }47 else {48 res.status(400).json({49 result: 400,50 "status": "FAIL",51 "reason": "there is already a session with that name",52 "status": data.status53 })54 }55 }56 async function init(session) {57 Sessions.checkAddUser(session)58 Sessions.addInfoSession(session, {59 apitoken: req.headers['apitoken'],60 sessionkey: req.headers['sessionkey'],61 wh_status: req.body.wh_status,62 wh_message: req.body.wh_message,63 wh_qrcode: req.body.wh_qrcode,64 wh_connect: req.body.wh_connect,65 wa_browser_id: req.headers['wa_browser_id'] ? req.headers['wa_browser_id'] : '',66 wa_secret_bundle: req.headers['wa_secret_bundle'] ? req.headers['wa_secret_bundle'] : '',67 wa_token_1: req.headers['wa_token_1'] ? req.headers['wa_token_1'] : '',68 wa_token_2: req.headers['wa_token_2'] ? req.headers['wa_token_2'] : '',69 })70 let response = await engine.start(req, res, session)71 if (response != undefined) {72 let data = {73 'session': session,74 'apitoken': req.headers['apitoken'],75 'sessionkey': req.headers['sessionkey'],76 'wh_status': req.body.wh_status,77 'wh_message': req.body.wh_message,78 'wh_qrcode': req.body.wh_qrcode,79 'wh_connect': req.body.wh_connect,80 'WABrowserId': response.WABrowserId,81 'WASecretBundle': response.WASecretBundle,82 'WAToken1': response.WAToken1,83 'WAToken2': response.WAToken284 }85 await firestore.collection('Sessions').doc(session).set(data);86 res.status(200).json({87 "result": 200,88 "status": "CONNECTED",89 "response": `Sessão ${session} gravada com sucesso no Firebase`90 })91 }92 }93 }94 else {95 req.io.emit('msg', {96 result: 400,97 "status": "FAIL",98 "reason": "Unauthorized, please check the API TOKEN"99 })100 res.status(401).json({101 result: 401,102 "status": "FAIL",103 "reason": "Unauthorized, please check the API TOKEN"104 })105 }106 }107 } catch (error) {108 res.status(500).json({109 result: 500,110 "status": "FAIL",111 "reason": error.message112 })113 }114})115//Sessões116Router.post('/logout', checkParams, Auth.logoutSession);117Router.post('/close', checkParams, Auth.closeSession);118Router.post('/SessionState', checkParams, Auth.getSessionState);119Router.post('/SessionConnect', checkParams, Auth.checkConnectionSession);120Router.post('/deleteSession', database.deleteSession);121Router.post('/getAllSessions', database.getAllSessions);122Router.get('/getQrCode', Auth.getQrCode);123//Mensagens124Router.post('/sendText', checkParams, checkNumber, Mensagens.sendText);125Router.post('/sendImage', checkParams, checkNumber, Mensagens.sendImage);126Router.post('/sendVideo', checkParams, checkNumber, Mensagens.sendVideo);127Router.post('/sendSticker', checkParams, checkNumber, Mensagens.sendSticker);128Router.post('/sendFile', checkParams, checkNumber, Mensagens.sendFile);129Router.post('/sendFile64', checkParams, checkNumber, Mensagens.sendFile64);130Router.post('/sendAudio', checkParams, checkNumber, Mensagens.sendAudio);131Router.post('/sendAudio64', checkParams, checkNumber, Mensagens.sendVoiceBase64);132Router.post('/sendLink', checkParams, checkNumber, Mensagens.sendLink);133Router.post('/sendContact', checkParams, checkNumber, Mensagens.sendContact);134Router.post('/sendLocation', checkParams, checkNumber, Mensagens.sendLocation);135Router.post('/reply', checkParams, Mensagens.reply);136Router.post('/forwardMessages', checkParams, Mensagens.forwardMessages);137Router.post('/getMessagesChat', checkParams, checkNumber, Commands.getMessagesChat);138Router.post('/getAllChats', checkParams, Commands.getAllChats);139Router.post('/getAllChatsWithMessages', checkParams, Commands.getAllChatsWithMessages);140Router.post('/getAllNewMessages', checkParams, Commands.getAllNewMessages);141Router.post('/getAllUnreadMessages', checkParams, Commands.getAllUnreadMessages);142//Router.post('/getOrderbyMsg', checkParams, Mensagens.getOrderbyMsg);143// Grupos144Router.post('/getAllGroups', checkParams, Groups.getAllGroups);145Router.post('/joinGroup', checkParams, Groups.joinGroup);146Router.post('/createGroup', checkParams, Groups.createGroup);147Router.post('/leaveGroup', checkParams, Groups.leaveGroup);148Router.post('/getGroupMembers', checkParams, checkNumber, Groups.getGroupMembers);149Router.post('/addParticipant', checkParams, checkNumber, Groups.addParticipant);150Router.post('/removeParticipant', checkParams, checkNumber, Groups.removeParticipant);151Router.post('/promoteParticipant', checkParams, checkNumber, Groups.promoteParticipant);152Router.post('/demoteParticipant', checkParams, checkNumber, Groups.demoteParticipant);153Router.post('/getGroupAdmins', checkParams, Groups.getGroupAdmins);154Router.post('/changePrivacyGroup', checkParams, Groups.changePrivacyGroup); //nova155Router.post('/getGroupInviteLink', checkParams, Groups.getGroupInviteLink);156Router.post('/setGroupPic', checkParams, Groups.setGroupPic); // ver funcao nao exite157// // Status158Router.post('/sendTextToStorie', checkParams, Status.sendTextToStorie);159Router.post('/sendImageToStorie', checkParams, Status.sendImageToStorie);160Router.post('/sendVideoToStorie', checkParams, Status.sendVideoToStorie);161// // Dispositivo, chats entre outras162Router.post('/getBatteryLevel', checkParams, Commands.getBatteryLevel);163Router.post('/getConnectionState', checkParams, Commands.getConnectionState);164Router.post('/getHostDevice', checkParams, Commands.getHostDevice);165Router.post('/getAllContacts', checkParams, Commands.getAllContacts);166Router.post('/getBlockList', checkParams, Commands.getBlockList);167Router.post('/getProfilePic', checkParams, checkNumber, Commands.getProfilePic);168Router.post('/verifyNumber', checkParams, checkNumber, Commands.verifyNumber);169Router.post('/deleteChat', checkParams, checkNumber, Commands.deleteChat);170Router.post('/clearChat', checkParams, checkNumber, Commands.clearChat);171Router.post('/archiveChat', checkParams, checkNumber, Commands.archiveChat);172Router.post('/deleteMessage', checkParams, checkNumber, Commands.deleteMessage);173Router.post('/markUnseenMessage', checkParams, checkNumber, Commands.markUnseenMessage);174Router.post('/blockContact', checkParams, checkNumber, Commands.blockContact);175Router.post('/unblockContact', checkParams, checkNumber, Commands.unblockContact);176Router.post('/getNumberProfile', checkParams, checkNumber, Commands.getNumberProfile);...
router.js
Source:router.js
...20 router.get('/', userRequired, 'home.index');21 // user22 router.get('/xapi/user', userRequired, 'user.index');23 // app24 router.get('/xapi/apps', userRequired, checkParams(['type']), 'app.getApps');25 router.get('/xapi/app', userRequired, appMemberRequired, 'app.getAppInfo');26 router.post('/xapi/app', userRequired, checkParams(['newAppName']), 'app.saveApp');27 // overview28 router.get('/xapi/overview_metrics', userRequired, appMemberRequired, 'overview.getOverviewMetrics');29 router.get('/xapi/main_metrics', userRequired, appMemberRequired, 'overview.getMainMetrics');30 // instance31 router.get('/xapi/agents', userRequired, appMemberRequired, 'instance.getAgents');32 router.get('/xapi/agent', userRequired, agentAccessibleRequired, checkParams(['agentId']), 'instance.checkAgent');33 // instance/process34 router.get('/xapi/node_processes', userRequired, agentAccessibleRequired, checkParams(['agentId']), 'process.getNodeProcesses');35 router.get('/xapi/xprofiler_processes', userRequired, agentAccessibleRequired, checkParams(['agentId']), 'process.getXprofilerProcesses');36 router.get('/xapi/xprofiler_status', userRequired, agentAccessibleRequired, checkParams(['agentId', 'pid']), 'process.checkXprofilerStatus');37 router.get('/xapi/process_trend', userRequired, agentAccessibleRequired, checkParams(['agentId', 'pid', 'trendType', 'duration']), 'process.getProcessTrend');38 router.post('/xapi/process_trend', userRequired, agentAccessibleRequired, checkParams(['agentId', 'pid']), 'process.saveProcessTrend');39 router.post('/xapi/action', userRequired, agentAccessibleRequired, checkParams(['agentId', 'pid', 'action']), 'process.takeAction');40 // instance/system41 router.get('/xapi/system_overview', userRequired, agentAccessibleRequired, checkParams(['agentId']), 'system.getOverview');42 router.get('/xapi/system_trend', userRequired, agentAccessibleRequired, checkParams(['agentId', 'trendType', 'duration']), 'system.getSystemTrend');43 // instance/error44 router.get('/xapi/error_files', userRequired, agentAccessibleRequired, checkParams(['agentId']), 'error.getFiles');45 router.get('/xapi/error_logs', userRequired, agentAccessibleRequired, checkParams(['agentId', 'errorFile', 'currentPage', 'pageSize']), 'error.getLogs');46 // instance/module47 router.get('/xapi/module_files', userRequired, agentAccessibleRequired, checkParams(['agentId']), 'module.getFiles');48 router.get('/xapi/module', userRequired, agentAccessibleRequired, checkParams(['agentId', 'moduleFile']), 'module.getModules');49 // file50 router.get('/xapi/files', userRequired, appMemberRequired, checkParams(['filterType', 'currentPage', 'pageSize']), 'file.getFiles');51 router.get('/file/download', userRequired, fileAccessibleRequired, checkParams(['fileId', 'fileType']), 'file.downloadFile');52 router.post('/xapi/file_status', userRequired, fileAccessibleRequired, checkParams(['files']), 'file.checkFileStatus');53 router.post('/xapi/file_transfer', userRequired, fileAccessibleRequired, checkParams(['fileId', 'fileType']), 'file.transferFile');54 router.post('/xapi/file_favor', userRequired, fileAccessibleRequired, checkParams(['fileId', 'fileType', 'favor']), 'file.favorFile');55 router.delete('/xapi/file_deletion', userRequired, fileAccessibleRequired, checkParams(['fileId', 'fileType']), 'file.deleteFile');56 // devtools57 router.get('/dashboard/devtools-new', userRequired, fileAccessibleRequired, checkParams(['fileId', 'fileType', 'selectedTab']), 'devtools.newDevtools');58 router.get('/dashboard/devtools-old', userRequired, fileAccessibleRequired, checkParams(['fileId', 'fileType', 'selectedTab']), 'devtools.oldDevtools');59 // upload file60 router.post('/xapi/upload_file', userRequired, appMemberRequired, checkParams(['fileType']), 'upload.fromConsole');61 router.post('/xapi/upload_from_xtransit', checkParams(['fileId', 'fileType', 'nonce', 'timestamp', 'signature']), 'upload.fromXtransit');62 // team63 router.get('/xapi/team_members', userRequired, appMemberRequired, 'team.getMembers');64 router.post('/xapi/team_member', userRequired, appMemberRequired, checkParams(['userId']), 'team.inviteMember');65 router.post('/xapi/team_ownership', userRequired, appOwnerRequired, checkParams(['userId']), 'team.transferOwnership');66 router.put('/xapi/invitation', userRequired, appInvitationRequired, checkParams(['status']), 'team.updateInvitation');67 router.delete('/xapi/leave_team', userRequired, appMemberRequired, 'team.leaveTeam');68 router.delete('/xapi/team_member', userRequired, appOwnerRequired, checkParams(['userId']), 'team.removeMember');69 // alarm70 router.get('/xapi/alarm_strategies', userRequired, appMemberRequired, 'alarm.getStrategies');71 router.post('/xapi/alarm_strategy', userRequired, appMemberRequired, 'alarm.addStrategy');72 router.put('/xapi/alarm_strategy', userRequired, strategyAccessibleRequired, 'alarm.updateStrategy');73 router.put('/xapi/alarm_strategy_status', userRequired, strategyAccessibleRequired, 'alarm.updateStrategyStatus');74 router.delete('/xapi/alarm_strategy', userRequired, strategyAccessibleRequired, 'alarm.deleteStrategy');75 // alarm/history76 router.get('/xapi/alarm_strategy_history', userRequired, strategyAccessibleRequired, 'alarm.getStrategyHistory');77 // alarm/contacts78 router.get('/xapi/alarm_strategy_contacts', userRequired, strategyAccessibleRequired, 'alarm.getStrategyContacts');79 router.post('/xapi/alarm_strategy_contact', userRequired, strategyAccessibleRequired, 'alarm.addContactToStrategy');80 router.delete('/xapi/alarm_strategy_contact', userRequired, strategyAccessibleRequired, 'alarm.deleteContactFromStrategy');81 // settings82 router.get('/xapi/settings', userRequired, appOwnerRequired, 'settings.getSettingInfo');83 router.put('/xapi/settings_app_name', userRequired, appOwnerRequired, checkParams(['newAppName']), 'settings.renameApp');84 router.delete('/xapi/settings_app', userRequired, appOwnerRequired, 'settings.deleteApp');...
validadarAPI.js
Source:validadarAPI.js
1exports.API = function(req, res) {2 var errors;3 // Validacion por servidor4 if (req.params.id_dron != undefined) {5 req.checkParams('id_dron', 'La ID dron es requerida.').notEmpty();6 req.checkParams('id_dron', 'La ID dron no es de MONGO.').isMongoId();7 req.checkParams('id_dron', 'La ID dron no cumple con la cantidad de caracteres.').len(24, 24);8 errors = req.validationErrors();9 }10 else if (req.params.id_producto != undefined) {11 req.checkParams('id_producto', 'La ID producto no es requerida.').notEmpty();12 req.checkParams('id_producto', 'La ID producto no es de MONGO.').isMongoId();13 req.checkParams('id_producto', 'La ID producto no cumple con la cantidad de caracteres.').len(24, 24);14 errors = req.validationErrors();15 }16 else {17 return false;18 }19 console.log(errors);20 if (errors) {21 return false;22 }23 else {24 return true;25 }26};27exports.APIinsertar = function(req, res) {28 var errors;29 console.log('Entro a validar');30 console.log('id_dron: ' + req.params.id_dron);31 // Validacion por servidor32 if (req.params.id_dron != undefined) {33 req.checkParams('id_dron', 'La ID dron es requerida.').notEmpty();34 req.checkParams('id_dron', 'La ID dron no es de MONGO.').isMongoId();35 req.checkParams('id_dron', 'La ID dron no cumple con la cantidad de caracteres.').len(24, 24);36 req.checkParams('temperatura', 'La temperatura no esta en decimal.').isDecimal();37 req.checkParams('temperatura', 'La temperatura no cumple con la cantidad de caracteres.').len(1, 5);38 req.checkParams('humedad', 'La humedad no esta en decimal.').isDecimal();39 req.checkParams('humedad', 'La humedad no cumple con la cantidad de caracteres.').len(1, 5);40 req.checkParams('co2', 'El co2 no esta en decimal.').isDecimal();41 req.checkParams('co2', 'El co2 no cumple con la cantidad de caracteres.').len(1, 5);42 req.checkParams('radiacion', 'La radiacion no esta en decimal.').isDecimal();43 req.checkParams('radiacion', 'La radiacion no cumple con la cantidad de caracteres.').len(1, 5);44 req.checkParams('luminosidad', 'La luminosidad no esta en decimal.').isDecimal();45 req.checkParams('luminosidad', 'La luminosidad no cumple con la cantidad de caracteres.').len(1, 5);46 req.checkParams('bateria', 'La bateria no esta en decimal.').isDecimal();47 req.checkParams('bateria', 'La bateria no cumple con la cantidad de caracteres.').len(1,5); //Hay que mirar como nos envian este dato48 49 req.checkParams('latitud', 'La latitud no cumple con la cantidad de caracteres.').len(1,30);50 51 req.checkParams('longitud', 'La latitud no cumple con la cantidad de caracteres.').len(1,30); 52 errors = req.validationErrors();53 }54 else {55 return false;56 }57 console.log(errors);58 if (errors) {59 return false;60 }61 else {62 return true;63 }64};65exports.APIDronesUsuario = function(req, res) {66 var errors;67 // Validacion por servidor68 if (req.params.id_usuario != undefined) {69 req.checkParams('id_usuario', 'La ID usuario es requerida.').notEmpty();70 req.checkParams('id_usuario', 'La ID usuario no es de MONGO.').isMongoId();71 req.checkParams('id_usuario', 'La ID usuario no cumple con la cantidad de caracteres.').len(24, 24);72 errors = req.validationErrors();73 }74 else {75 return false;76 }77 console.log(errors);78 if (errors) {79 return false;80 }81 else {82 return true;83 }84};85exports.APIconfAlertas = function(req, res) {...
check.test.js
Source:check.test.js
1/* eslint-disable jest/no-export */2import {issueCheck, decodeCheck, getGasCoinFromCheck} from '~/src';3export const VALID_CHECK = 'Mcf8973101830f423f80888ac7230489e8000080b84199953f49ef0ed10d971b8df2c018e7699cd749feca03cad9d03f32a8992d77ab6c818d770466500b41165c18a1826662fb0d45b3a9193fcacc13a4131702e017011ba069f7cfdead0ea971e9f3e7b060463e10929ccf2f4309b8145c0916f51f4c5040a025767d4ea835ee8fc2a096b8f99717ef65627cad5e99c2427e34a9928881ba34';4// gasCoin: 55export const VALID_CHECK_WITH_CUSTOM_GAS_COIN = 'Mcf8973101830f423f80888ac7230489e8000005b841b0fe6d3805fae9f38bafefb74d0f61302fb37a20f0e9337871bef91c7423277646555dcb425fbb1ec35eda8a304bda41e9242dd55cb62a48e9b14a07262bc0d3011ba0ec85458016f3ba8de03000cc0a417836da4d0ae4013be482dce89285e04e559ca065b129e4d743a193774bf287a6421f9d39e23177d8bf603b236be337811be10a';6export const checkParams = {7 privateKey: '0x2919c43d5c712cae66f869a524d9523999998d51157dc40ac4d8d80a7602ce02',8 password: 'pass',9 nonce: '1',10 chainId: '1',11 coin: '0',12 value: '10',13 gasCoin: '0',14 dueBlock: '999999',15};16describe('issueCheck()', () => {17 test('should work', () => {18 const check = issueCheck(checkParams);19 expect(check).toEqual(VALID_CHECK);20 });21 test('should accept buffer private key', () => {22 const check = issueCheck({23 ...checkParams,24 privateKey: Buffer.from(checkParams.privateKey.substr(2), 'hex'),25 });26 expect(check).toEqual(VALID_CHECK);27 });28 test('should work with custom gasCoin', () => {29 expect(issueCheck({30 ...checkParams,31 gasCoin: '5',32 })).toEqual(VALID_CHECK_WITH_CUSTOM_GAS_COIN);33 });34 test('default dueBlock: 999999', () => {35 expect(issueCheck({36 ...checkParams,37 dueBlock: undefined,38 })).toEqual(issueCheck({39 ...checkParams,40 dueBlock: 999999999,41 }));42 });43 test('default chainId: 1', () => {44 expect(issueCheck({45 ...checkParams,46 chainId: undefined,47 })).toEqual(issueCheck({48 ...checkParams,49 chainId: 1,50 }));51 });52 test('default gasCoin: 0 (base coin)', () => {53 expect(issueCheck({54 ...checkParams,55 gasCoin: undefined,56 })).toEqual(issueCheck({57 ...checkParams,58 gasCoin: '0',59 }));60 });61 test('numeric nonce should be treated as string', () => {62 expect(issueCheck({63 ...checkParams,64 nonce: 123,65 })).toEqual(issueCheck({66 ...checkParams,67 nonce: '123',68 }));69 });70 test('should throw on invalid dueBlock', () => {71 expect(() => issueCheck({72 ...checkParams,73 dueBlock: '123asd',74 })).toThrow();75 });76 test('should throw on invalid value', () => {77 expect(() => issueCheck({78 ...checkParams,79 value: '123asd',80 })).toThrow();81 });82 test('should throw with invalid gasCoin', () => {83 expect(() => issueCheck({84 ...checkParams,85 gasCoin: true,86 })).toThrow();87 });88 test('should throw with string gasCoin', () => {89 expect(() => issueCheck({90 ...checkParams,91 gasCoin: 'AA',92 })).toThrow();93 });94});95describe('decodeCheck()', () => {96 const checkParamsWithoutSensitiveData = Object.assign({}, checkParams);97 delete checkParamsWithoutSensitiveData.password;98 delete checkParamsWithoutSensitiveData.privateKey;99 test('should work', () => {100 expect(decodeCheck(VALID_CHECK)).toEqual(checkParamsWithoutSensitiveData);101 });102 test('should not lose precision', () => {103 const bigValue = '123456789012345.123456789012345678';104 const check = issueCheck({...checkParams, value: bigValue});105 expect(decodeCheck(check).value).toEqual(bigValue);106 });107});108describe('getGasCoinFromCheck()', () => {109 test('should work', () => {110 const check = issueCheck(checkParams);111 expect(getGasCoinFromCheck(check)).toEqual('0');112 });...
check-params.test.js
Source:check-params.test.js
1const2 {expect,assert} = require('chai')3 ,CheckParams = require('./../lib/check-params')4 ,NormalizeParamsFactory = require('./../lib/normalize-params')5;6describe('test `CheckParams` class' , () => {7 it('should be an function' , () => {8 assert.isFunction( CheckParams ) ;9 } ) ;10 it('should \\throw RangeError' , () => {11 const fxRangeError = () => new CheckParams( 42 ) ;12 expect( fxRangeError ).to.throw( RangeError , 'arg1 constructor should be an params object' ) ;13 } ) ;14 let argsFactory = new NormalizeParamsFactory( {15 type: ' routes-crud',16 name: ' user ' ,17 action: '/:slug/:id' ,18 requestName: ' request ' ,19 responseName: ' response '20 } ).params ;21 let checkParams = new CheckParams( argsFactory ) ;22 describe('test build object' , () => {23 it('should be an object' , () => {24 assert.isObject( checkParams ) ;25 } ) ;26 it('should have property params' , () => {27 expect( checkParams ).to.have.property( 'params' ) ;28 // property `params` test with: /test/normalize-params.test.js29 assert.isObject( checkParams.params ) ;30 } ) ;31 describe('test property status' , () => {32 it('should have status property' , () => {33 expect( checkParams ).to.have.property( 'status' ) ;34 assert.isObject( checkParams.status ) ;35 } ) ;36 it('should have property isValid boolean' , () => {37 expect( checkParams.status ).to.have.property( 'isValid' ) ;38 assert.isBoolean( checkParams.status.isValid ) ;39 assert.isTrue( checkParams.status.isValid ) ;40 argsFactory = new NormalizeParamsFactory( {41 type: ' truc', //not valid42 name: ' user ' ,43 action: '/:slug/:id' ,44 requestName: ' request ' ,45 responseName: ' response '46 } ).params ;47 checkParams = new CheckParams( argsFactory ) ;48 expect( checkParams.status ).to.have.property( 'isValid' ) ;49 assert.isBoolean( checkParams.status.isValid ) ;50 assert.isFalse( checkParams.status.isValid ) ;51 } ) ;52 it('should have property error ?int' , () => {53 expect( checkParams.status ).to.have.property('error') ;54 assert.isNumber( checkParams.status.error ) ;55 expect( checkParams.status.error ).to.be.equal( 400 ) ;56 argsFactory = new NormalizeParamsFactory( {57 type: ' routes-crud',58 name: ' user ' ,59 action: '/:slug/:id' ,60 requestName: ' request ' ,61 responseName: ' response '62 } ).params ;63 checkParams = new CheckParams( argsFactory ) ;64 assert.isNull( checkParams.status.error ) ;65 } ) ;66 } ) ;67 } ) ;...
checkParams.test.js
Source:checkParams.test.js
1 const checkParams = require('../utils/checkParams.js');2 test('test login', () => {3 expect(checkParams('login', 'name')).toBe(true);4 });5 test('test login', () => {6 expect(checkParams('login','name','passw')).toBe(false);7 });8 test('test logout', () => {9 expect(checkParams('logout')).toBe(true);10 });11 12 test('test logout', () => {13 expect(checkParams('logout','name','passw')).toBe(false);14 }); 15 test('test usermod', () => {16 expect(checkParams('usermod','param1','param2')).toBe(true);17 });18 19 test('test usermod', () => {20 expect(checkParams('usermod','param1','param2','param3')).toBe(false);21 }); 22 23 test('test users', () => {24 expect(checkParams('users','param1')).toBe(true);25 });26 27 test('test users', () => {28 expect(checkParams('users','param1','param2','param3')).toBe(false);29 }); 30 test('SessionsPerPoint', () => {31 expect(checkParams('SessionsPerPoint','param1','param2','param3')).toBe(true);32 }); 33 34 test('SessionsPerEv', () => {35 expect(checkParams('SessionsPerEv','param1','param2','param3','param4','param5')).toBe(false);36 });37 38 39 test('SessionsPerEv', () => {40 expect(checkParams('SessionsPerEv','param1','param3')).toBe(true);41 }); 42 43 test('SessionsPerEv', () => {44 expect(checkParams('SessionsPerEv','param1','param2','param3','param4','param5')).toBe(false);45 });46 47 test('SessionsPerPoint', () => {48 expect(checkParams('SessionsPerPoint','param1','param3')).toBe(true);49 });50 test('SessionsPerPoint', () => {51 expect(checkParams('SessionsPerPoint','param1','param2','param3')).toBe(true);52 }); 53 54 test('SessionsPerPoint', () => {55 expect(checkParams('SessionsPerPoint','param1','param2','param3','param4','param5')).toBe(false);...
Using AI Code Generation
1const BaseDriver = require('appium-base-driver');2const { checkParams } = BaseDriver;3const args = {a: 1, b: 2};4const required = ['a', 'b'];5const optional = ['c'];6checkParams(args, required, optional, 'MyDriver.constructor', true);7const BaseDriver = require('appium-base-driver');8const { checkParams } = BaseDriver;9const args = {a: 1, b: 2};10const required = ['a', 'b'];11const optional = ['c'];12checkParams(args, required, optional, 'MyDriver.constructor', true);13const BaseDriver = require('appium-base-driver');14const { checkParams } = BaseDriver;15const args = {a: 1, b: 2};16const required = ['a', 'b'];17const optional = ['c'];18checkParams(args, required, optional, 'MyDriver.constructor', true);19const BaseDriver = require('appium-base-driver');20const { checkParams } = BaseDriver;21const args = {a: 1, b: 2};22const required = ['a', 'b'];23const optional = ['c'];24checkParams(args, required, optional, 'MyDriver.constructor', true);25const BaseDriver = require('appium-base-driver');26const { checkParams } = BaseDriver;27const args = {a: 1, b: 2};28const required = ['a', 'b'];29const optional = ['c'];30checkParams(args, required, optional, 'MyDriver.constructor', true);31const BaseDriver = require('appium-base-driver');32const { checkParams } = BaseDriver;33const args = {a: 1, b: 2};34const required = ['a', 'b'];35const optional = ['c'];36checkParams(args, required, optional, 'MyDriver.constructor', true);
Using AI Code Generation
1var BaseDriver = require('appium-base-driver').BaseDriver;2var driver = new BaseDriver();3driver.checkParams({app: 'test.apk', platformName: 'Android', deviceName: 'Android Emulator'});4var AndroidDriver = require('appium-android-driver').AndroidDriver;5var driver = new AndroidDriver();6driver.checkParams({app: 'test.apk', platformName: 'Android', deviceName: 'Android Emulator'});7var IOSDriver = require('appium-ios-driver').IOSDriver;8var driver = new IOSDriver();9driver.checkParams({app: 'test.apk', platformName: 'iOS', deviceName: 'iPhone Simulator'});10var WindowsDriver = require('appium-windows-driver').WindowsDriver;11var driver = new WindowsDriver();12driver.checkParams({app: 'test.apk', platformName: 'Windows', deviceName: 'Windows Phone Emulator'});13var YouiEngineDriver = require('appium-youiengine-driver').YouiEngineDriver;14var driver = new YouiEngineDriver();15driver.checkParams({app: 'test.apk', platformName: 'YouiEngine', deviceName: 'Android Emulator'});16var SelendroidDriver = require('appium-selendroid-driver').SelendroidDriver;17var driver = new SelendroidDriver();18driver.checkParams({app: 'test.apk', platformName: 'Android', deviceName: 'Android Emulator'});19var XCUITestDriver = require('appium-xcuitest-driver').XCUITestDriver;20var driver = new XCUITestDriver();21driver.checkParams({app: 'test.apk', platformName: 'iOS', deviceName: 'iPhone Simulator'});22var MacDriver = require('appium-mac-driver').MacDriver;23var driver = new MacDriver();24driver.checkParams({app: 'test.apk', platformName: 'Mac', deviceName
Using AI Code Generation
1public class SumOfNumbers {2 public static void main(String[] args) {3 Scanner input = new Scanner(System.in);4 System.out.print("Enter a number: ");5 int number = input.nextInt();6 int sum = 0;7 int i = 1;8 while (i <= number) {9 sum = sum + i;10 i++;11 }12 System.out.println("Sum of 1 to " + number + " = " + sum);13 }14}15public class SumOfNumbers {16 public static void main(String[] args) {17 Scanner input = new Scanner(System.in);18 System.out.print("Enter a number: ");19 int number = input.nextInt();20 int sum = 0;21 int i = 1;22 while (i <= number) {23 sum = sum + i;24 i++;25 }26 System.out.println("
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!