You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.8 KiB
61 lines
1.8 KiB
import flet as ft
|
|
import requests
|
|
from requests.auth import HTTPBasicAuth
|
|
import csv
|
|
from globalState import AppState
|
|
import asyncio
|
|
import aiohttp
|
|
|
|
def customers(page: ft.Page):
|
|
page.title = "Customers"
|
|
|
|
user = AppState.user
|
|
password = AppState.password
|
|
url = AppState.url
|
|
if url.endswith("/"):
|
|
url = url[:-1]
|
|
url = f"{url}:1443/api/customers"
|
|
|
|
response = requests.get(url, auth=HTTPBasicAuth(user, password), verify=False)
|
|
|
|
if response.status_code == 200:
|
|
data = response.json()
|
|
customer = data['_embedded']['ngcp:customers']
|
|
|
|
rows = []
|
|
|
|
for custom in customer:
|
|
id = custom['id']
|
|
external_id = custom['external_id']
|
|
email = custom['contact_id']
|
|
billing_profile = custom['billing_profile_id']
|
|
status = custom['status']
|
|
|
|
rows.append(
|
|
ft.DataRow(
|
|
cells=[
|
|
ft.DataCell(ft.Text(str(id))),
|
|
ft.DataCell(ft.Text(str(external_id))),
|
|
ft.DataCell(ft.Text(email)),
|
|
ft.DataCell(ft.Text(billing_profile)),
|
|
ft.DataCell(ft.Text(status)),
|
|
]
|
|
)
|
|
)
|
|
|
|
table = ft.DataTable(
|
|
columns=[
|
|
ft.DataColumn(ft.Text("#")),
|
|
ft.DataColumn(ft.Text("External ID")),
|
|
ft.DataColumn(ft.Text("Email")),
|
|
ft.DataColumn(ft.Text("Billing Profiles ")),
|
|
ft.DataColumn(ft.Text("Status")),
|
|
],
|
|
rows=rows
|
|
)
|
|
|
|
page.add(table)
|
|
page.update()
|
|
else:
|
|
page.add(ft.Text(f"Error al obtener datos: {response.status_code}"))
|
|
page.update() |