Spaces:
Sleeping
Sleeping
Round to test Usage Api
Browse files
app.py
CHANGED
|
@@ -138,15 +138,26 @@ async def status_callback(request: Request):
|
|
| 138 |
# Consultar costo real de uso de WhatsApp del d铆a (cobro por conversaci贸n)
|
| 139 |
if message_status == 'delivered':
|
| 140 |
try:
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
except Exception as e:
|
| 151 |
print(f"鈿狅笍 No se pudo obtener uso de WhatsApp: {str(e)}")
|
| 152 |
|
|
|
|
| 138 |
# Consultar costo real de uso de WhatsApp del d铆a (cobro por conversaci贸n)
|
| 139 |
if message_status == 'delivered':
|
| 140 |
try:
|
| 141 |
+
whatsapp_categories = [
|
| 142 |
+
'channels-whatsapp-service',
|
| 143 |
+
'channels-whatsapp-template-marketing',
|
| 144 |
+
'channels-whatsapp-template-utility',
|
| 145 |
+
'channels-whatsapp-template-authentication',
|
| 146 |
+
'channels-whatsapp-conversation-free',
|
| 147 |
+
'channels-messaging-inbound',
|
| 148 |
+
'channels-messaging-outbound',
|
| 149 |
+
]
|
| 150 |
+
print(f"\n馃挵 USO WHATSAPP HOY:")
|
| 151 |
+
for category in whatsapp_categories:
|
| 152 |
+
try:
|
| 153 |
+
records = client.usage.records.today.list(category=category)
|
| 154 |
+
for record in records:
|
| 155 |
+
if float(record.count) > 0 or float(record.price) > 0:
|
| 156 |
+
print(f" {record.description}:")
|
| 157 |
+
print(f" Cantidad: {record.count} {record.count_unit}")
|
| 158 |
+
print(f" Costo: {record.price} {record.price_unit}")
|
| 159 |
+
except Exception:
|
| 160 |
+
pass
|
| 161 |
except Exception as e:
|
| 162 |
print(f"鈿狅笍 No se pudo obtener uso de WhatsApp: {str(e)}")
|
| 163 |
|