# coding: utf-8

"""
    Synctera API

    <h2>Let's build something great.</h2><p>Welcome to the official reference documentation for Synctera APIs. Our APIs are the best way to automate your company's banking needs and are designed to be easy to understand and implement.</p><p>We're continuously growing this library and what you see here is just the start, but if you need something specific or have a question, <a class='text-blue-600' href='https://synctera.com/contact' target='_blank' rel='noreferrer'>contact us</a>.</p>  # noqa: E501

    The version of the OpenAPI document: 1.41.3
    Contact: dev@swadesh.co
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""


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


from typing import List, Optional
from pydantic import BaseModel, Field, StrictInt, StrictStr, conlist
from synctera_client_v1.models.transaction import Transaction

class SecurityAccountSummary(BaseModel):
    """
    A summary for the security account backing the credit account.
    """
    account_id: Optional[StrictStr] = Field(None, description="The unique identifier of the backing account.")
    account_number: Optional[StrictStr] = Field(None, description="Account number of the backing account.")
    account_type: Optional[StrictStr] = Field(None, description="The type of the account. It refers to the backing account. ")
    apy: Optional[StrictInt] = Field(None, description="The annual percentage yield (APY) for the security account for this statement period, in basis points. For example, an APY of 5.5% will display as 550. ")
    closing_balance: Optional[StrictInt] = Field(None, description="The security account balance at the end of the statement period, in ISO 4217 minor currency units. For example, $1,000 USD will be displayed as 100000.")
    disclosure: Optional[StrictStr] = None
    interest: Optional[StrictInt] = Field(None, description="The total interest earned by the security account for this statement period in ISO 4217 minor currency units. For example, $1.50 USD of interest will be displayed as 150. ")
    interest_previous_month: Optional[StrictInt] = Field(None, description="The total interest earned by the security account in the previous statement period in ISO 4217 minor currency units. For example, $1.50 USD of interest will be displayed as 150. ")
    interest_previous_year: Optional[StrictInt] = Field(None, description="The total interest earned by the security account in the previous year in ISO 4217 minor currency units. For example, $100 USD of interest will be displayed as 10000. ")
    interest_ytd: Optional[StrictInt] = Field(None, description="The total interest earned by the security account for this year to date in ISO 4217 minor currency units. For example, $100 USD of interest will be displayed as 10000. ")
    opening_balance: Optional[StrictInt] = Field(None, description="The security account balance at the start of the statement period, in ISO 4217 minor currency units. For example, $1,000 USD will be displayed as 100000.")
    transactions: Optional[conlist(Transaction)] = Field(None, description="This attribute is deprecated and will be removed. Use `GET /v0/statements/{statement_id}/transactions` instead.")
    __properties = ["account_id", "account_number", "account_type", "apy", "closing_balance", "disclosure", "interest", "interest_previous_month", "interest_previous_year", "interest_ytd", "opening_balance", "transactions"]

    class Config:
        allow_population_by_field_name = True
        validate_assignment = True

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

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

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

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of each item in transactions (list)
        _items = []
        if self.transactions:
            for _item in self.transactions:
                if _item:
                    _items.append(_item.to_dict())
            _dict['transactions'] = _items
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> SecurityAccountSummary:
        """Create an instance of SecurityAccountSummary from a dict"""
        if obj is None:
            return None

        if type(obj) is not dict:
            return SecurityAccountSummary.parse_obj(obj)

        _obj = SecurityAccountSummary.parse_obj({
            "account_id": obj.get("account_id"),
            "account_number": obj.get("account_number"),
            "account_type": obj.get("account_type"),
            "apy": obj.get("apy"),
            "closing_balance": obj.get("closing_balance"),
            "disclosure": obj.get("disclosure"),
            "interest": obj.get("interest"),
            "interest_previous_month": obj.get("interest_previous_month"),
            "interest_previous_year": obj.get("interest_previous_year"),
            "interest_ytd": obj.get("interest_ytd"),
            "opening_balance": obj.get("opening_balance"),
            "transactions": [Transaction.from_dict(_item) for _item in obj.get("transactions")] if obj.get("transactions") is not None else None
        })
        return _obj

