facho/cli.py: nuevo subcomando sendtestsetasync para envio de peticion soap

FossilOrigin-Name: 778df44a974144037dedb125ce8539b18540c2b3ce85b9f352cff06ebc1bdce3
This commit is contained in:
bit4bit@riseup.net 2020-05-23 21:06:25 +00:00
parent 24b227710e
commit a369585f73
2 changed files with 56 additions and 7 deletions

View File

@ -42,8 +42,25 @@ def consultaResolucionesFacturacion(nit, nit_proveedor, id_software, username, p
print(str(resp)) print(str(resp))
@click.command()
@click.option('--private-key', required=True)
@click.option('--public-key', required=True)
@click.option('--password')
@click.argument('filename', required=True)
@click.argument('zipfile', type=click.Path(exists=True))
def SendTestSetAsync(private_key, public_key, password, filename, zipfile):
from facho.fe.client import dian
client = dian.DianSignatureClient(private_key, public_key, password=password)
resp = client.request(dian.SendTestSetAsync(
filename, zipfile.read().encode('utf-8')
))
print(resp)
@click.group() @click.group()
def main(): def main():
pass pass
main.add_command(consultaResolucionesFacturacion) main.add_command(consultaResolucionesFacturacion)
main.add_command(SendTestSetAsync)

View File

@ -2,7 +2,7 @@ from facho import facho
import zeep import zeep
from zeep.wsse.username import UsernameToken from zeep.wsse.username import UsernameToken
from zeep.wsse.signature import Signature
import urllib.request import urllib.request
from datetime import datetime from datetime import datetime
@ -91,14 +91,25 @@ class SendBillAsync:
return {} return {}
class DianClient: @dataclass
class SendTestSetAsync:
fileName: str
contentFile: str
def __init__(self, user, password): def get_wsdl(self):
self._username = user return 'https://colombia-dian-webservices-input-sbx.azurewebsites.net/WcfDianCustomerServices.svc?wsdl'
self._password = password
def get_service(self):
return 'SendTestSetAsync'
def build_response(self, as_dict):
return {}
class DianGateway:
def _open(self, service): def _open(self, service):
return zeep.Client(service.get_wsdl(), wsse=UsernameToken(self._username, self._password)) raise NotImplementedError()
def _remote_service(self, conn, service): def _remote_service(self, conn, service):
return conn.service[service.get_service()] return conn.service[service.get_service()]
@ -118,4 +129,25 @@ class DianClient:
return service.build_response(resp) return service.build_response(resp)
class DianClient(DianGateway):
def __init__(self, user, password):
self._username = user
self._password = password
def _open(self, service):
return zeep.Client(service.get_wsdl(), wsse=UsernameToken(self._username, self._password))
class DianSignatureClient(DianGateway):
def __init__(self, private_key_path, public_key_path, password=None):
self.private_key_path = private_key_path
self.public_key_path = public_key_path
self.password = password
def _open(self, service):
return zeep.Client(service.get_wsdl(), wsse=Signature(
self.private_key_path, self.public_key_path, self.password))