Skip to main content

Django Pickit Integration

Project description

django-pickit

Starting

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

Current features

  • Get default payload.
  • Create shipping.

Pre-requisitos

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

Installation

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

or

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

and, install in your project django

pip install {{path}}/django-pickit/dist/{{tar.gz file}}
  1. Settings in django project
DJANGO_PICKIT = {
    'PICKIT': {
        'BASE_URL': '<PICKIT_BASE_URL>',
        'RUT_USER': '<PICKIT_RUT_USER>',
        'PASS_USER': '<PICKIT_PASS_USER>',
        'DELIVERY_TYPE': '<PICKIT_DELIVERY_TYPE>',
    },
    'SENDER': {
        'RUT_COMPANY': '<PICKIT_RUT_COMPANY>',
        'CTA_CTE_NUMBER': '<PICKIT_CTA_CTE_NUMBER>',
        'DV_CTA_CTE_NUMBER': '<PICKIT_DV_CTA_CTE_NUMBER>',
        'CENTER_COST_CTA_CTE': '<PICKIT_CENTER_COST_CTA_CTE>',
        'DOCUMENT_TYPE': '<PICKIT_DOCUMENT_TYPE>',
        'GENERATE_LABEL_DOCUMENT_1': '<PICKIT_GENERATE_LABEL_DOCUMENT_1>',
        'TYPE_ORDER_1': '<PICKIT_TYPE_ORDER_1>',
        'ORIGEN_CITY': <PICKIT_ORIGEN_CITY>,
    }
}

Usage

  1. Create instance to be sent

    import json
    from types import SimpleNamespace
    
    dict_ = {
        'reference': '99999',
        'delivery_date': '2018-12-06 13:00:00',
        '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',
        'agency_id': '123',
        'items': [
            {
                'code': 'SKU1234',
                'name': 'POLOS',
                'price': '2500',
                'quantity': '2'
            },
            {
                'code': 'SKU12345',
                'name': 'SHORT',
                'price': '1500',
                'quantity': '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 default payload:

from pickit.handler import PickitHandler

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

handler = PickitHandler()
default_data = handler.create_shipping(<default_data>)
  1. Get events:
from pickit.handler import PickitHandler

handler = PickitHandler()

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 pickit.handler import PickitHandler

handler = PickitHandler()

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

corona_pickit-0.0.10.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

corona_pickit-0.0.10-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file corona_pickit-0.0.10.tar.gz.

File metadata

  • Download URL: corona_pickit-0.0.10.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for corona_pickit-0.0.10.tar.gz
Algorithm Hash digest
SHA256 3690705bc330f077dac713fec91a3ba4e52d90a1ed4007a2f2be116c595dbc9b
MD5 3c7b448aabe90d8e5becd4e58a0ec096
BLAKE2b-256 97186a9a9f3a46d65c3eea4cb6cdf7c7501512785780a3845f2d913523b70b4d

See more details on using hashes here.

File details

Details for the file corona_pickit-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: corona_pickit-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for corona_pickit-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 7985c76a5868a83dcc307ea7f2ad6557ef001b4afac68b45d1cc1ef9cc741b70
MD5 17fcd49c8d5d35b95cc61bd7526fc029
BLAKE2b-256 a896004b0ece91e517fab57049ac1e2ca24041cec39dd7ac3ae6f38553484836

See more details on using hashes here.

Supported by

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