# coding: utf-8

"""
Payment API

API for accepting payments and storing subscriptions

The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
"""  # noqa: E501

from typing import Any, Awaitable, Dict, List, Optional, Tuple, Union

from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call
from typing_extensions import Annotated

from crypticorn.pay.client.api_client import ApiClient, RequestSerialized
from crypticorn.pay.client.api_response import ApiResponse
from crypticorn.pay.client.models.paginated_response_payment import (
    PaginatedResponsePayment,
)
from crypticorn.pay.client.models.payment import Payment
from crypticorn.pay.client.models.subscription import Subscription
from crypticorn.pay.client.rest import RESTResponseType

# Import async_to_sync for sync methods
try:
    from asgiref.sync import async_to_sync

    _HAS_ASGIREF = True
except ImportError:
    _HAS_ASGIREF = False

    def async_to_sync(async_func):
        """Fallback decorator that raises an error if asgiref is not available."""

        def wrapper(*args, **kwargs):
            raise ImportError(
                "asgiref is required for sync methods. Install with: pip install asgiref"
            )

        return wrapper


class PaymentsApi:
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    def __init__(self, api_client=None, is_sync: bool = False) -> None:
        if api_client is None:
            api_client = ApiClient.get_default()
        self.api_client = api_client
        self.is_sync = is_sync

    @validate_call
    def get_payment_history(
        self,
        filter_by: Annotated[
            Optional[StrictStr], Field(description="The field to filter by")
        ] = None,
        filter_value: Annotated[
            Optional[StrictStr], Field(description="The value to filter with")
        ] = None,
        sort_order: Annotated[
            Optional[StrictStr], Field(description="The order to sort by")
        ] = None,
        sort_by: Annotated[
            Optional[StrictStr], Field(description="The field to sort by")
        ] = None,
        page: Annotated[
            Optional[StrictInt], Field(description="The current page number")
        ] = None,
        page_size: Annotated[
            Optional[Annotated[int, Field(le=100, strict=True, ge=1)]],
            Field(
                description="The number of items per page. Default is 10, max is 100."
            ),
        ] = None,
        user_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The ID of the user. Overrides the authenticated user if provided and the user is an admin."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> Union[PaginatedResponsePayment, Awaitable[PaginatedResponsePayment]]:
        """Get Payment History"""
        if self.is_sync:
            return self._get_payment_history_sync(
                filter_by=filter_by,
                filter_value=filter_value,
                sort_order=sort_order,
                sort_by=sort_by,
                page=page,
                page_size=page_size,
                user_id=user_id,
                _request_timeout=_request_timeout,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )

        else:
            return self._get_payment_history_async(
                filter_by=filter_by,
                filter_value=filter_value,
                sort_order=sort_order,
                sort_by=sort_by,
                page=page,
                page_size=page_size,
                user_id=user_id,
                _request_timeout=_request_timeout,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )

    @validate_call
    def get_payment_history_with_http_info(
        self,
        filter_by: Annotated[
            Optional[StrictStr], Field(description="The field to filter by")
        ] = None,
        filter_value: Annotated[
            Optional[StrictStr], Field(description="The value to filter with")
        ] = None,
        sort_order: Annotated[
            Optional[StrictStr], Field(description="The order to sort by")
        ] = None,
        sort_by: Annotated[
            Optional[StrictStr], Field(description="The field to sort by")
        ] = None,
        page: Annotated[
            Optional[StrictInt], Field(description="The current page number")
        ] = None,
        page_size: Annotated[
            Optional[Annotated[int, Field(le=100, strict=True, ge=1)]],
            Field(
                description="The number of items per page. Default is 10, max is 100."
            ),
        ] = None,
        user_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The ID of the user. Overrides the authenticated user if provided and the user is an admin."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> Union[
        ApiResponse[PaginatedResponsePayment],
        Awaitable[ApiResponse[PaginatedResponsePayment]],
    ]:
        """Get Payment History with HTTP info"""
        if self.is_sync:
            return self._get_payment_history_sync_with_http_info(
                filter_by=filter_by,
                filter_value=filter_value,
                sort_order=sort_order,
                sort_by=sort_by,
                page=page,
                page_size=page_size,
                user_id=user_id,
                _request_timeout=_request_timeout,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )

        else:
            return self._get_payment_history_async_with_http_info(
                filter_by=filter_by,
                filter_value=filter_value,
                sort_order=sort_order,
                sort_by=sort_by,
                page=page,
                page_size=page_size,
                user_id=user_id,
                _request_timeout=_request_timeout,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )

    @validate_call
    def get_payment_history_without_preload_content(
        self,
        filter_by: Annotated[
            Optional[StrictStr], Field(description="The field to filter by")
        ] = None,
        filter_value: Annotated[
            Optional[StrictStr], Field(description="The value to filter with")
        ] = None,
        sort_order: Annotated[
            Optional[StrictStr], Field(description="The order to sort by")
        ] = None,
        sort_by: Annotated[
            Optional[StrictStr], Field(description="The field to sort by")
        ] = None,
        page: Annotated[
            Optional[StrictInt], Field(description="The current page number")
        ] = None,
        page_size: Annotated[
            Optional[Annotated[int, Field(le=100, strict=True, ge=1)]],
            Field(
                description="The number of items per page. Default is 10, max is 100."
            ),
        ] = None,
        user_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The ID of the user. Overrides the authenticated user if provided and the user is an admin."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> Union[RESTResponseType, Awaitable[RESTResponseType]]:
        """Get Payment History without preloading content"""
        if self.is_sync:
            return self._get_payment_history_sync_without_preload_content(
                filter_by=filter_by,
                filter_value=filter_value,
                sort_order=sort_order,
                sort_by=sort_by,
                page=page,
                page_size=page_size,
                user_id=user_id,
                _request_timeout=_request_timeout,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )

        else:
            return self._get_payment_history_async_without_preload_content(
                filter_by=filter_by,
                filter_value=filter_value,
                sort_order=sort_order,
                sort_by=sort_by,
                page=page,
                page_size=page_size,
                user_id=user_id,
                _request_timeout=_request_timeout,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )

    # Private async implementation methods
    @validate_call
    async def _get_payment_history_async(
        self,
        filter_by: Annotated[
            Optional[StrictStr], Field(description="The field to filter by")
        ] = None,
        filter_value: Annotated[
            Optional[StrictStr], Field(description="The value to filter with")
        ] = None,
        sort_order: Annotated[
            Optional[StrictStr], Field(description="The order to sort by")
        ] = None,
        sort_by: Annotated[
            Optional[StrictStr], Field(description="The field to sort by")
        ] = None,
        page: Annotated[
            Optional[StrictInt], Field(description="The current page number")
        ] = None,
        page_size: Annotated[
            Optional[Annotated[int, Field(le=100, strict=True, ge=1)]],
            Field(
                description="The number of items per page. Default is 10, max is 100."
            ),
        ] = None,
        user_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The ID of the user. Overrides the authenticated user if provided and the user is an admin."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> PaginatedResponsePayment:
        """Get Payment History

        Get the combined payment history for a user across all payment services.

        :param filter_by: The field to filter by
        :type filter_by: str
        :param filter_value: The value to filter with
        :type filter_value: str
        :param sort_order: The order to sort by
        :type sort_order: str
        :param sort_by: The field to sort by
        :type sort_by: str
        :param page: The current page number
        :type page: int
        :param page_size: The number of items per page. Default is 10, max is 100.
        :type page_size: int
        :param user_id: The ID of the user. Overrides the authenticated user if provided and the user is an admin.
        :type user_id: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._get_payment_history_serialize(
            filter_by=filter_by,
            filter_value=filter_value,
            sort_order=sort_order,
            sort_by=sort_by,
            page=page,
            page_size=page_size,
            user_id=user_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "PaginatedResponsePayment",
        }

        response_data = await self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        await response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data

    @validate_call
    async def _get_payment_history_async_with_http_info(
        self,
        filter_by: Annotated[
            Optional[StrictStr], Field(description="The field to filter by")
        ] = None,
        filter_value: Annotated[
            Optional[StrictStr], Field(description="The value to filter with")
        ] = None,
        sort_order: Annotated[
            Optional[StrictStr], Field(description="The order to sort by")
        ] = None,
        sort_by: Annotated[
            Optional[StrictStr], Field(description="The field to sort by")
        ] = None,
        page: Annotated[
            Optional[StrictInt], Field(description="The current page number")
        ] = None,
        page_size: Annotated[
            Optional[Annotated[int, Field(le=100, strict=True, ge=1)]],
            Field(
                description="The number of items per page. Default is 10, max is 100."
            ),
        ] = None,
        user_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The ID of the user. Overrides the authenticated user if provided and the user is an admin."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[PaginatedResponsePayment]:
        """Get Payment History

        Get the combined payment history for a user across all payment services.

        :param filter_by: The field to filter by
        :type filter_by: str
        :param filter_value: The value to filter with
        :type filter_value: str
        :param sort_order: The order to sort by
        :type sort_order: str
        :param sort_by: The field to sort by
        :type sort_by: str
        :param page: The current page number
        :type page: int
        :param page_size: The number of items per page. Default is 10, max is 100.
        :type page_size: int
        :param user_id: The ID of the user. Overrides the authenticated user if provided and the user is an admin.
        :type user_id: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._get_payment_history_serialize(
            filter_by=filter_by,
            filter_value=filter_value,
            sort_order=sort_order,
            sort_by=sort_by,
            page=page,
            page_size=page_size,
            user_id=user_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "PaginatedResponsePayment",
        }

        response_data = await self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        await response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data, response_types_map=_response_types_map
        )

    @validate_call
    async def _get_payment_history_async_without_preload_content(
        self,
        filter_by: Annotated[
            Optional[StrictStr], Field(description="The field to filter by")
        ] = None,
        filter_value: Annotated[
            Optional[StrictStr], Field(description="The value to filter with")
        ] = None,
        sort_order: Annotated[
            Optional[StrictStr], Field(description="The order to sort by")
        ] = None,
        sort_by: Annotated[
            Optional[StrictStr], Field(description="The field to sort by")
        ] = None,
        page: Annotated[
            Optional[StrictInt], Field(description="The current page number")
        ] = None,
        page_size: Annotated[
            Optional[Annotated[int, Field(le=100, strict=True, ge=1)]],
            Field(
                description="The number of items per page. Default is 10, max is 100."
            ),
        ] = None,
        user_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The ID of the user. Overrides the authenticated user if provided and the user is an admin."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Get Payment History

        Get the combined payment history for a user across all payment services.

        :param filter_by: The field to filter by
        :type filter_by: str
        :param filter_value: The value to filter with
        :type filter_value: str
        :param sort_order: The order to sort by
        :type sort_order: str
        :param sort_by: The field to sort by
        :type sort_by: str
        :param page: The current page number
        :type page: int
        :param page_size: The number of items per page. Default is 10, max is 100.
        :type page_size: int
        :param user_id: The ID of the user. Overrides the authenticated user if provided and the user is an admin.
        :type user_id: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._get_payment_history_serialize(
            filter_by=filter_by,
            filter_value=filter_value,
            sort_order=sort_order,
            sort_by=sort_by,
            page=page,
            page_size=page_size,
            user_id=user_id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "PaginatedResponsePayment",
        }

        response_data = await self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        return response_data

    # Private sync implementation methods
    @validate_call
    def _get_payment_history_sync(
        self,
        filter_by: Annotated[
            Optional[StrictStr], Field(description="The field to filter by")
        ] = None,
        filter_value: Annotated[
            Optional[StrictStr], Field(description="The value to filter with")
        ] = None,
        sort_order: Annotated[
            Optional[StrictStr], Field(description="The order to sort by")
        ] = None,
        sort_by: Annotated[
            Optional[StrictStr], Field(description="The field to sort by")
        ] = None,
        page: Annotated[
            Optional[StrictInt], Field(description="The current page number")
        ] = None,
        page_size: Annotated[
            Optional[Annotated[int, Field(le=100, strict=True, ge=1)]],
            Field(
                description="The number of items per page. Default is 10, max is 100."
            ),
        ] = None,
        user_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The ID of the user. Overrides the authenticated user if provided and the user is an admin."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> PaginatedResponsePayment:
        """Synchronous version of get_payment_history"""
        return async_to_sync(self._get_payment_history_async)(
            filter_by=filter_by,
            filter_value=filter_value,
            sort_order=sort_order,
            sort_by=sort_by,
            page=page,
            page_size=page_size,
            user_id=user_id,
            _request_timeout=_request_timeout,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

    @validate_call
    def _get_payment_history_sync_with_http_info(
        self,
        filter_by: Annotated[
            Optional[StrictStr], Field(description="The field to filter by")
        ] = None,
        filter_value: Annotated[
            Optional[StrictStr], Field(description="The value to filter with")
        ] = None,
        sort_order: Annotated[
            Optional[StrictStr], Field(description="The order to sort by")
        ] = None,
        sort_by: Annotated[
            Optional[StrictStr], Field(description="The field to sort by")
        ] = None,
        page: Annotated[
            Optional[StrictInt], Field(description="The current page number")
        ] = None,
        page_size: Annotated[
            Optional[Annotated[int, Field(le=100, strict=True, ge=1)]],
            Field(
                description="The number of items per page. Default is 10, max is 100."
            ),
        ] = None,
        user_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The ID of the user. Overrides the authenticated user if provided and the user is an admin."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[PaginatedResponsePayment]:
        """Synchronous version of get_payment_history_with_http_info"""
        return async_to_sync(self._get_payment_history_async_with_http_info)(
            filter_by=filter_by,
            filter_value=filter_value,
            sort_order=sort_order,
            sort_by=sort_by,
            page=page,
            page_size=page_size,
            user_id=user_id,
            _request_timeout=_request_timeout,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

    @validate_call
    def _get_payment_history_sync_without_preload_content(
        self,
        filter_by: Annotated[
            Optional[StrictStr], Field(description="The field to filter by")
        ] = None,
        filter_value: Annotated[
            Optional[StrictStr], Field(description="The value to filter with")
        ] = None,
        sort_order: Annotated[
            Optional[StrictStr], Field(description="The order to sort by")
        ] = None,
        sort_by: Annotated[
            Optional[StrictStr], Field(description="The field to sort by")
        ] = None,
        page: Annotated[
            Optional[StrictInt], Field(description="The current page number")
        ] = None,
        page_size: Annotated[
            Optional[Annotated[int, Field(le=100, strict=True, ge=1)]],
            Field(
                description="The number of items per page. Default is 10, max is 100."
            ),
        ] = None,
        user_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The ID of the user. Overrides the authenticated user if provided and the user is an admin."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Synchronous version of get_payment_history_without_preload_content"""
        return async_to_sync(self._get_payment_history_async_without_preload_content)(
            filter_by=filter_by,
            filter_value=filter_value,
            sort_order=sort_order,
            sort_by=sort_by,
            page=page,
            page_size=page_size,
            user_id=user_id,
            _request_timeout=_request_timeout,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

    def _get_payment_history_serialize(
        self,
        filter_by,
        filter_value,
        sort_order,
        sort_by,
        page,
        page_size,
        user_id,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {}

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        # process the query parameters
        if filter_by is not None:

            _query_params.append(("filter_by", filter_by))

        if filter_value is not None:

            _query_params.append(("filter_value", filter_value))

        if sort_order is not None:

            _query_params.append(("sort_order", sort_order))

        if sort_by is not None:

            _query_params.append(("sort_by", sort_by))

        if page is not None:

            _query_params.append(("page", page))

        if page_size is not None:

            _query_params.append(("page_size", page_size))

        if user_id is not None:

            _query_params.append(("user_id", user_id))

        # process the header parameters
        # process the form parameters
        # process the body parameter

        # set the HTTP header `Accept`
        if "Accept" not in _header_params:
            _header_params["Accept"] = self.api_client.select_header_accept(
                ["application/json"]
            )

        # authentication setting
        _auth_settings: List[str] = ["APIKeyHeader", "HTTPBearer"]

        return self.api_client.param_serialize(
            method="GET",
            resource_path="/payments/history",
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth,
        )

    @validate_call
    def get_payments_by_invoice(
        self,
        id: Annotated[StrictStr, Field(description="The invoice ID")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> Union[List[Payment], Awaitable[List[Payment]]]:
        """Get Payments By Invoice"""
        if self.is_sync:
            return self._get_payments_by_invoice_sync(
                id=id,
                _request_timeout=_request_timeout,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )

        else:
            return self._get_payments_by_invoice_async(
                id=id,
                _request_timeout=_request_timeout,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )

    @validate_call
    def get_payments_by_invoice_with_http_info(
        self,
        id: Annotated[StrictStr, Field(description="The invoice ID")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> Union[ApiResponse[List[Payment]], Awaitable[ApiResponse[List[Payment]]]]:
        """Get Payments By Invoice with HTTP info"""
        if self.is_sync:
            return self._get_payments_by_invoice_sync_with_http_info(
                id=id,
                _request_timeout=_request_timeout,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )

        else:
            return self._get_payments_by_invoice_async_with_http_info(
                id=id,
                _request_timeout=_request_timeout,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )

    @validate_call
    def get_payments_by_invoice_without_preload_content(
        self,
        id: Annotated[StrictStr, Field(description="The invoice ID")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> Union[RESTResponseType, Awaitable[RESTResponseType]]:
        """Get Payments By Invoice without preloading content"""
        if self.is_sync:
            return self._get_payments_by_invoice_sync_without_preload_content(
                id=id,
                _request_timeout=_request_timeout,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )

        else:
            return self._get_payments_by_invoice_async_without_preload_content(
                id=id,
                _request_timeout=_request_timeout,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )

    # Private async implementation methods
    @validate_call
    async def _get_payments_by_invoice_async(
        self,
        id: Annotated[StrictStr, Field(description="The invoice ID")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> List[Payment]:
        """Get Payments By Invoice

        Get all payments by invoice ID. Usually is just one payment, but can be multiple in case of partial payments.

        :param id: The invoice ID (required)
        :type id: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._get_payments_by_invoice_serialize(
            id=id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "List[Payment]",
        }

        response_data = await self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        await response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data

    @validate_call
    async def _get_payments_by_invoice_async_with_http_info(
        self,
        id: Annotated[StrictStr, Field(description="The invoice ID")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[List[Payment]]:
        """Get Payments By Invoice

        Get all payments by invoice ID. Usually is just one payment, but can be multiple in case of partial payments.

        :param id: The invoice ID (required)
        :type id: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._get_payments_by_invoice_serialize(
            id=id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "List[Payment]",
        }

        response_data = await self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        await response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data, response_types_map=_response_types_map
        )

    @validate_call
    async def _get_payments_by_invoice_async_without_preload_content(
        self,
        id: Annotated[StrictStr, Field(description="The invoice ID")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Get Payments By Invoice

        Get all payments by invoice ID. Usually is just one payment, but can be multiple in case of partial payments.

        :param id: The invoice ID (required)
        :type id: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._get_payments_by_invoice_serialize(
            id=id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "List[Payment]",
        }

        response_data = await self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        return response_data

    # Private sync implementation methods
    @validate_call
    def _get_payments_by_invoice_sync(
        self,
        id: Annotated[StrictStr, Field(description="The invoice ID")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> List[Payment]:
        """Synchronous version of get_payments_by_invoice"""
        return async_to_sync(self._get_payments_by_invoice_async)(
            id=id,
            _request_timeout=_request_timeout,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

    @validate_call
    def _get_payments_by_invoice_sync_with_http_info(
        self,
        id: Annotated[StrictStr, Field(description="The invoice ID")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[List[Payment]]:
        """Synchronous version of get_payments_by_invoice_with_http_info"""
        return async_to_sync(self._get_payments_by_invoice_async_with_http_info)(
            id=id,
            _request_timeout=_request_timeout,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

    @validate_call
    def _get_payments_by_invoice_sync_without_preload_content(
        self,
        id: Annotated[StrictStr, Field(description="The invoice ID")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Synchronous version of get_payments_by_invoice_without_preload_content"""
        return async_to_sync(
            self._get_payments_by_invoice_async_without_preload_content
        )(
            id=id,
            _request_timeout=_request_timeout,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

    def _get_payments_by_invoice_serialize(
        self,
        id,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {}

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if id is not None:
            _path_params["id"] = id
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter

        # set the HTTP header `Accept`
        if "Accept" not in _header_params:
            _header_params["Accept"] = self.api_client.select_header_accept(
                ["application/json"]
            )

        # authentication setting
        _auth_settings: List[str] = []

        return self.api_client.param_serialize(
            method="GET",
            resource_path="/payments/by-invoice/{id}",
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth,
        )

    @validate_call
    def get_subscriptions(
        self,
        user_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The ID of the user to get subscriptions for. Overrides the authenticated user if provided and the user is an admin."
            ),
        ] = None,
        state: Annotated[
            Optional[StrictStr],
            Field(
                description="The state of the subscriptions to get. Defaults to all states."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> Union[List[Subscription], Awaitable[List[Subscription]]]:
        """Get Subscriptions"""
        if self.is_sync:
            return self._get_subscriptions_sync(
                user_id=user_id,
                state=state,
                _request_timeout=_request_timeout,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )

        else:
            return self._get_subscriptions_async(
                user_id=user_id,
                state=state,
                _request_timeout=_request_timeout,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )

    @validate_call
    def get_subscriptions_with_http_info(
        self,
        user_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The ID of the user to get subscriptions for. Overrides the authenticated user if provided and the user is an admin."
            ),
        ] = None,
        state: Annotated[
            Optional[StrictStr],
            Field(
                description="The state of the subscriptions to get. Defaults to all states."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> Union[
        ApiResponse[List[Subscription]], Awaitable[ApiResponse[List[Subscription]]]
    ]:
        """Get Subscriptions with HTTP info"""
        if self.is_sync:
            return self._get_subscriptions_sync_with_http_info(
                user_id=user_id,
                state=state,
                _request_timeout=_request_timeout,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )

        else:
            return self._get_subscriptions_async_with_http_info(
                user_id=user_id,
                state=state,
                _request_timeout=_request_timeout,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )

    @validate_call
    def get_subscriptions_without_preload_content(
        self,
        user_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The ID of the user to get subscriptions for. Overrides the authenticated user if provided and the user is an admin."
            ),
        ] = None,
        state: Annotated[
            Optional[StrictStr],
            Field(
                description="The state of the subscriptions to get. Defaults to all states."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> Union[RESTResponseType, Awaitable[RESTResponseType]]:
        """Get Subscriptions without preloading content"""
        if self.is_sync:
            return self._get_subscriptions_sync_without_preload_content(
                user_id=user_id,
                state=state,
                _request_timeout=_request_timeout,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )

        else:
            return self._get_subscriptions_async_without_preload_content(
                user_id=user_id,
                state=state,
                _request_timeout=_request_timeout,
                _request_auth=_request_auth,
                _content_type=_content_type,
                _headers=_headers,
                _host_index=_host_index,
            )

    # Private async implementation methods
    @validate_call
    async def _get_subscriptions_async(
        self,
        user_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The ID of the user to get subscriptions for. Overrides the authenticated user if provided and the user is an admin."
            ),
        ] = None,
        state: Annotated[
            Optional[StrictStr],
            Field(
                description="The state of the subscriptions to get. Defaults to all states."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> List[Subscription]:
        """Get Subscriptions

        Get all subscriptions for a user. Subscriptions are the products a user has subscribed to. Returns both active and inactive subscriptions.

        :param user_id: The ID of the user to get subscriptions for. Overrides the authenticated user if provided and the user is an admin.
        :type user_id: str
        :param state: The state of the subscriptions to get. Defaults to all states.
        :type state: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._get_subscriptions_serialize(
            user_id=user_id,
            state=state,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "List[Subscription]",
        }

        response_data = await self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        await response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data

    @validate_call
    async def _get_subscriptions_async_with_http_info(
        self,
        user_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The ID of the user to get subscriptions for. Overrides the authenticated user if provided and the user is an admin."
            ),
        ] = None,
        state: Annotated[
            Optional[StrictStr],
            Field(
                description="The state of the subscriptions to get. Defaults to all states."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[List[Subscription]]:
        """Get Subscriptions

        Get all subscriptions for a user. Subscriptions are the products a user has subscribed to. Returns both active and inactive subscriptions.

        :param user_id: The ID of the user to get subscriptions for. Overrides the authenticated user if provided and the user is an admin.
        :type user_id: str
        :param state: The state of the subscriptions to get. Defaults to all states.
        :type state: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._get_subscriptions_serialize(
            user_id=user_id,
            state=state,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "List[Subscription]",
        }

        response_data = await self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        await response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data, response_types_map=_response_types_map
        )

    @validate_call
    async def _get_subscriptions_async_without_preload_content(
        self,
        user_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The ID of the user to get subscriptions for. Overrides the authenticated user if provided and the user is an admin."
            ),
        ] = None,
        state: Annotated[
            Optional[StrictStr],
            Field(
                description="The state of the subscriptions to get. Defaults to all states."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Get Subscriptions

        Get all subscriptions for a user. Subscriptions are the products a user has subscribed to. Returns both active and inactive subscriptions.

        :param user_id: The ID of the user to get subscriptions for. Overrides the authenticated user if provided and the user is an admin.
        :type user_id: str
        :param state: The state of the subscriptions to get. Defaults to all states.
        :type state: str
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """  # noqa: E501

        _param = self._get_subscriptions_serialize(
            user_id=user_id,
            state=state,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "List[Subscription]",
        }

        response_data = await self.api_client.call_api(
            *_param, _request_timeout=_request_timeout
        )
        return response_data

    # Private sync implementation methods
    @validate_call
    def _get_subscriptions_sync(
        self,
        user_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The ID of the user to get subscriptions for. Overrides the authenticated user if provided and the user is an admin."
            ),
        ] = None,
        state: Annotated[
            Optional[StrictStr],
            Field(
                description="The state of the subscriptions to get. Defaults to all states."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> List[Subscription]:
        """Synchronous version of get_subscriptions"""
        return async_to_sync(self._get_subscriptions_async)(
            user_id=user_id,
            state=state,
            _request_timeout=_request_timeout,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

    @validate_call
    def _get_subscriptions_sync_with_http_info(
        self,
        user_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The ID of the user to get subscriptions for. Overrides the authenticated user if provided and the user is an admin."
            ),
        ] = None,
        state: Annotated[
            Optional[StrictStr],
            Field(
                description="The state of the subscriptions to get. Defaults to all states."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[List[Subscription]]:
        """Synchronous version of get_subscriptions_with_http_info"""
        return async_to_sync(self._get_subscriptions_async_with_http_info)(
            user_id=user_id,
            state=state,
            _request_timeout=_request_timeout,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

    @validate_call
    def _get_subscriptions_sync_without_preload_content(
        self,
        user_id: Annotated[
            Optional[StrictStr],
            Field(
                description="The ID of the user to get subscriptions for. Overrides the authenticated user if provided and the user is an admin."
            ),
        ] = None,
        state: Annotated[
            Optional[StrictStr],
            Field(
                description="The state of the subscriptions to get. Defaults to all states."
            ),
        ] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)], Annotated[StrictFloat, Field(gt=0)]
            ],
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """Synchronous version of get_subscriptions_without_preload_content"""
        return async_to_sync(self._get_subscriptions_async_without_preload_content)(
            user_id=user_id,
            state=state,
            _request_timeout=_request_timeout,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

    def _get_subscriptions_serialize(
        self,
        user_id,
        state,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {}

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        # process the query parameters
        if user_id is not None:

            _query_params.append(("user_id", user_id))

        if state is not None:

            _query_params.append(("state", state))

        # process the header parameters
        # process the form parameters
        # process the body parameter

        # set the HTTP header `Accept`
        if "Accept" not in _header_params:
            _header_params["Accept"] = self.api_client.select_header_accept(
                ["application/json"]
            )

        # authentication setting
        _auth_settings: List[str] = ["APIKeyHeader", "HTTPBearer"]

        return self.api_client.param_serialize(
            method="GET",
            resource_path="/payments/subscriptions",
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth,
        )
