# Path: fnapy/exceptions.py
# class FnapyConnectionError(FnapyException):
#     """Raised when the connection is incorrect"""
# 
# Path: fnapy/utils.py
# def get_credentials(sandbox=True):
#     """Return the credentials for the sandbox or the real account
# 
#     Usage::
#         credentials = get_credentials(sandbox=sandbox)
# 
#     :type sandbox: bool
#     :param sandbox: determines whether you get the credentials for the sandbox
#     account (True) or the real account (False).
# 
#     :rtype: dict
#     :returns: the credentials for the selected account type
# 
#     """
#     credentials = {
#         "sandbox": {
#             "partner_id": os.getenv("FNAC_SANDBOX_PARTNER_ID"),
#             "shop_id": os.getenv("FNAC_SANDBOX_SHOP_ID"),
#             "key": os.getenv("FNAC_SANDBOX_KEY"),
#         },
#         "real": {
#             "partner_id": os.getenv("FNAC_PARTNER_ID"),
#             "shop_id": os.getenv("FNAC_SHOP_ID"),
#             "key": os.getenv("FNAC_KEY"),
#         },
#     }
#     use_sandbox = {True: "sandbox", False: "real"}
#     account_type = use_sandbox[sandbox]
#     return credentials[account_type]


from fnapy.exceptions import FnapyConnectionError
from fnapy.utils import get_credentials
        connection = FnapyConnection(sandbox=True)

    .. note:: You must have previously defined the following environment
        variables:

    * for the sandbox: FNAC_SANDBOX_PARTNER_ID, FNAC_SANDBOX_SHOP_ID,
        FNAC_SANDBOX_KEY

    * for the real account: FNAC_PARTNER_ID, FNAC_SHOP_ID, FNAC_KEY

    """

    def __init__(self, credentials={}, sandbox=None):
        # credentials
        if len(credentials) > 0:
            expecteds = ("partner_id", "shop_id", "key", "sandbox")
            for expected in expecteds:
                if credentials.get(expected) is None:
                    msg = "You didn't provide the {}."
                    msg += "You must provide the following keys in credentials: "
                    msg += ", ".join(expecteds)
                    raise FnapyConnectionError(msg.format(expected))

        # sandbox
        else:
            if sandbox is not None:
                credentials = get_credentials(sandbox)
                credentials.update({"sandbox": sandbox})
            else:
                msg = "You must either specify credentials or sandbox as arguments."

# Path: fnapy/exceptions.py
# class FnapyConnectionError(FnapyException):
#     """Raised when the connection is incorrect"""
# 
# Path: fnapy/utils.py
# def get_credentials(sandbox=True):
#     """Return the credentials for the sandbox or the real account
# 
#     Usage::
#         credentials = get_credentials(sandbox=sandbox)
# 
#     :type sandbox: bool
#     :param sandbox: determines whether you get the credentials for the sandbox
#     account (True) or the real account (False).
# 
#     :rtype: dict
#     :returns: the credentials for the selected account type
# 
#     """
#     credentials = {
#         "sandbox": {
#             "partner_id": os.getenv("FNAC_SANDBOX_PARTNER_ID"),
#             "shop_id": os.getenv("FNAC_SANDBOX_SHOP_ID"),
#             "key": os.getenv("FNAC_SANDBOX_KEY"),
#         },
#         "real": {
#             "partner_id": os.getenv("FNAC_PARTNER_ID"),
#             "shop_id": os.getenv("FNAC_SHOP_ID"),
#             "key": os.getenv("FNAC_KEY"),
#         },
#     }
#     use_sandbox = {True: "sandbox", False: "real"}
#     account_type = use_sandbox[sandbox]
#     return credentials[account_type]


# Path: fnapy/connection.py
from fnapy.exceptions import FnapyConnectionError
from fnapy.utils import get_credentials

        connection = FnapyConnection(sandbox=True)

    .. note:: You must have previously defined the following environment
        variables:

    * for the sandbox: FNAC_SANDBOX_PARTNER_ID, FNAC_SANDBOX_SHOP_ID,
        FNAC_SANDBOX_KEY

    * for the real account: FNAC_PARTNER_ID, FNAC_SHOP_ID, FNAC_KEY

    """

    def __init__(self, credentials={}, sandbox=None):
        # credentials
        if len(credentials) > 0:
            expecteds = ("partner_id", "shop_id", "key", "sandbox")
            for expected in expecteds:
                if credentials.get(expected) is None:
                    msg = "You didn't provide the {}."
                    msg += "You must provide the following keys in credentials: "
                    msg += ", ".join(expecteds)
                    raise FnapyConnectionError(msg.format(expected))

        # sandbox
        else:
            if sandbox is not None:
                credentials = get_credentials(sandbox)
                credentials.update({"sandbox": sandbox})
            else:
                msg = "You must either specify credentials or sandbox as arguments."

                raise FnapyConnectionError(msg)