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.
![big picture](overview.svg)
* 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, TRS... more to come.
### Usage
```python
from roulier import roulier
laposte = roulier.get('laposte')
response = laposte.get_label({
"auth": {
"login": "12345",
"password": "password",
},
"service": {
"productCode": "COL"
},
"parcel": {
"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:
```python
from roulier import roulier
print roulier.get_carriers()
```
To get the full list of parameters:
```python
from pprint import pprint
from roulier import roulier
laposte = roulier.get('laposte')
pprint(laposte.api())
# ...
```
### Return
```python
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',
# },
# tracking: {
# 'number': 'tracking code here',
# },
# 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
```python
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](http://docs.python-cerberus.org/en/stable/)
```python
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
* [@hparfr](https://github.com/hparfr) ([Akretion.com](https://akretion.com))
* [@damdam-s](https://github.com/damdam-s) ([Camp2Camp.com](http://camptocamp.com))
* [@bealdav](https://github.com/bealdav) ([Akretion.com](https://akretion.com))
### Dependencies
* [Cerberus](http://docs.python-cerberus.org/) - input validation and normalization
* [lxml](http://lxml.de/) - XML parsing
* [Jinja2](http://jinja.pocoo.org/) - templating
* [Requests](http://docs.python-requests.org/) - HTTP requests
* [zplgrf](https://github.com/kylemacfarlane/zplgrf) - PNG to ZPL conversion
* [unidecode](https://pypi-hypernode.com/pypi/Unidecode) - Remove accents from ZPL
* [unicodecsv](https://github.com/jdunck/python-unicodecsv) - CSV generation
===
Roulier is a shipping library written in Python for sending parcels.
Roulier will get a label + tracking number to your carrier for you.
![big picture](overview.svg)
* 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, TRS... more to come.
### Usage
```python
from roulier import roulier
laposte = roulier.get('laposte')
response = laposte.get_label({
"auth": {
"login": "12345",
"password": "password",
},
"service": {
"productCode": "COL"
},
"parcel": {
"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:
```python
from roulier import roulier
print roulier.get_carriers()
```
To get the full list of parameters:
```python
from pprint import pprint
from roulier import roulier
laposte = roulier.get('laposte')
pprint(laposte.api())
# ...
```
### Return
```python
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',
# },
# tracking: {
# 'number': 'tracking code here',
# },
# 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
```python
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](http://docs.python-cerberus.org/en/stable/)
```python
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
* [@hparfr](https://github.com/hparfr) ([Akretion.com](https://akretion.com))
* [@damdam-s](https://github.com/damdam-s) ([Camp2Camp.com](http://camptocamp.com))
* [@bealdav](https://github.com/bealdav) ([Akretion.com](https://akretion.com))
### Dependencies
* [Cerberus](http://docs.python-cerberus.org/) - input validation and normalization
* [lxml](http://lxml.de/) - XML parsing
* [Jinja2](http://jinja.pocoo.org/) - templating
* [Requests](http://docs.python-requests.org/) - HTTP requests
* [zplgrf](https://github.com/kylemacfarlane/zplgrf) - PNG to ZPL conversion
* [unidecode](https://pypi-hypernode.com/pypi/Unidecode) - Remove accents from ZPL
* [unicodecsv](https://github.com/jdunck/python-unicodecsv) - CSV generation
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.1.1.tar.gz
(21.2 kB
view details)
Built Distribution
roulier-0.1.1-py2-none-any.whl
(40.5 kB
view details)
File details
Details for the file roulier-0.1.1.tar.gz
.
File metadata
- Download URL: roulier-0.1.1.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 772a4515d509b63d91cc120fbd888f5843a3e84b16a3a4fe5b69406de2590a50 |
|
MD5 | 95d5c5b2dcecdb0e1fb046640597d5eb |
|
BLAKE2b-256 | 1df31af3eff61a59efb5bea5eb5cc716459c46c540a28bfcc69c222096c343d1 |
File details
Details for the file roulier-0.1.1-py2-none-any.whl
.
File metadata
- Download URL: roulier-0.1.1-py2-none-any.whl
- Upload date:
- Size: 40.5 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01ffaa9da69a1c4f2b912d6bb14f643a32849edae50e8f1e80d28b191239bcd4 |
|
MD5 | 161a3b1a2cadb091b95f3ee8d1fc8267 |
|
BLAKE2b-256 | 59da90a4dc7424c30079004f3b94bd67afe4cf9839ef619f53e432422f608900 |