csc-cia-stne 0.1.24__tar.gz → 0.1.26__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/PKG-INFO +1 -1
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/pyproject.toml +1 -1
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/stne_admin.py +112 -23
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne.egg-info/PKG-INFO +1 -1
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/LICENCE +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/README.md +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/README_PYPI.md +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/setup.cfg +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/__init__.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/bc_correios.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/bc_sta.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/email.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/ftp.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/gcp_bigquery.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/gcp_bucket.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/google_drive.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/karavela.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/logger_json.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/logger_rich.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/provio.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/servicenow.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/slack.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/__init__.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/functions/__init__.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/functions/func_b64.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/functions/func_converters.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/functions/func_datetime.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/functions/func_delete.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/functions/func_get_secret.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/functions/func_recriar_pastas.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/functions/func_settings.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/functions/func_titulo.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/functions/func_validate_json.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/validations/GcpBigQueryValidator.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/validations/GoogleDriveValidator.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/validations/ServiceNowValidator.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/validations/__init__.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/validations/ftp.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/validations/gcp_bucket.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/validations/waccess.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/validations/web_validator.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/web_screen/__init__.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/web_screen/web_screen_abstract.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/web_screen/web_screen_botcity.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/web_screen/web_screen_selenium.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/wacess.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/web.py +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne.egg-info/SOURCES.txt +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne.egg-info/dependency_links.txt +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne.egg-info/requires.txt +0 -0
- {csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne.egg-info/top_level.txt +0 -0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "csc_cia_stne"
|
7
|
-
version = "0.1.
|
7
|
+
version = "0.1.26"
|
8
8
|
license = { text = "MIT" }
|
9
9
|
description = "Biblioteca do time CSC-CIA utilizada no desenvolvimento de RPAs"
|
10
10
|
keywords = ["karavela", "csc", "cia", "stone", "rpa", "botcity", "stne"]
|
@@ -1,14 +1,9 @@
|
|
1
|
+
import re
|
1
2
|
import requests
|
2
3
|
import jwt
|
3
4
|
from datetime import datetime, timedelta
|
4
5
|
import time
|
5
|
-
#import subprocess
|
6
6
|
import json
|
7
|
-
#from modules.pdf import gerar_pdf_extrato
|
8
|
-
#import csv
|
9
|
-
#import io
|
10
|
-
#import sys
|
11
|
-
#import logging
|
12
7
|
from pydantic import BaseModel, StrictStr, StrictInt, ValidationError, field_validator, FieldValidationInfo
|
13
8
|
from typing import Literal
|
14
9
|
|
@@ -217,7 +212,6 @@ class StoneAdmin:
|
|
217
212
|
|
218
213
|
raise Exception(f"Falha ao logar no Stone Admin:\n{response.json()}")
|
219
214
|
|
220
|
-
|
221
215
|
def renew_authorization(self):
|
222
216
|
"""
|
223
217
|
Renova a autorização do usuário.
|
@@ -419,7 +413,7 @@ class StoneAdmin:
|
|
419
413
|
response = requests.get(f"{self.base_url}/accounts/{account_id}", headers=self.authenticated_header)
|
420
414
|
return response
|
421
415
|
|
422
|
-
def
|
416
|
+
def __detalhar_titular_cpf(self,documento:str):
|
423
417
|
"""
|
424
418
|
Detalha o titular do CPF fornecido.
|
425
419
|
Args:
|
@@ -438,20 +432,31 @@ class StoneAdmin:
|
|
438
432
|
DocumentoValidator(documento=documento)
|
439
433
|
|
440
434
|
except ValidationError as e:
|
441
|
-
|
442
|
-
|
435
|
+
|
436
|
+
return {"success": False, "status_code": 400, "error": f"Erro na validação dos dados de input do método: {e.errors()}"}
|
443
437
|
|
444
438
|
# Detalha o titular
|
445
439
|
|
446
440
|
# Verificar na rota /users (CPF)
|
441
|
+
documento = re.sub(r"\D", "", documento)
|
447
442
|
filtro = {'document': documento}
|
448
443
|
param = {
|
449
|
-
'filter': json.dumps(filtro) # Transforma o dicionário em uma string JSON
|
444
|
+
'filter': json.dumps(filtro), # Transforma o dicionário em uma string JSON
|
445
|
+
'sort': json.dumps(['created_at','DESC'])
|
450
446
|
}
|
451
|
-
|
452
|
-
|
447
|
+
try:
|
448
|
+
response = requests.get(f"{self.base_url}/users", params=param, headers=self.authenticated_header)
|
449
|
+
if response.status_code == 401 and 'unauthenticated' in str(response.json()):
|
450
|
+
self.renew_authorization()
|
451
|
+
return self.__detalhar_titular_cpf(documento=documento)
|
452
|
+
elif response.status_code != 200:
|
453
|
+
return {"success": False, "status_code": response.status_code, "error": f"{response.text}"}
|
454
|
+
else:
|
455
|
+
return {"success": True, "status_code": response.status_code, "data": response.json()}
|
456
|
+
except Exception as e:
|
457
|
+
return {"success": False, "status_code": 500, "error": str(e)}
|
453
458
|
|
454
|
-
def
|
459
|
+
def __detalhar_titular_cnpj(self,documento:str):
|
455
460
|
"""
|
456
461
|
Detalha o titular de um CNPJ.
|
457
462
|
Args:
|
@@ -470,16 +475,36 @@ class StoneAdmin:
|
|
470
475
|
DocumentoValidator(documento=documento)
|
471
476
|
|
472
477
|
except ValidationError as e:
|
473
|
-
|
474
|
-
raise ValueError("Erro na validação dos dados de input do método:", e.errors())
|
478
|
+
return {"success": False, "status_code": 400, "error": f"Erro na validação dos dados de input do método: {e.errors()}"}
|
475
479
|
|
476
480
|
# Verificar na rota /organizations (CNPJ)
|
481
|
+
documento = re.sub(r"\D", "", documento)
|
477
482
|
filtro = {'document': documento}
|
483
|
+
|
478
484
|
param = {
|
479
|
-
'filter': json.dumps(filtro) # Transforma o dicionário em uma string JSON
|
485
|
+
'filter': json.dumps(filtro), # Transforma o dicionário em uma string JSON
|
486
|
+
'sort': json.dumps(['created_at','DESC'])
|
480
487
|
}
|
481
|
-
|
482
|
-
|
488
|
+
try:
|
489
|
+
response = requests.get(f"{self.base_url}/organizations", params=param, headers=self.authenticated_header)
|
490
|
+
if response.status_code == 401 and 'unauthenticated' in str(response.json()):
|
491
|
+
self.renew_authorization()
|
492
|
+
return self.__detalhar_titular_cnpj(documento=documento)
|
493
|
+
elif response.status_code != 200:
|
494
|
+
return {"success": False, "status_code": response.status_code, "error": f"{response.text}"}
|
495
|
+
else:
|
496
|
+
return {"success": True, "status_code": response.status_code, "data": response.json()}
|
497
|
+
except Exception as e:
|
498
|
+
return {"success": False, "status_code": 500, "error": str(e)}
|
499
|
+
|
500
|
+
def detalhar_titular(self,tipo_documento:str,documento:str):
|
501
|
+
documento = re.sub(r"\D", "", documento)
|
502
|
+
if str(tipo_documento).strip().upper() == 'F':
|
503
|
+
return self.__detalhar_titular_cpf(documento=documento)
|
504
|
+
elif str(tipo_documento).strip().upper() == 'J':
|
505
|
+
return self.__detalhar_titular_cnpj(documento=documento)
|
506
|
+
else:
|
507
|
+
return {"success": False, "error": "Tipo de documento inválido. Use 'F' para CPF ou 'J' para CNPJ."}
|
483
508
|
|
484
509
|
def extrair_extrato(self,account_id:str,data_inicio:datetime,data_fim:datetime,async_mode:bool=False):
|
485
510
|
"""
|
@@ -527,12 +552,12 @@ class StoneAdmin:
|
|
527
552
|
|
528
553
|
except ValidationError as e:
|
529
554
|
|
530
|
-
|
555
|
+
return {"success": False, "status_code": 400, "error": f"Erro na validação dos dados de input do método: {e.errors()}"}
|
531
556
|
|
532
557
|
# Validação do async_mode
|
533
558
|
if not isinstance(async_mode, bool):
|
534
|
-
|
535
|
-
|
559
|
+
|
560
|
+
return {"success": False, "status_code": 400, "error": "async_mode deve ser um valor booleano."}
|
536
561
|
|
537
562
|
|
538
563
|
data_inicio = data_inicio.strftime('%Y-%m-%d')
|
@@ -612,4 +637,68 @@ class StoneAdmin:
|
|
612
637
|
|
613
638
|
except Exception as e:
|
614
639
|
|
615
|
-
return {'result': False, 'status_code': None, 'error': e, 'pdf_content': None}
|
640
|
+
return {'result': False, 'status_code': None, 'error': e, 'pdf_content': None}
|
641
|
+
|
642
|
+
def legal_entities(self, documento: str) -> dict:
|
643
|
+
"""
|
644
|
+
Consulta informações de entidades legais por documento.
|
645
|
+
|
646
|
+
Args:
|
647
|
+
documento (str): Número do documento (CPF ou CNPJ) para consulta.
|
648
|
+
Aceita documento com ou sem formatação.
|
649
|
+
|
650
|
+
Returns:
|
651
|
+
dict: Dicionário contendo o resultado da consulta:
|
652
|
+
- success (bool): Indica se a operação foi bem-sucedida.
|
653
|
+
- data (list): Lista de entidades encontradas (se success=True).
|
654
|
+
- error (str): Mensagem de erro (se success=False).
|
655
|
+
|
656
|
+
Raises:
|
657
|
+
ValueError: Se ocorrer erro na validação dos dados de entrada.
|
658
|
+
|
659
|
+
Example:
|
660
|
+
>>> admin = StoneAdmin(client_id, user_agent, private_key, ambiente)
|
661
|
+
>>> resultado = admin.legal_entities("12345678901234")
|
662
|
+
>>> if resultado["success"]:
|
663
|
+
... print(f"Encontradas {len(resultado['data'])} entidades")
|
664
|
+
... for entidade in resultado["data"]:
|
665
|
+
... print(entidade)
|
666
|
+
... else:
|
667
|
+
... print(f"Erro: {resultado['error']}")
|
668
|
+
"""
|
669
|
+
|
670
|
+
try:
|
671
|
+
# Validação usando a classe existente
|
672
|
+
DocumentoValidator(documento=documento)
|
673
|
+
|
674
|
+
except ValidationError as e:
|
675
|
+
return {"success": False, "status_code": 400, "error": f"Erro na validação dos dados de input do método: {e.errors()}"}
|
676
|
+
|
677
|
+
# Remove formatação do documento
|
678
|
+
documento_limpo = re.sub(r"\D", "", documento)
|
679
|
+
|
680
|
+
filtro = {'main_document_value': documento_limpo}
|
681
|
+
param = {
|
682
|
+
'filter': json.dumps(filtro)
|
683
|
+
}
|
684
|
+
|
685
|
+
try:
|
686
|
+
response = requests.get(
|
687
|
+
f"{self.base_url}/legal-entities",
|
688
|
+
params=param,
|
689
|
+
headers=self.authenticated_header,
|
690
|
+
timeout=120
|
691
|
+
)
|
692
|
+
|
693
|
+
# Verifica se houve erro de autenticação
|
694
|
+
if response.status_code == 401 and 'unauthenticated' in str(response.json()):
|
695
|
+
self.renew_authorization()
|
696
|
+
return self.legal_entities(documento=documento)
|
697
|
+
|
698
|
+
if response.status_code == 200:
|
699
|
+
return {"success": True, "status_code": 200, "data": response.json()}
|
700
|
+
else:
|
701
|
+
return {"success": False, "status_code": response.status_code, "error": f"Status {response.status_code}: {response.text}"}
|
702
|
+
|
703
|
+
except Exception as e:
|
704
|
+
return {"success": False, "error": str(e)}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/functions/__init__.py
RENAMED
File without changes
|
{csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/functions/func_b64.py
RENAMED
File without changes
|
File without changes
|
{csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/functions/func_datetime.py
RENAMED
File without changes
|
{csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/functions/func_delete.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/functions/func_settings.py
RENAMED
File without changes
|
{csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/functions/func_titulo.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/validations/__init__.py
RENAMED
File without changes
|
File without changes
|
{csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/validations/gcp_bucket.py
RENAMED
File without changes
|
{csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/validations/waccess.py
RENAMED
File without changes
|
File without changes
|
{csc_cia_stne-0.1.24 → csc_cia_stne-0.1.26}/src/csc_cia_stne/utilitarios/web_screen/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|