# Path: roulier/api.py
# class MyValidator(Validator):
# class BaseApi(object):
# class ApiParcel(BaseApi):
# class ApiPackingSlip(BaseApi):
#     def _normalize_coerce_zpl(self, value):
#     def _normalize_coerce_accents(self, value):
#     def __init__(self, config_object):
#     def _validator(self):
#     def _auth(self):
#     def api_schema(self):
#         def wrap_schema(schema):
#     def api_values(self):
#     def errors(self, data):
#     def validate(self, data):
#     def normalize(self, data):
#     def _address(self):
#     def _from_address(self):
#     def _to_address(self):
#     def _parcel(self):
#     def _parcels(self):
#     def _service(self):
#     def _schemas(self):
#     def _packing_slip_number(self):
#     def _parcels_numbers(self):
#     def _schemas(self):


from roulier.api import Api

class GeodisMappingIn(Api):
    """Internal API"""

    def flatten(self, data, out):
        for (key, val) in data.items():
            if isinstance(val, dict):
                self.flatten(val, out)
            else:
                out[key] = val

    def normalize(self, data):
        without_auth = {key: val for (key, val) in data.items() if key != "auth"}
        flat = {"auth": data["auth"], "service": {}}
        self.flatten(without_auth, flat["service"])
        normalized = super(GeodisMappingIn, self).normalize(flat)
        return normalized


class GeodisApiTrackingListMapping(GeodisMappingIn):
    """Internal API

    Used to rename fields."""

    def _schemas(self):
        return {
            "service": {
                "shippingDate": {"rename": "dateDepart"},
                "shippingDateStart": {"rename": "dateDepartDebut"},
                "shippingDateEnd": {"rename": "dateDepartFin"},

# Path: roulier/api.py
# class MyValidator(Validator):
# class BaseApi(object):
# class ApiParcel(BaseApi):
# class ApiPackingSlip(BaseApi):
#     def _normalize_coerce_zpl(self, value):
#     def _normalize_coerce_accents(self, value):
#     def __init__(self, config_object):
#     def _validator(self):
#     def _auth(self):
#     def api_schema(self):
#         def wrap_schema(schema):
#     def api_values(self):
#     def errors(self, data):
#     def validate(self, data):
#     def normalize(self, data):
#     def _address(self):
#     def _from_address(self):
#     def _to_address(self):
#     def _parcel(self):
#     def _parcels(self):
#     def _service(self):
#     def _schemas(self):
#     def _packing_slip_number(self):
#     def _parcels_numbers(self):
#     def _schemas(self):


# Path: roulier/carriers/geodis/geodis_api_rest_ws.py
from roulier.api import Api


class GeodisMappingIn(Api):
    """Internal API"""

    def flatten(self, data, out):
        for (key, val) in data.items():
            if isinstance(val, dict):
                self.flatten(val, out)
            else:
                out[key] = val

    def normalize(self, data):
        without_auth = {key: val for (key, val) in data.items() if key != "auth"}
        flat = {"auth": data["auth"], "service": {}}
        self.flatten(without_auth, flat["service"])
        normalized = super(GeodisMappingIn, self).normalize(flat)
        return normalized


class GeodisApiTrackingListMapping(GeodisMappingIn):
    """Internal API

    Used to rename fields."""

    def _schemas(self):
        return {
            "service": {
                "shippingDate": {"rename": "dateDepart"},
                "shippingDateStart": {"rename": "dateDepartDebut"},
                "shippingDateEnd": {"rename": "dateDepartFin"},

                "agencyId": {"rename": "codeSa"},