Django Correos Chile Integration
Project description
Linets Correos Chile
Starting 🚀
These instructions will allow you to install the library in your django project.
Current features 📋
- Generate order in Correos Chile.
- Generate default data for create order in Correos Chile.
Pre-requisitos 📋
- Python >= 3.7
- Django >= 3
- zeep >= 4
Installation 🔧
- To get the latest stable release from PyPi:
pip install django-correos-chile
or
- From a build
git clone https://gitlab.com/linets/ecommerce/oms/integrations/oms-correos-chile
cd {{project}} && git checkout develop
python setup.py sdist
and, install in your project django
pip install {{path}}/oms-correos-chile/dist/{{tar.gz file}}
- Settings in django project
DJANGO_CORREOS_CHILE = {
'CORREOS_CHILE': {
'EXECUTE_WSDL': '<CORREOS_CHILE_EXECUTE_WSDL>',
'USER': '<CORREOS_CHILE_USER>',
'PASSWORD': '<CORREOS_CHILE_PASSWORD>',
'COD_SERVICIO': '<CORREOS_CHILE_COD_SERVICIO>',
'COD_REF': '<CORREOS_CHILE_COD_REF>',
'TYPE_POR': '<CORREOS_CHILE_TYPE_POR>',
'DEV_CON': '<CORREOS_CHILE_DEV_CON>',
'PAG_SEG': '<CORREOS_CHILE_PAG_SEG>',
},
'SENDER': {
'ADMISSION': '<CORREOS_CHILE_ADMISSION>',
'CLIENT': '<CORREOS_CHILE_CLIENT>',
'CENTRO': '<CORREOS_CHILE_CENTRO>',
'NAME': '<CORREOS_CHILE_NAME>',
'ADDRESS': '<CORREOS_CHILE_ADDRESS>',
'COUNTRY': '<CORREOS_CHILE_COUNTRY>',
'POSTALCODE': '<CORREOS_CHILE_POSTALCODE>',
'CITY': '<CORREOS_CHILE_CITY>',
'RUT': '<CORREOS_CHILE_RUT>',
'CONTACT_NAME': '<CORREOS_CHILE_CONTACT_NAME>',
'CONTACT_PHONE': '<CORREOS_CHILE_CONTACT_PHONE>',
},
}
Usage 🔧
-
Create instance to be sent
import json from types import SimpleNamespace dict_ = { 'reference': '99999', 'created_at': '12/12/21', 'shipping_date': '12/12/21', 'expiration_date': '26/12/21' 'tracking_code': '6075620-1', 'transport_guide_number': '1121632479536-01-1', 'purchase_number': 'CLV0048146676851-1', 'customer': { 'first_name': 'Marcos', 'last_name': 'Sac', 'full_name': 'Marcos Sac', 'phone': '932932932', 'email': 'test@gmail.com', 'rut': '16936195-9' }, 'address': { 'street': 'ALEJANDRO VENEGAS CADIZ', 'number': '513', 'unit': 'DEPTO 6A', 'full_address': 'ALEJANDRO VENEGAS CADIZ 513 DEPTO 6A' }, 'commune': { 'name': 'Aisen', 'code': '', 'zone_code': '11201', 'zone_post': 'WPA', }, 'location': { 'code': 'MONTANDON', 'name': 'MNN', }, 'region': { 'name': 'Aysén del General Carlos Ibáñez del Campo', 'code': '11', 'iso_code': 'CL-XI', } } instance = json.loads(json.dumps(dict_), object_hook=lambda attr: SimpleNamespace(**attr))
-
Generate default data for create a order in Correos Chile:
from correos_chile.handler import CorreosHandler
handler = CorreosHandler()
default_data = handler.get_default_payload(instance)
Output:
{
'recipient_name': 'Ascensión Paniagua',
'recipient_address': 'Jessica Villaverde 8752',
'recipient_postal_code': 'PROV',
'recipient_commune': 'Providencia',
'recipient_rut': '41.460.173-4',
'recipient_contact': 'Ascensión Paniagua',
'recipient_phone': '9999999999'
}
- Create a order in Correos Chile:
from correos_chile.handler import CorreosHandler
handler = CorreosHandler()
response = handler.create_shipping(default_data)
Output:
{
'ExtensionData': None,
'CodigoSucursal': None,
'NombreSucursal': None,
'Cuartel': None,
'Sector': None,
'SDP': None,
'Movil': None,
'AbreviaturaCentro': '61001',
'CodigoDelegacionDestino': '864',
'NombreDelegacionDestino': 'PLANTA CEP RM',
'DireccionDestino': 'JESSICA VILLAVERDE 8752',
'CodigoEncaminamiento': '02475000007',
'GrabarEnvio': 'S',
'NumeroEnvio': '990077321938',
'ComunaDestino': 'PROVIDENCIA',
'AbreviaturaServicio': 'PED',
'IdTransaccional': None,
'CodigoAdmision': 'PRB20201103'
}
- Get events:
from correos_chile.handler import CorreosHandler
handler = CorreosHandler()
raw_data = {
'expedicion': '990077324935',
'referencia': 'CLV-10000001',
'estado_2': 'ENVIO ENTREGADO',
'fechaEvento': '12/12/2021',
'fechaCarga': '12/12/2021',
'estadoBase': 'Envio en reparto',
'ciudad': 'Santiago'
}
response = handler.get_events(raw_data)
Output:
[{
'city': string
'state': string
'description': string
'date': string
}, ...]
- Get status and if "is_delivered":
from correos_chile.handler import CorreosHandler
handler = CorreosHandler()
raw_data = {
'expedicion': '990077324935',
'referencia': 'CLV-10000001',
'estado_2': 'ENVIO ENTREGADO',
'fechaEvento': '12/12/2021',
'fechaCarga': '12/12/2021',
'estadoBase': 'Envio en reparto',
'ciudad': 'Santiago'
}
response = handler.get_status(raw_data)
Output:
('Entregado', True)
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
Close
Hashes for django-correos-chile-1.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b9e62afd5c00d2809410d0ea4c77223d33979578e340746d0b9f1471a21a7eb |
|
MD5 | a78c9570266ad52263f4775bfd935aeb |
|
BLAKE2b-256 | 75217e88eaf28700e28ed4ce9eae9cf21ead60b1112a91a15f5f7f4f4857bbaf |