# coding: utf-8

"""
    CATAPA API

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

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

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


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from uuid import UUID
from openapi_client.models.bank_branch_response import BankBranchResponse
from openapi_client.models.bank_response import BankResponse
from openapi_client.models.currency_simple_response import CurrencySimpleResponse
from typing import Optional, Set
from typing_extensions import Self

class BankAccountResponse(BaseModel):
    """
    BankAccountResponse
    """ # noqa: E501
    id: Optional[UUID] = None
    bank_id: Optional[StrictStr] = Field(default=None, alias="bankId")
    bank: Optional[BankResponse] = None
    bank_branch_id: Optional[StrictStr] = Field(default=None, alias="bankBranchId")
    bank_branch: Optional[BankBranchResponse] = Field(default=None, alias="bankBranch")
    account_number: Optional[StrictStr] = Field(default=None, alias="accountNumber")
    account_name: Optional[StrictStr] = Field(default=None, alias="accountName")
    beneficiary_id: Optional[StrictStr] = Field(default=None, alias="beneficiaryId")
    priority: Optional[Union[StrictFloat, StrictInt]] = None
    currency: Optional[CurrencySimpleResponse] = None
    percentage: Optional[Union[StrictFloat, StrictInt]] = None
    amount: Optional[Union[StrictFloat, StrictInt]] = None
    __properties: ClassVar[List[str]] = ["id", "bankId", "bank", "bankBranchId", "bankBranch", "accountNumber", "accountName", "beneficiaryId", "priority", "currency", "percentage", "amount"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of BankAccountResponse from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of bank
        if self.bank:
            _dict['bank'] = self.bank.to_dict()
        # override the default output from pydantic by calling `to_dict()` of bank_branch
        if self.bank_branch:
            _dict['bankBranch'] = self.bank_branch.to_dict()
        # override the default output from pydantic by calling `to_dict()` of currency
        if self.currency:
            _dict['currency'] = self.currency.to_dict()
        # set to None if bank_branch_id (nullable) is None
        # and model_fields_set contains the field
        if self.bank_branch_id is None and "bank_branch_id" in self.model_fields_set:
            _dict['bankBranchId'] = None

        # set to None if beneficiary_id (nullable) is None
        # and model_fields_set contains the field
        if self.beneficiary_id is None and "beneficiary_id" in self.model_fields_set:
            _dict['beneficiaryId'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of BankAccountResponse from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "bankId": obj.get("bankId"),
            "bank": BankResponse.from_dict(obj["bank"]) if obj.get("bank") is not None else None,
            "bankBranchId": obj.get("bankBranchId"),
            "bankBranch": BankBranchResponse.from_dict(obj["bankBranch"]) if obj.get("bankBranch") is not None else None,
            "accountNumber": obj.get("accountNumber"),
            "accountName": obj.get("accountName"),
            "beneficiaryId": obj.get("beneficiaryId"),
            "priority": obj.get("priority"),
            "currency": CurrencySimpleResponse.from_dict(obj["currency"]) if obj.get("currency") is not None else None,
            "percentage": obj.get("percentage"),
            "amount": obj.get("amount")
        })
        return _obj


