-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.py
82 lines (66 loc) · 2.42 KB
/
cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from types import NoneType
import click
from datetime import datetime
from rich.console import Console
from rich.table import Table
from soa_sdk.client import SOAWebServicesClient
console = Console()
@click.group()
def cli():
"""SOA WebServices CLI"""
pass
@cli.command()
def saldo():
"""Get account balance"""
client = SOAWebServicesClient()
result = client.get_saldo()
# result = client.get_balance_rest()
table = Table(title="Account Balance")
table.add_column("Saldo")
table.add_row(str(result.get('Saldo', 'N/A')))
console.print(table)
@cli.command()
@click.option('--ano', type=int, required=True, help='Year')
@click.option('--mes', type=int, required=True, help='Month')
def extrato_sintetico(ano: int, mes: int):
"""Get synthetic statement"""
client = SOAWebServicesClient()
result = client.get_extrato_sintetico(ano, mes)
table = Table(title="Synthetic Statement")
table.add_column("Total Quantity")
table.add_column("Total Value")
table.add_row(
str(result.get('ConsumoQuantidadeTotal', 'N/A')),
str(result.get('ConsumoValorTotal', 'N/A'))
)
console.print(table)
@cli.command()
@click.option('--documento', required=True, help='Document number')
@click.option('--data-nascimento', help='Birth date (YYYY-MM-DD)')
def pessoa_fisica_nfe(documento: str, data_nascimento: str):
"""Get NFe information for individual"""
client = SOAWebServicesClient()
result = client.get_pessoa_fisica_nfe(documento, data_nascimento)
table = Table(title="Individual NFe Information")
table.add_column("Field")
table.add_column("Value")
for key, value in result.items():
if isinstance(value, (str, int, float, NoneType)):
table.add_row(key, str(value))
console.print(table)
@cli.command()
@click.option('--documento', required=True, help='Document number')
def pessoa_juridica_nfe(documento: str):
"""Get NFe information for company"""
client = SOAWebServicesClient()
result = client.get_pessoa_juridica_nfe(documento)
table = Table(title="Company NFe Information")
table.add_column("Field")
table.add_column("Value")
for key, value in result.items():
if isinstance(value, (str, int, float)):
table.add_row(key, str(value))
console.print(table)
cli.add_command(pessoa_fisica_nfe, name='pessoafisicanfe')
if __name__ == '__main__':
cli()