# 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: 0.36.0.dev5
    Generated by: https://openapi-generator.tech
"""


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


from typing import Optional
from pydantic import BaseModel, Field, StrictStr, conint, constr, validator
from synctera_client_ng.models.minimum_payment_partial import MinimumPaymentPartial

class TemplateFieldsLineOfCredit(BaseModel):
    """NOTE: This class is auto generated by OpenAPI Generator.
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """
    account_type: StrictStr = ...
    bank_country: constr(strict=True) = Field(..., description="Bank country of the account. ISO 3166-1 Alpha-2 or Alpha-3 country code.")
    currency: constr(strict=True) = Field(..., description="Account currency. ISO 4217 alphabetic currency code")
    chargeoff_period: Optional[conint(strict=True, ge=0)] = Field(90, description="The number of days an account can stay delinquent before marking an account as charged-off. ")
    delinquency_period: Optional[conint(strict=True, ge=0)] = Field(30, description="The number of days past the due date to wait for a minimum payment before marking an account as delinquent. ")
    grace_period: Optional[conint(strict=True, ge=0)] = Field(30, description="The number of days past the billing period to allow for payment before it is considered due. This directly infers the due date for a payment. ")
    interest_product_id: Optional[StrictStr] = Field(None, description="An interest account product that the current account associates with. The account product must have its calculation_method set to COMPOUNDED_DAILY. ")
    minimum_payment: MinimumPaymentPartial = ...
    __properties = ["account_type", "bank_country", "currency", "chargeoff_period", "delinquency_period", "grace_period", "interest_product_id", "minimum_payment"]

    @validator('bank_country')
    def bank_country_validate_regular_expression(cls, v):
        if v is None:
            return v
        if not re.match(r"^[A-Z]{2,3}$", v):
            raise ValueError(r"must validate the regular expression /^[A-Z]{2,3}$/")
        return v

    @validator('currency')
    def currency_validate_regular_expression(cls, v):
        if v is None:
            return v
        if not re.match(r"^[A-Z]{3}$", v):
            raise ValueError(r"must validate the regular expression /^[A-Z]{3}$/")
        return v

    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) -> TemplateFieldsLineOfCredit:
        """Create an instance of TemplateFieldsLineOfCredit 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 minimum_payment
        if self.minimum_payment:
            _dict['minimum_payment'] = self.minimum_payment.to_dict()
        return _dict

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

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

        _obj = TemplateFieldsLineOfCredit.parse_obj({
            "account_type": obj.get("account_type"),
            "bank_country": obj.get("bank_country"),
            "currency": obj.get("currency"),
            "chargeoff_period": obj.get("chargeoff_period") if obj.get("chargeoff_period") is not None else 90,
            "delinquency_period": obj.get("delinquency_period") if obj.get("delinquency_period") is not None else 30,
            "grace_period": obj.get("grace_period") if obj.get("grace_period") is not None else 30,
            "interest_product_id": obj.get("interest_product_id"),
            "minimum_payment": MinimumPaymentPartial.from_dict(obj.get("minimum_payment")) if obj.get("minimum_payment") is not None else None
        })
        return _obj

