# Path: exactonline/exceptions.py
# class ExactOnlineError(Exception):
#     pass
# 
# Path: exactonline/http.py
# FALLBACK_CACERT_FILE = '/etc/ssl/certs/ca-certificates.crt'
#     _PROPERTIES = ('protocols', 'verify_cert', 'cacert_file', 'headers')
# def binquote(value):
#     def __init__(self, url, code, msg, hdrs, response, reqmethod, reqdata):
#     def clean_and_trim(value):
#     def get_content_type(self):
#     def format_req(self):
#     def format_resp(self):
#     def __str__(self):
#     def __or__(self, other):
#     def __init__(self, method=None, *args, **kwargs):
#     def get_method(self):
#     def __init__(self, *args, **kwargs):
#     def connect(self):
#     def __init__(self, cacert_file):
#     def https_open(self, req):
# def http_req(method, url, data=None, opt=opt_default, limiter=None):
# def _marshalled(data):
# def _update_ratelimiter_with_exactonline_headers(limiter, headers):
# def _http_request(url, method=None, data=None, opt=None, limiter=None):
# class BadProtocol(ValueError):
# class HTTPError(request.HTTPError):
# class Options(object):
# class Request(request.Request):
# class ValidHTTPSConnection(HTTPConnection):
# class ValidHTTPSHandler(request.HTTPSHandler):
#             class CustomValidHTTPSConnection(ValidHTTPSConnection):
# 
# Path: exactonline/resource.py
# class GET(_Resource):
#     pass
# 
# Path: exactonline/storage/base.py
# class MissingSetting(ValueError):
#     pass


from ..exceptions import ExactOnlineError
from ..http import urljoin
from ..resource import GET
from ..storage import MissingSetting
Autoselects the division.

This file is part of the Exact Online REST API Library in Python
(EORALP), licensed under the LGPLv3+.
Copyright (C) 2015-2017 Walter Doekes, OSSO B.V.
"""


class V1DivisionError(ExactOnlineError):
    pass


class V1Division(object):
    def restv1(self, request):
        try:
            division = self.storage.get_division()
        except MissingSetting:
            raise V1DivisionError('Division unset/blank in config')
        if not division:
            raise V1DivisionError('Division unset/blank in config')

        urlbase = 'v1/%d/' % (division,)
        request = request.update(resource=urljoin(urlbase, request.resource))
        return self.rest(request)

    def get_divisions(self):
        """
        Get the "current" division and return a dictionary of divisions
        so the user can select the right one.
        """

# Path: exactonline/exceptions.py
# class ExactOnlineError(Exception):
#     pass
# 
# Path: exactonline/http.py
# FALLBACK_CACERT_FILE = '/etc/ssl/certs/ca-certificates.crt'
#     _PROPERTIES = ('protocols', 'verify_cert', 'cacert_file', 'headers')
# def binquote(value):
#     def __init__(self, url, code, msg, hdrs, response, reqmethod, reqdata):
#     def clean_and_trim(value):
#     def get_content_type(self):
#     def format_req(self):
#     def format_resp(self):
#     def __str__(self):
#     def __or__(self, other):
#     def __init__(self, method=None, *args, **kwargs):
#     def get_method(self):
#     def __init__(self, *args, **kwargs):
#     def connect(self):
#     def __init__(self, cacert_file):
#     def https_open(self, req):
# def http_req(method, url, data=None, opt=opt_default, limiter=None):
# def _marshalled(data):
# def _update_ratelimiter_with_exactonline_headers(limiter, headers):
# def _http_request(url, method=None, data=None, opt=None, limiter=None):
# class BadProtocol(ValueError):
# class HTTPError(request.HTTPError):
# class Options(object):
# class Request(request.Request):
# class ValidHTTPSConnection(HTTPConnection):
# class ValidHTTPSHandler(request.HTTPSHandler):
#             class CustomValidHTTPSConnection(ValidHTTPSConnection):
# 
# Path: exactonline/resource.py
# class GET(_Resource):
#     pass
# 
# Path: exactonline/storage/base.py
# class MissingSetting(ValueError):
#     pass


# Path: exactonline/api/v1division.py
from ..exceptions import ExactOnlineError
from ..http import urljoin
from ..resource import GET
from ..storage import MissingSetting

Autoselects the division.

This file is part of the Exact Online REST API Library in Python
(EORALP), licensed under the LGPLv3+.
Copyright (C) 2015-2017 Walter Doekes, OSSO B.V.
"""


class V1DivisionError(ExactOnlineError):
    pass


class V1Division(object):
    def restv1(self, request):
        try:
            division = self.storage.get_division()
        except MissingSetting:
            raise V1DivisionError('Division unset/blank in config')
        if not division:
            raise V1DivisionError('Division unset/blank in config')

        urlbase = 'v1/%d/' % (division,)
        request = request.update(resource=urljoin(urlbase, request.resource))
        return self.rest(request)

    def get_divisions(self):
        """
        Get the "current" division and return a dictionary of divisions
        so the user can select the right one.
        """

        ret = self.rest(GET('v1/current/Me?$select=CurrentDivision'))