# coding: utf-8

"""
    Accounting service API

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

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

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

import warnings
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
from typing import Any, Dict, List, Optional, Tuple, Union
from typing_extensions import Annotated

from pydantic import Field, StrictInt, StrictStr, field_validator
from typing import Optional
from typing_extensions import Annotated
from cloudbeds_accounting.models.source_balance_response import SourceBalanceResponse
from cloudbeds_accounting.models.source_kind import SourceKind

from cloudbeds_accounting.api_client import ApiClient, RequestSerialized
from cloudbeds_accounting.api_response import ApiResponse
from cloudbeds_accounting.rest import RESTResponseType


class SourceBalanceApi:
    """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) -> None:
        if api_client is None:
            api_client = ApiClient.get_default()
        self.api_client = api_client


    @validate_call
    def get_source_balance_by_source(
        self,
        x_property_id: Annotated[StrictInt, Field(description="Property id")],
        source_kind: SourceKind,
        source_id: Annotated[StrictInt, Field(description="Reservation ID | House Account ID | Group Profile ID | Accounts Receivable Ledger ID")],
        accept_language: Annotated[Optional[StrictStr], Field(description="Language preference for localized tax/fee names. Supports: en-US (English US), es-ES (Spanish Spain), es-MX (Spanish Mexico),  fr-FR (French), de-DE (German), it-IT (Italian), pt-PT (Portuguese Portugal), pt-BR (Portuguese Brazil). Defaults to en-US if not provided or unsupported language is specified. ")] = 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,
    ) -> SourceBalanceResponse:
        """get_source_balance_by_source

        Get source balance information for a reservation / house account / group profile / accounts receivable ledger

        :param x_property_id: Property id (required)
        :type x_property_id: int
        :param source_kind: (required)
        :type source_kind: SourceKind
        :param source_id: Reservation ID | House Account ID | Group Profile ID | Accounts Receivable Ledger ID (required)
        :type source_id: int
        :param accept_language: Language preference for localized tax/fee names. Supports: en-US (English US), es-ES (Spanish Spain), es-MX (Spanish Mexico),  fr-FR (French), de-DE (German), it-IT (Italian), pt-PT (Portuguese Portugal), pt-BR (Portuguese Brazil). Defaults to en-US if not provided or unsupported language is specified. 
        :type accept_language: 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_source_balance_by_source_serialize(
            x_property_id=x_property_id,
            source_kind=source_kind,
            source_id=source_id,
            accept_language=accept_language,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "SourceBalanceResponse",
            '400': "ApiAccountingError",
            '404': "ApiAccountingError",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def get_source_balance_by_source_with_http_info(
        self,
        x_property_id: Annotated[StrictInt, Field(description="Property id")],
        source_kind: SourceKind,
        source_id: Annotated[StrictInt, Field(description="Reservation ID | House Account ID | Group Profile ID | Accounts Receivable Ledger ID")],
        accept_language: Annotated[Optional[StrictStr], Field(description="Language preference for localized tax/fee names. Supports: en-US (English US), es-ES (Spanish Spain), es-MX (Spanish Mexico),  fr-FR (French), de-DE (German), it-IT (Italian), pt-PT (Portuguese Portugal), pt-BR (Portuguese Brazil). Defaults to en-US if not provided or unsupported language is specified. ")] = 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[SourceBalanceResponse]:
        """get_source_balance_by_source

        Get source balance information for a reservation / house account / group profile / accounts receivable ledger

        :param x_property_id: Property id (required)
        :type x_property_id: int
        :param source_kind: (required)
        :type source_kind: SourceKind
        :param source_id: Reservation ID | House Account ID | Group Profile ID | Accounts Receivable Ledger ID (required)
        :type source_id: int
        :param accept_language: Language preference for localized tax/fee names. Supports: en-US (English US), es-ES (Spanish Spain), es-MX (Spanish Mexico),  fr-FR (French), de-DE (German), it-IT (Italian), pt-PT (Portuguese Portugal), pt-BR (Portuguese Brazil). Defaults to en-US if not provided or unsupported language is specified. 
        :type accept_language: 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_source_balance_by_source_serialize(
            x_property_id=x_property_id,
            source_kind=source_kind,
            source_id=source_id,
            accept_language=accept_language,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "SourceBalanceResponse",
            '400': "ApiAccountingError",
            '404': "ApiAccountingError",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def get_source_balance_by_source_without_preload_content(
        self,
        x_property_id: Annotated[StrictInt, Field(description="Property id")],
        source_kind: SourceKind,
        source_id: Annotated[StrictInt, Field(description="Reservation ID | House Account ID | Group Profile ID | Accounts Receivable Ledger ID")],
        accept_language: Annotated[Optional[StrictStr], Field(description="Language preference for localized tax/fee names. Supports: en-US (English US), es-ES (Spanish Spain), es-MX (Spanish Mexico),  fr-FR (French), de-DE (German), it-IT (Italian), pt-PT (Portuguese Portugal), pt-BR (Portuguese Brazil). Defaults to en-US if not provided or unsupported language is specified. ")] = 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_source_balance_by_source

        Get source balance information for a reservation / house account / group profile / accounts receivable ledger

        :param x_property_id: Property id (required)
        :type x_property_id: int
        :param source_kind: (required)
        :type source_kind: SourceKind
        :param source_id: Reservation ID | House Account ID | Group Profile ID | Accounts Receivable Ledger ID (required)
        :type source_id: int
        :param accept_language: Language preference for localized tax/fee names. Supports: en-US (English US), es-ES (Spanish Spain), es-MX (Spanish Mexico),  fr-FR (French), de-DE (German), it-IT (Italian), pt-PT (Portuguese Portugal), pt-BR (Portuguese Brazil). Defaults to en-US if not provided or unsupported language is specified. 
        :type accept_language: 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_source_balance_by_source_serialize(
            x_property_id=x_property_id,
            source_kind=source_kind,
            source_id=source_id,
            accept_language=accept_language,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "SourceBalanceResponse",
            '400': "ApiAccountingError",
            '404': "ApiAccountingError",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _get_source_balance_by_source_serialize(
        self,
        x_property_id,
        source_kind,
        source_id,
        accept_language,
        _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 source_kind is not None:
            _path_params['sourceKind'] = source_kind.value
        if source_id is not None:
            _path_params['sourceId'] = source_id
        # process the query parameters
        # process the header parameters
        if x_property_id is not None:
            _header_params['X-Property-ID'] = x_property_id
        if accept_language is not None:
            _header_params['Accept-Language'] = accept_language
        # 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] = [
            'bearerAuth'
        ]

        return self.api_client.param_serialize(
            method='GET',
            resource_path='/accounting/v1.0/source-balances/{sourceKind}/{sourceId}',
            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
        )


