¡Conecta a los Microservicios de CodeFlex desde una Sola Librería!
Project description
CODEFLEX CLOUD S.A.S | DIAN
Codificación y Almacenamiento Simplificados | IDE
Explore the docs »
About The Project
Installation
pip install codeflexDian
Usage
- Example 1 | Lambda Function | GetNumberingRange
import lxml.etree as ET from codeflexDian.SOAPSing import SOAPSing from codeflexDian.Signing import Signing import boto3 import os from string import Template def lambda_handler(event, context): ProviderSub = event['ProviderSub'] accountCode = event['accountCode'] accountCodeT = event['accountCodeT'] softwareCode = event['softwareCode'] s3subir = boto3.client('s3') s3 = boto3.resource('s3') pathCert = "/tmp/" + ProviderSub + "/certificado.pfx" pathClave = "/tmp/" + ProviderSub + "/clave.txt" metodo = "GetNumberingRange" # CREA DIRECTORIO DE TRABAJO SI NO EXISTE directory = "/tmp/" + ProviderSub if not os.path.exists(directory): os.makedirs(directory) # Descarga el certificado s3.Bucket(ProviderSub).download_file("certificado.pfx", pathCert) # Descarga la clave s3.Bucket(ProviderSub).download_file("clave.txt", pathClave) # Lee la clave with open(pathClave) as f: passwordCert = f.readline().strip() # Si la clave es NA entonces la clave será un blanco if (passwordCert == "NA"): passwordCert = "" signing = Signing(pathCert, passwordCert) signer = SOAPSing(signing, metodo) template = Template('''<wcf:GetNumberingRange xmlns:wcf="http://wcf.dian.colombia"><wcf:accountCode>${accountCode}</wcf:accountCode><wcf:accountCodeT>${accountCodeT}</wcf:accountCodeT><wcf:softwareCode>${softwareCode}</wcf:softwareCode></wcf:GetNumberingRange>''') value = { 'accountCode': accountCode, 'accountCodeT': accountCodeT, 'softwareCode': softwareCode } templateOk = template.substitute(value) element = ET.fromstring(templateOk.encode('utf-8')) soapSigned = signer.sing(element) soapSignedString = ET.tostring(soapSigned, pretty_print=True) # Escribe Request firmado en /tmp signed_file_path = '/tmp/' + ProviderSub + '/' + 'RANGOS-SIGN.xml' with open(signed_file_path, 'wb') as f: f.write(soapSignedString) # Sube Request firmado de /tmp a s3 s3subir.upload_file(signed_file_path, ProviderSub, 'RANGOS-SIGN.xml') # Retorno de información de destino return { 'ProviderSub': event['ProviderSub'], 'ProviderEmail': event['ProviderEmail'] }
For more examples, please refer to the Documentation
License
Distributed under the MIT License. See LICENSE
for more information.
Contact
Telefono: +57 3008130562 | Email: info@codeflex.com.co
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
codeflexdian-1.0.0.tar.gz
(10.2 kB
view details)
Built Distribution
File details
Details for the file codeflexdian-1.0.0.tar.gz
.
File metadata
- Download URL: codeflexdian-1.0.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73e9cacc88cf3ea40694c3e88b75534001006aa97bd7cc80c5c7bae295d1d214 |
|
MD5 | 9af37876f699186731c0c630ecd56c1b |
|
BLAKE2b-256 | 4c1f49197aa6edb0ebe960e0c41aed4b93d6cd7195b4af92d98dedcfc982f3ab |
File details
Details for the file codeflexDian-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: codeflexDian-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f602f01bcccc5bfb5df09b276076225afa0b94c7f663aea1816c5b487dc0f7ae |
|
MD5 | 8a439178fabc79689de12214ef438858 |
|
BLAKE2b-256 | 07ce5853258e2e393d94bd68cb09cf40af13ffa61a5ce4b7aeecfe4e1c4814ae |