"""mindbodypublicapi.

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

# ruff: noqa: E501
from apimatic_core.configurations.global_configuration import (
    GlobalConfiguration,
)
from apimatic_core.decorators.lazy_property import (
    LazyProperty,
)

from mindbodypublicapi.configuration import (
    Configuration,
    Environment,
)
from mindbodypublicapi.controllers.appointment_controller import (
    AppointmentController,
)
from mindbodypublicapi.controllers.base_controller import (
    BaseController,
)
from mindbodypublicapi.controllers.class_controller import (
    ClassController,
)
from mindbodypublicapi.controllers.client_controller import (
    ClientController,
)
from mindbodypublicapi.controllers.cross_site_controller import (
    CrossSiteController,
)
from mindbodypublicapi.controllers.enrollment_controller import (
    EnrollmentController,
)
from mindbodypublicapi.controllers.payroll_controller import (
    PayrollController,
)
from mindbodypublicapi.controllers.pick_a_spot_controller import (
    PickASpotController,
)
from mindbodypublicapi.controllers.pricing_option_controller import (
    PricingOptionController,
)
from mindbodypublicapi.controllers.sale_controller import (
    SaleController,
)
from mindbodypublicapi.controllers.site_controller import (
    SiteController,
)
from mindbodypublicapi.controllers.staff_controller import (
    StaffController,
)
from mindbodypublicapi.controllers.user_token_controller import (
    UserTokenController,
)
from mindbodypublicapi.http.auth.custom_header_authentication import (
    CustomHeaderAuthentication,
)


class MindbodypublicapiClient(object):
    """Client that provide access to the MindbodypublicapiClient APIs."""

    @LazyProperty
    def appointment(self):
        """Provide access to the AppointmentController endpoints."""
        return AppointmentController(self.global_configuration)

    @LazyProperty
    def mclass(self):
        """Provide access to the ClassController endpoints."""
        return ClassController(self.global_configuration)

    @LazyProperty
    def client(self):
        """Provide access to the ClientController endpoints."""
        return ClientController(self.global_configuration)

    @LazyProperty
    def cross_site(self):
        """Provide access to the CrossSiteController endpoints."""
        return CrossSiteController(self.global_configuration)

    @LazyProperty
    def enrollment(self):
        """Provide access to the EnrollmentController endpoints."""
        return EnrollmentController(self.global_configuration)

    @LazyProperty
    def payroll(self):
        """Provide access to the PayrollController endpoints."""
        return PayrollController(self.global_configuration)

    @LazyProperty
    def pick_a_spot(self):
        """Provide access to the PickASpotController endpoints."""
        return PickASpotController(self.global_configuration)

    @LazyProperty
    def pricing_option(self):
        """Provide access to the PricingOptionController endpoints."""
        return PricingOptionController(self.global_configuration)

    @LazyProperty
    def sale(self):
        """Provide access to the SaleController endpoints."""
        return SaleController(self.global_configuration)

    @LazyProperty
    def site(self):
        """Provide access to the SiteController endpoints."""
        return SiteController(self.global_configuration)

    @LazyProperty
    def staff(self):
        """Provide access to the StaffController endpoints."""
        return StaffController(self.global_configuration)

    @LazyProperty
    def user_token(self):
        """Provide access to the UserTokenController endpoints."""
        return UserTokenController(self.global_configuration)

    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, proxy_settings=None,
                 environment=Environment.PRODUCTION, api_key=None,
                 custom_header_authentication_credentials=None, config=None):
        """Initialize a new instance of MindbodypublicapiClient."""
        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,
            proxy_settings=proxy_settings, environment=environment,
            api_key=api_key,
            custom_header_authentication_credentials=custom_header_authentication_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 = {
            "API-Key": CustomHeaderAuthentication(
                self.config.custom_header_authentication_credentials),
        }
        self.global_configuration =\
            self.global_configuration.auth_managers(self.auth_managers)

    @classmethod
    def from_environment(cls, dotenv_path=None, **overrides):
        """Create a client instance using environment variables.

        Returns:
            MindbodypublicapiClient instance.

        """
        return cls(config=Configuration
            .from_environment(dotenv_path=dotenv_path, **overrides))
