-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from webu/gls_eu
GLS FR via REST Web Service
- Loading branch information
Showing
30 changed files
with
932 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +0,0 @@ | ||
__version__ = "0.1.0" | ||
|
||
from . import api | ||
from . import decoder | ||
from . import encoder | ||
from . import transport | ||
from . import carrier_action | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
__version__ = "0.1.0" | ||
|
||
from . import api | ||
from . import carrier_action | ||
from . import decoder | ||
from . import encoder | ||
from . import transport |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
roulier/carriers/gls_fr/gls.py → roulier/carriers/gls_fr/glsbox/gls.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_roulier_gls_fr |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
__version__ = "0.1.0" | ||
|
||
from . import api | ||
from . import carrier_action | ||
from . import decoder | ||
from . import encoder | ||
from . import transport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Implementation of Laposte Api.""" | ||
|
||
from roulier.api import ApiParcel | ||
|
||
from .constants import SERVICE_CHOICES | ||
from .constants import SERVICE_STANDARD | ||
|
||
|
||
class GlsEuApiParcel(ApiParcel): | ||
def _service(self): | ||
schema = super()._service() | ||
schema["language"] = {"default": "en"} | ||
schema["product"].update( | ||
{ | ||
"type": "string", | ||
"default": SERVICE_STANDARD, | ||
"allowed": tuple(SERVICE_CHOICES), | ||
} | ||
) | ||
schema["pickupLocationId"] = {"type": "string"} | ||
schema["labelSize"] = { | ||
"type": "string", | ||
"default": "A6", | ||
"allowed": ["A6", "A5", "A4"], | ||
} | ||
schema["labelFormat"].update( | ||
{"type": "string", "default": "PDF", "allowed": ["PDF", "PNG"],} | ||
) | ||
return schema | ||
|
||
def _address(self): | ||
string_1_10 = {"type": "string", "minlength": 1, "maxlength": 10} | ||
string_2_35 = {"type": "string", "minlength": 2, "maxlength": 35} | ||
string_0_35 = {"type": "string", "minlength": 0, "maxlength": 35} | ||
schema = super()._address() | ||
schema["name"].update(string_2_35) | ||
schema["street1"].update({"minlength": 3, "maxlength": 35}) | ||
schema["country"].update({"minlength": 2, "maxlength": 2}) | ||
schema["zip"].update(string_1_10) | ||
schema["phone"].update({"maxlength": 20}) | ||
schema["email"].update( | ||
{"required": True, "minlength": 3, "maxlength": 100,} | ||
) | ||
schema["city"].update(string_2_35) | ||
schema.update( | ||
{ | ||
"id": {"type": "string", "minlength": 0, "maxlength": 20}, | ||
"street2": string_0_35, | ||
"street3": string_0_35, | ||
"blockNo1": string_1_10, | ||
"province": string_2_35, | ||
"contact": string_2_35, | ||
"mobile": schema["phone"], | ||
"incoterm": { | ||
"type": "string", | ||
# "regex": r"^\d{2}$", | ||
# "allowed": ["10", "13", 18", "20", "23", "30", "40", "43", "50", "60"], | ||
}, | ||
} | ||
) | ||
return schema | ||
|
||
def _opt_schema(self, schema): | ||
return { | ||
"type": "dict", | ||
"required": False, | ||
"schema": schema, | ||
} | ||
|
||
def _parcel(self): | ||
schema = super()._parcel() | ||
schema.update( | ||
{ | ||
"services": { | ||
"type": "list", | ||
"schema": { | ||
"schema": { | ||
"product": { | ||
"type": "string", | ||
"allowed": tuple(SERVICE_CHOICES), | ||
}, | ||
"pickupLocationId": {"type": "string"}, | ||
}, | ||
"type": "dict", | ||
}, | ||
}, | ||
"reference2": {"type": "string"}, | ||
"comment": {"type": "string", "maxlength": 35}, | ||
} | ||
) | ||
return schema | ||
|
||
def _returns(self): | ||
return { | ||
"type": "list", | ||
"schema": { | ||
"type": "dict", | ||
"schema": { | ||
"weight": { | ||
"type": "float", | ||
"default": "", | ||
"required": True, | ||
"empty": False, | ||
} | ||
}, | ||
}, | ||
"empty": False, | ||
"required": False, | ||
} | ||
|
||
def _auth(self): | ||
schema = super()._auth() | ||
schema["login"].update({"required": True, "empty": False}) | ||
schema["password"].update({"required": True, "empty": False}) | ||
return schema | ||
|
||
def _schemas(self): | ||
schema = super()._schemas() | ||
schema["returns"] = self._returns() | ||
schema["to_address"] = self._opt_schema(self._to_address()) | ||
schema["from_address"] = self._opt_schema(self._address()) | ||
schema["return_address"] = self._opt_schema(self._address()) | ||
schema["pickup_address"] = self._opt_schema(self._address()) | ||
return schema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""Implementation for Laposte.""" | ||
|
||
from roulier.carrier_action import CarrierGetLabel | ||
from roulier.roulier import factory | ||
|
||
from .api import GlsEuApiParcel | ||
from .encoder import GlsEuEncoder | ||
from .decoder import GlsEuDecoderGetLabel | ||
from .transport import GlsEuTransport | ||
|
||
|
||
class GlsEuGetabel(CarrierGetLabel): | ||
"""Implementation for GLS via it's REST WebService.""" | ||
|
||
ws_url = "https://api.gls-group.eu/public/v1/shipments" | ||
ws_test_url = "https://api-qs.gls-group.eu/public/v1/shipments" | ||
encoder = GlsEuEncoder | ||
decoder = GlsEuDecoderGetLabel | ||
transport = GlsEuTransport | ||
api = GlsEuApiParcel | ||
manage_multi_label = True | ||
|
||
|
||
factory.register_builder("gls_fr_rest", "get_label", GlsEuGetabel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
SERVICE_STANDARD = "Standard" | ||
""" | ||
Concerne les livraisons pour la France et l’international sans aucun service additionnel, | ||
notre système utilisera le produit adapté en fonction de la destination : | ||
BP (Business Parcel), EBP (Euro Business Parcel) ou GBP (Global Business Parcel) | ||
""" | ||
|
||
SERVICE_FDS = "flexDeliveryService" | ||
""" | ||
Pour les livraisons aux particuliers, GLS communique par mail et SMS avec le | ||
destinataire afin d’offrir une interaction avec les modalités de livraison | ||
""" | ||
|
||
SERVICE_SHD = "shopdeliveryservice" | ||
""" | ||
livraison du colis dans un point relais | ||
""" | ||
|
||
SERVICE_SRS = "shopreturnservice" | ||
""" | ||
Dépôt du colis par le destinataire dans un point relais colis pour une livraison | ||
en retour à l’adresse du donneur d’ordre, identifié par le shipperId utilisé | ||
""" | ||
|
||
SERVICE_PandS = "Pick&ShipService" | ||
""" | ||
enlèvement du colis par GLS à une adresse indiquée pour une livraison à une | ||
autre adresse que celle du compte GLS donneur de l’ordre. | ||
ATTENTION, l’une des deux adresses doit être localisé en France | ||
""" | ||
|
||
SERVICE_PandR = "Pick&ReturnService" | ||
""" | ||
enlèvement du colis par GLS à une adresse indiquée pour une livraison en | ||
retour à l’adresse du donneur de l’ordre, identifié par le shipperId utilisé. | ||
ATTENTION, l’une des deux adresses doit être localisé en France | ||
""" | ||
|
||
SERVICE_CHOICES = { | ||
SERVICE_STANDARD, | ||
SERVICE_FDS, | ||
SERVICE_SHD, | ||
SERVICE_SRS, | ||
SERVICE_PandS, | ||
SERVICE_PandR, | ||
} | ||
|
||
FR_ONLY_SERVICES_CHOICES = SERVICE_CHOICES - { | ||
SERVICE_STANDARD, | ||
} |
Oops, something went wrong.