# Path: roulier/exception.py
# class InvalidApiInput(Exception):
#     """Bad input.
# 
#     Use this class in your application to manage
#     exception with api call
#     """


import logging
from abc import ABC, abstractmethod
from .exception import InvalidApiInput
"""Transform to/from a carrier specific format."""


_logger = logging.getLogger(__name__)


class Encoder(ABC):
    def __init__(self, config_object):
        self.config = config_object

    def _extra_input_data_processing(self, input_payload, data):
        return data

    @abstractmethod
    def transform_input_to_carrier_webservice(self, data):
        pass

    def encode(self, input_payload):
        """Transform input from external app to compatible input for carrier webservice."""
        validator = self.config.api(self.config)
        if not validator.validate(input_payload):
            _logger.warning("Laposte api call exception:")

# Path: roulier/exception.py
# class InvalidApiInput(Exception):
#     """Bad input.
# 
#     Use this class in your application to manage
#     exception with api call
#     """


# Path: roulier/codec.py
import logging
from abc import ABC, abstractmethod
from .exception import InvalidApiInput

"""Transform to/from a carrier specific format."""


_logger = logging.getLogger(__name__)


class Encoder(ABC):
    def __init__(self, config_object):
        self.config = config_object

    def _extra_input_data_processing(self, input_payload, data):
        return data

    @abstractmethod
    def transform_input_to_carrier_webservice(self, data):
        pass

    def encode(self, input_payload):
        """Transform input from external app to compatible input for carrier webservice."""
        validator = self.config.api(self.config)
        if not validator.validate(input_payload):
            _logger.warning("Laposte api call exception:")

            raise InvalidApiInput(