Skip to main content

Django Urbano Integration

Project description

django-urbano

Starting

These instructions will allow you to install the library in your python project.

Current features

  • Get tracking info.

Pre-requisitos

  • Python >= 3.7
  • Django >= 3
  • requests >= 2

Installation

  1. To get the latest stable release from PyPi:
pip install django-urbano

or

  1. From a build
git clone https://gitlab.com/linets/ecommerce/oms/integrations/django-urbano
cd {{project}}
python setup.py sdist

and, install in your project django

pip install {{path}}/django-urbano/dist/{{tar.gz file}}
  1. Settings in django project
DJANGO_URBANO = {
    'URBANO': {
        'BASE_URL': '<URBANO_BASE_URL>',
        'USER': '<URBANO_USER>',
        'PASSWORD': '<URBANO_PASSWORD>',
        'ID_CONTRATO': '<URBANO_ID_CONTRATO>',
    }
}

Usage

  1. 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))
    
  2. Get tracking info:

from urbano.handler import UrbanoHandler

handler = UrbanoHandler()

tracking_info = handler.get_tracking(<identifier>)
  1. Get default payload:
from urbano.handler import UrbanoHandler

handler = UrbanoHandler()
default_data = handler.get_default_payload(<instance>)
  1. Create shipping:
from urbano.handler import UrbanoHandler

handler = UrbanoHandler()
default_data = handler.create_shipping(<default_data>)
  1. Get events:
from urbano.handler import UrbanoHandler

handler = UrbanoHandler()

raw_data = {
    'tracking_number': 999999,
    'status': 'ENTREGADO',
    'events': [{
        'city': 'Santiago'
        'state': 'RM',
        'description': 'Llego al almacén',
        'date': '12/12/2021'
    }]
}
response = handler.get_events(raw_data)

Output:
[{
    'city': 'Santiago'
    'state': 'RM',
    'description': 'Llego al almacén',
    'date': '12/12/2021'
}]
  1. Get status and if "is_delivered":
from urbano.handler import UrbanoHandler

handler = UrbanoHandler()

raw_data = {
    'tracking_number': 999999,
    'status': 'ENTREGADO',
    'events': [{
        'city': 'Santiago'
        'state': 'RM',
        'description': 'Llego al almacén',
        'date': '12/12/2021'
    }]
}
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

django-urbano-1.4.3.tar.gz (9.6 kB view details)

Uploaded Source

File details

Details for the file django-urbano-1.4.3.tar.gz.

File metadata

  • Download URL: django-urbano-1.4.3.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.0

File hashes

Hashes for django-urbano-1.4.3.tar.gz
Algorithm Hash digest
SHA256 2fe907c2a1e196e71b226cac5d362c5dddb6c722c8892744b008e99813e1d284
MD5 239e7aa83ccb4bd7a241d3775c263f16
BLAKE2b-256 f8b4cfb7f8330a8bc1ab458b5a98d294ba04e02944f8a2512169642a338e5a03

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page