-
Notifications
You must be signed in to change notification settings - Fork 184
Add bidirectional call/sms send #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,11 +9,28 @@ const emitSuccess = message => console.log(green(` ✔ Sucesso: ${message}`)); | |
| const emitError = message => console.log(red(` ✗ Erro: ${message}`)); | ||
|
|
||
| function cli(args) { | ||
| gemidao(args) | ||
| .then(() => { | ||
| emitSuccess(args.sms ? 'sms enviado!' : 'chamada efetuada!'); | ||
| }) | ||
| .catch(pipe(prop('message'), emitError)); | ||
| if(args.bidirecional){ | ||
| send(args); | ||
| var temp = args.de; | ||
| args.de = args.para; | ||
| args.para = temp; | ||
| send(args); | ||
| }else{ | ||
| send(args); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| function bidirecional(args){ | ||
|
|
||
| } | ||
|
|
||
| function send(arg){ | ||
| gemidao(arg) | ||
| .then(() => { | ||
| emitSuccess(arg.sms ? 'sms enviado!' : 'chamada efetuada!'); | ||
| }) | ||
| .catch(pipe(prop('message'), emitError)); | ||
| } | ||
|
|
||
| cli(yargs | ||
|
|
@@ -34,6 +51,10 @@ cli(yargs | |
| describe: 'Se definido, será enviado um SMS ao invés de uma chamada', | ||
| type: 'boolean' | ||
| }) | ||
| .option('bidirecional', { | ||
| describe: 'Defini se a chamada deve ser enviada para ambos os números', | ||
|
||
| type: 'boolean' | ||
| }) | ||
| .demandOption(['para', 'token']) | ||
| .locale('pt_BR') | ||
| .strict() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sugestão de código utilizando ES6:
É importante ressalvar que
send()é assíncrono. Eu não sei como a API se comportaria com duas chamadas simultâneas. Talvez fosse bacana você encadear a promise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pela minha configuração do linter atual, até o
letvai ser barrado. Ele vai permitir somenteconst, e vai bloquear reatribuição/mutabilidade (paradigma funcional).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O ideal também é que a lógica aconteça dentro do
gemidao.js, que é onde lida com os argumentos. Ocli.jssó despacha.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opa, bem lembrado, @haskellcamargo. Nem cheguei a ler as configs do Lint ainda.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ele tá barrando
let,var,try,forewhile, pelo que lembro.