"""cellpointapi.

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 cellpointapi.apis.apple_pay_api import (
    ApplePayApi,
)
from cellpointapi.apis.authentication_api import (
    AuthenticationApi,
)
from cellpointapi.apis.base_api import BaseApi
from cellpointapi.apis.bulk_api import BulkApi
from cellpointapi.apis.cards_api import CardsApi
from cellpointapi.apis.notes_api import NotesApi
from cellpointapi.apis.oauth_authorization_api import (
    OauthAuthorizationApi,
)
from cellpointapi.apis.orders_api import OrdersApi
from cellpointapi.apis.payment_methods_api import (
    PaymentMethodsApi,
)
from cellpointapi.apis.proxy_api import ProxyApi
from cellpointapi.apis.transactions_api import (
    TransactionsApi,
)
from cellpointapi.apis.wallet_api import WalletApi
from cellpointapi.configuration import (
    Configuration,
    Environment,
)
from cellpointapi.http.auth.cpd_issued_jwt import (
    CpdIssuedJwt,
)
from cellpointapi.http.auth.merchant_issued_jwt import (
    MerchantIssuedJwt,
)


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

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

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

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

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

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

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

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

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

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

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

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

    @property
    def cpd_issued_jwt(self):
        """Provide access to the CpdIssuedJwt auth manager."""
        return self.auth_managers["cpdIssuedJWT"]

    def __init__(self, http_client_instance=None,
                 override_http_client_configuration=False, http_call_back=None,
                 timeout=30, max_retries=0, backoff_factor=2,
                 retry_statuses=None, retry_methods=None, proxy_settings=None,
                 logging_configuration=None, environment=Environment.PRODUCTION,
                 cpd_issued_jwt_credentials=None,
                 merchant_issued_jwt_credentials=None, config=None):
        """Initialize a new instance of CellpointapiClient."""
        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,
            logging_configuration=logging_configuration,
            environment=environment,
            cpd_issued_jwt_credentials=cpd_issued_jwt_credentials,
            merchant_issued_jwt_credentials=merchant_issued_jwt_credentials)

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

        self.auth_managers = {
            "cpdIssuedJWT": CpdIssuedJwt(self.config.cpd_issued_jwt_credentials,
                                         self.global_configuration),
            "merchantIssuedJWT": MerchantIssuedJwt(
                self.config.merchant_issued_jwt_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:
            CellpointapiClient instance.

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