# -*- coding: utf-8 -*-

"""
shelldatareportingapis

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""

from apimatic_core.configurations.global_configuration import GlobalConfiguration
from apimatic_core.decorators.lazy_property import LazyProperty
from shelldatareportingapis.configuration import Configuration
from shelldatareportingapis.controllers.base_controller import BaseController
from shelldatareportingapis.configuration import Environment
from shelldatareportingapis.http.auth.basic_auth import BasicAuth
from shelldatareportingapis.http.auth.bearer_token import BearerToken
from shelldatareportingapis.controllers.customer_controller\
    import CustomerController
from shelldatareportingapis.controllers.transaction_controller\
    import TransactionController
from shelldatareportingapis.controllers.invoice_controller\
    import InvoiceController
from shelldatareportingapis.controllers.o_auth_authorization_controller\
    import OAuthAuthorizationController


class ShelldatareportingapisClient(object):
    @LazyProperty
    def customer(self):
        return CustomerController(self.global_configuration)

    @LazyProperty
    def transaction(self):
        return TransactionController(self.global_configuration)

    @LazyProperty
    def invoice(self):
        return InvoiceController(self.global_configuration)

    @LazyProperty
    def o_auth_authorization(self):
        return OAuthAuthorizationController(self.global_configuration)

    @property
    def bearer_token(self):
        return self.auth_managers['BearerToken']

    def __init__(self, http_client_instance=None,
                 override_http_client_configuration=False, http_call_back=None,
                 timeout=60, max_retries=0, backoff_factor=2,
                 retry_statuses=None, retry_methods=None,
                 environment=Environment.SIT, basic_auth_credentials=None,
                 bearer_token_credentials=None, config=None):
        self.config = config or Configuration(
            http_client_instance=http_client_instance,
            override_http_client_configuration=override_http_client_configuration,
            http_call_back=http_call_back, timeout=timeout,
            max_retries=max_retries, backoff_factor=backoff_factor,
            retry_statuses=retry_statuses, retry_methods=retry_methods,
            environment=environment,
            basic_auth_credentials=basic_auth_credentials,
            bearer_token_credentials=bearer_token_credentials)

        self.global_configuration = GlobalConfiguration(self.config)\
            .global_errors(BaseController.global_errors())\
            .base_uri_executor(self.config.get_base_uri)\
            .user_agent(BaseController.user_agent(), BaseController.user_agent_parameters())

        self.auth_managers = {key: None for key in ['BasicAuth', 'BearerToken']}
        self.auth_managers['BasicAuth'] = BasicAuth(
            self.config.basic_auth_credentials)
        self.auth_managers['BearerToken'] = BearerToken(
            self.config.bearer_token_credentials, self.global_configuration)
        self.global_configuration = self.global_configuration.auth_managers(self.auth_managers)

