Skip to main content

Django Bluexpress 24 Integration

Project description

Linets Bluexpress

Starting 🚀

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

Current features 📋

  • Generate order in Bluexpress.
  • Generate default data for create order in Bluexpress.

Pre-requisitos 📋

  • Python >= 3.7
  • Django >= 3
  • zeep >= 4

Installation 🔧

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

or

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

and, install in your project django

pip install {{path}}/oms-bluexpress/dist/{{tar.gz file}}
  1. Settings in django project
DJANGO_BLUEXPRESS_24 = {
    'BLUEXPRESS': {
        'ISSUE_WSDL': '<BLUEXPRESS_ISSUE_WSDL>',
        'TOKEN_ID': '<BLUEXPRESS_TOKEN_ID>',
        'USER_COD': '<BLUEXPRESS_USER_COD>',
        'COMPANY_CODE': '<BLUEXPRESS_COMPANY_CODE>',
        'SHIPPING_TYPE': '<BLUEXPRESS_SHIPPING_TYPE>',
        'PAYMENT_TYPE': '<BLUEXPRESS_PAYMENT_TYPE>',
        'PRODUCT_CODE': '<BLUEXPRESS_PRODUCT_CODE>',
        'CURRENCY_CODE': '<BLUEXPRESS_CURRENCY_CODE>',
        'SERVICE_TYPE_CODE': '<BLUEXPRESS_SERVICE_TYPE_CODE>',
        'PRODUCT_FAMILY_CODE': '<BLUEXPRESS_PRODUCT_FAMILY_CODE>',
    },
    'SENDER': {
        'PERSON_CODE': '<BLUEXPRESS_PERSON_CODE>',
        'ACCOUNT_CLIENT': '<BLUEXPRESS_ACCOUNT_CLIENT>',
        'RUT': '<BLUEXPRESS_RUT>',
        'DV': '<BLUEXPRESS_DV>',
        'NAME': '<BLUEXPRESS_NAME>',
        'STREET': '<BLUEXPRESS_STREET>',
        'NUMBER': '<BLUEXPRESS_NUMBER>',
        'FLOOR': '<BLUEXPRESS_FLOOR>',
        'DPTO': '<BLUEXPRESS_DPTO>',
        'PHONE_PREFIX': '<BLUEXPRESS_PHONE_PREFIX>',
        'PHONE_NUMBER': '<BLUEXPRESS_PHONE_NUMBER>',
        'PHONE_ANNEXED': '<BLUEXPRESS_PHONE_ANNEXED>',
        'COUNTRY_CODE': '<BLUEXPRESS_COUNTRY_CODE>',
        'REGION_CODE': '<BLUEXPRESS_REGION_CODE>',
        'COMMUNE_CODE': '<BLUEXPRESS_COMMUNE_CODE>',
        'LOCATION_CODE': '<BLUEXPRESS_LOCATION_CODE>'
    },
    'DESTINATARY': {
        'PHONE_PREFIX': '<BLUEXPRESS_PHONE_PREFIX>',
        'COUNTRY_CODE': '<BLUEXPRESS_COUNTRY_CODE>',
    },
}

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. Generate default data for create a order in Bluexpress:

from bluexpress24.handler import Bluexpress24Handler

handler = Bluexpress24Handler()
default_data = handler.get_default_payload(instance)

Output:

  1. Create a order in Bluexpress:
from bluexpress24.handler import Bluexpress24Handler

handler = Bluexpress24Handler()
response = handler.create_shipping(default_data)

Output:

  1. Get events:
from bluexpress24.handler import Bluexpress24Handler

handler = Bluexpress24Handler()

raw_data = {
    'carrier_tracking_number': int.
    'tracking_data': xml string.
}
response = handler.get_events(raw_data)

Output:
[{
    'city': string
    'state': string
    'description': string
    'date': string
}, ...]
  1. Get status and if "is_delivered":
from bluexpress24.handler import Bluexpress24Handler

handler = Bluexpress24Handler()

raw_data = {
    'carrier_tracking_number': int.
    'tracking_data': xml string.
}
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-bluexpress-24-1.0.1.tar.gz (6.6 kB view details)

Uploaded Source

File details

Details for the file django-bluexpress-24-1.0.1.tar.gz.

File metadata

  • Download URL: django-bluexpress-24-1.0.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.0

File hashes

Hashes for django-bluexpress-24-1.0.1.tar.gz
Algorithm Hash digest
SHA256 726675ee814dac595b171787833a9c37aebca49cf49de4a4121b1a37cc6f5bdc
MD5 d5b67507f4ba8e9c965faac00ed2c022
BLAKE2b-256 a2ad11eeb71bbe746adaf2f30a3c9c48d983a7f0fff2ab625f347eddbf58e341

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