Label parcels without pain
Project description
Roulier
Roulier is a shipping library written in Python for sending parcels. Roulier will get a label + tracking number to your carrier for you.
- Roulier runs on your server and call each carrier API directly.
- You have to use your own credentials provided by each carriers.
- Roulier is Open Source software, AGPL-3
- Roulier integrate a multitude of carriers : Laposte, Geodis, DPD, K&N... more to come.
Usage
from roulier import roulier
laposte = roulier.get('laposte')
response = laposte.get_label({
"auth": {
"login": "12345",
"password": "password",
},
"service": {
"productCode": "COL"
},
"parcels": [{
"weight": 3.4,
}],
"to_address": {
"firstName": "Hparfr"
"street1": "35 b Rue Montgolfier"
"city": "Villeurbanne"
"country": "FR",
"zip": "69100"
},
"from_address": {
"fristName": "Akretion France"
"street1": "35 b Rue Montgolfier"
"city": "Villeurbanne"
"country": "FR",
"zip": "69100"
},
})
print(response)
Get supported carriers:
from roulier import roulier
print(roulier.get_carriers())
To get the full list of parameters:
from pprint import pprint
from roulier import roulier
laposte = roulier.get('laposte')
pprint(laposte.api())
# ...
Return
from roulier import roulier
laposte = roulier.get('laposte')
api = laposte.api()
api['auth']['login'] = '12345'
...
print(laposte.get_label(api))
# {
# label: {
# 'name':'label',
# 'type': 'zpl',
# 'data': 'base64 here', #main label
# },
# tracking: {
# 'number': 'tracking code here',
# },
# parcels: [{
# { 'id': 1,
# 'reference: '',
# 'number': 'tracking code here',
# 'label': {
# 'data': '', 'type': 'zpl',
# 'name': 'label 1 '
# }
# }],
# annexes: [
# {
# 'name': 'cn23',
# 'type': 'pdf',
# 'data': 'base64 here'
# }, ...
# ],
#}
Advanced usage for Laposte
Usefull for debugging: get the xml before the call, send an xml directly, analyse the response
from roulier import roulier
laposte = roulier.get('laposte')
#0) create dict for the request as usually
api = laposte.api();
api['auth']['login'] = '12345'
...
# 1) get the sls xml:
req = laposte.encoder.encode(api, 'generateLabelRequest')
# req['body'] contains the xml payload (<sls:generateLabel xmlns:sls="http://sls.ws.coliposte.fr">...</sls:generateLabel>)
# 2) get the soap message
soap_request = laposte.ws.soap_wrap(req['body'], req['headers'])
#soap_request is a string (xml)
# 3) send xml_request to ws
soap_response = laposte.ws.send_request(xml_request)
# soap_response is a Requests response
# 4) interpret the response
data = laposte.ws.handle_response(soap_response)
# 5)get the raw Request Response:
data['response']
It's more or less the same for every carrier with SOAP webservice.
Validate input
For input validate we use Cerberus
from roulier import roulier
laposte = roulier.get('laposte')
# get a ready to fill dict with default values:
laposte.api()
# advanced usage :
from roulier.carriers.laposte.laposte_api import LaposteApi
l_api = LaposteApi()
# get the full schema:
l_api.api_schema()
# validate a dict against the schema
a_dict = { 'auth': {'login': '', 'password': 'password'}, ... }
l_api.errors(a_dict)
# > {'auth': [{'login': ['empty values not allowed']}], ...}
# get a part of schema (like 'parcel')
l_api._parcel()
Contributors
Dependencies
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
roulier-0.3.9.tar.gz
(32.7 kB
view details)
Built Distribution
roulier-0.3.9-py2-none-any.whl
(57.7 kB
view details)
File details
Details for the file roulier-0.3.9.tar.gz
.
File metadata
- Download URL: roulier-0.3.9.tar.gz
- Upload date:
- Size: 32.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15rc1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0125db127f854a87b86a5cfdfcdaeeed5e875be95784c5bf0102dee91bd76676 |
|
MD5 | 003678495904daeea1bd879a54ff3b1a |
|
BLAKE2b-256 | 6c27d7e6569f33ba17da7b366b9a99c94e0861992417ba1a2e47308d3e902498 |
File details
Details for the file roulier-0.3.9-py2-none-any.whl
.
File metadata
- Download URL: roulier-0.3.9-py2-none-any.whl
- Upload date:
- Size: 57.7 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15rc1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00ccd0ed81169080716a0ddde53038eacfa8e6e2b7f44433c00e9e002c188915 |
|
MD5 | fee8f37c241a503c83d4d68097c40714 |
|
BLAKE2b-256 | 6c8e3e879cd4d42db724f182d72308303e80f25af5db3bfe79eaa18637d3a7a2 |