Skip to content

Commit

Permalink
[IMP] busqueda por nombre
Browse files Browse the repository at this point in the history
  • Loading branch information
cgsmadmin committed Jun 15, 2019
1 parent bb1adaf commit 4834b74
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 40 deletions.
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
History
=======

0.2.10 (2019-06-13)
-------------------
* Busqueda por nombre y cedula desde registro civil

0.2.1 (2017-12-19)
------------------

Expand Down
48 changes: 38 additions & 10 deletions runa/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
PASSWORD,
CODAGENCIA,
CODINSTITUCION,
WS_ENABLED
WS_ENABLED,
)
from .models import PreparedRuna, PreparedContribuyente

logger = logging.getLogger('runa')
logger = logging.getLogger("runa")


def login(WSDL):
Expand All @@ -45,19 +45,21 @@ def login(WSDL):
factory.Urlsw = WSDL
response = cl_auth.service.ValidarPermiso(factory)

if response.TienePermiso == 'N':
logger.error('%s %s' % (response.Mensaje.CodError, response.Mensaje.DesError)) # noqa
if response.TienePermiso == "N":
logger.error(
"%s %s" % (response.Mensaje.CodError, response.Mensaje.DesError)
) # noqa
return False, False
return response, client


def login_service(service='sri'):
def login_service(service="sri"):
return login(WS_ENABLED[service])


def _has_error(response):
if not response.CodigoError == '000':
return '{0} {1}'.format(response.CodigoError, response.Error)
if not response.CodigoError == "000":
return "{0} {1}".format(response.CodigoError, response.Error)


def create_tokens(response):
Expand All @@ -81,7 +83,7 @@ def set_token(response, client):
client.set_options(wsse=security)


def read_by_nui(nui, mode='prod', authorized_nui=AUTHORIZED_NUI):
def read_by_nui(nui, mode="prod", authorized_nui=AUTHORIZED_NUI):
response, client = login(WS_CIUDADANO)
if not response:
return False
Expand All @@ -93,7 +95,7 @@ def read_by_nui(nui, mode='prod', authorized_nui=AUTHORIZED_NUI):
Usuario=USER,
Contrasenia=PASSWORD,
CodigoInstitucion=CODINSTITUCION,
CodigoAgencia=CODAGENCIA
CodigoAgencia=CODAGENCIA,
)
error = _has_error(consulta_response)
if error:
Expand All @@ -103,7 +105,33 @@ def read_by_nui(nui, mode='prod', authorized_nui=AUTHORIZED_NUI):
return runa


def busqueda_por_nui(nui, mode='prod', authorized_nui=AUTHORIZED_NUI):
def busqueda_por_nombre(
apellido1, apellido2, nombre1, nombre2, AUTHORIZED_NUI=AUTHORIZED_NUI
):
response, client = login(WS_CIUDADANO)
if not response:
return False
security = create_tokens(response)
client.set_options(wsse=security)
consulta_response = client.service.BusquedaPorNombre(
Apellido1=apellido1,
Apellido2=apellido2,
Nombre1=nombre1,
Nombre2=nombre2,
Usuario=USER,
Contrasenia=PASSWORD,
CodigoInstitucion=CODINSTITUCION,
CodigoAgencia=CODAGENCIA,
)
error = _has_error(consulta_response)
if error:
raise Exception(error)
runa = PreparedRuna()
runa.prepare_by_name(consulta_response)
return runa


def busqueda_por_nui(nui, mode="prod", authorized_nui=AUTHORIZED_NUI):
return read_by_nui(nui, mode=mode, authorized_nui=authorized_nui)


Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.1.0
current_version = 0.2.10
commit = True
tag = True

Expand Down
48 changes: 19 additions & 29 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@

from setuptools import setup, find_packages

with open('README.rst') as readme_file:
with open("README.rst") as readme_file:
readme = readme_file.read()

with open('HISTORY.rst') as history_file:
with open("HISTORY.rst") as history_file:
history = history_file.read()

requirements = [
'Click>=6.0',
'suds2==0.7.1'
]
requirements = ["Click>=6.0", "suds2==0.7.1"]

setup_requirements = [
# TODO(ovnicraft): put setup requirements (distutils extensions, etc.) here
Expand All @@ -25,37 +22,30 @@
]

setup(
name='runa',
version='0.2.9',
name="runa",
version="0.2.10",
description="Librería para uso de WS del Bus Gubernamental de Ecuador",
long_description=readme + '\n\n' + history,
long_description=readme + "\n\n" + history,
author="Cristian Salamea",
author_email='[email protected]',
url='https://github.com/ovnicraft/runa',
packages=find_packages(include=['runa']),
entry_points={
'console_scripts': [
'runa=runa.cli:main'
]
},
author_email="[email protected]",
url="https://github.com/ovnicraft/runa",
packages=find_packages(include=["runa"]),
entry_points={"console_scripts": ["runa=runa.cli:main"]},
include_package_data=True,
install_requires=requirements,
license="MIT license",
zip_safe=False,
keywords='runa webservices ecuador bgs',
keywords="runa webservices ecuador bgs",
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
"Development Status :: 3 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
],
test_suite='tests',
test_suite="tests",
tests_require=test_requirements,
setup_requires=setup_requirements,
)

0 comments on commit 4834b74

Please sign in to comment.