# 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.41.0
    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, StrictBool, StrictStr, conint, conlist, constr, validator
from synctera_client_ng.models.balance_ceiling import BalanceCeiling
from synctera_client_ng.models.balance_floor import BalanceFloor
from synctera_client_ng.models.billing_period import BillingPeriod
from synctera_client_ng.models.minimum_payment import MinimumPayment
from synctera_client_ng.models.spending_limits import SpendingLimits

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

    Do not edit the class manually.
    """
    account_type: StrictStr = ...
    balance_ceiling: Optional[BalanceCeiling] = None
    balance_floor: Optional[BalanceFloor] = None
    bank_country: constr(strict=True) = Field(..., description="Bank country of the account")
    billing_period: Optional[BillingPeriod] = None
    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. ")
    currency: constr(strict=True) = Field(..., description="Account currency. ISO 4217 alphabetic currency code")
    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. ")
    fee_product_ids: Optional[conlist(StrictStr)] = Field(None, description="A list of fee account products that the current account associates with.")
    grace_period: Optional[conint(strict=True, le=28, ge=21)] = Field(21, 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. The default will be set to 21 days. ")
    interest_product_id: Optional[StrictStr] = Field(None, description="An interest account product that the current account associates with.")
    is_ach_enabled: Optional[StrictBool] = Field(False, description="Enable ACH transaction on ledger.")
    is_card_enabled: Optional[StrictBool] = Field(False, description="Enable card transaction on ledger.")
    is_external_card_enabled: Optional[StrictBool] = Field(False, description="Enable external card transaction on ledger.")
    is_p2p_enabled: Optional[StrictBool] = Field(False, description="Enable P2P transaction on ledger.")
    is_sar_enabled: Optional[StrictBool] = Field(False, description="Enable SAR report.")
    is_wire_enabled: Optional[StrictBool] = Field(False, description="Enable wire transaction on ledger.")
    minimum_payment: Optional[MinimumPayment] = None
    overdraft_limit: Optional[conint(strict=True, ge=0)] = Field(None, description="This field is unused and will be removed in a future API version. ")
    spend_control_ids: Optional[conlist(StrictStr, max_items=10)] = Field(None, description="List of spend control IDs to control spending for the account")
    spending_limits: Optional[SpendingLimits] = None
    __properties = ["account_type", "balance_ceiling", "balance_floor", "bank_country", "billing_period", "chargeoff_period", "currency", "delinquency_period", "fee_product_ids", "grace_period", "interest_product_id", "is_ach_enabled", "is_card_enabled", "is_external_card_enabled", "is_p2p_enabled", "is_sar_enabled", "is_wire_enabled", "minimum_payment", "overdraft_limit", "spend_control_ids", "spending_limits"]

    @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) -> TemplateFieldsGenericResponse:
        """Create an instance of TemplateFieldsGenericResponse 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 balance_ceiling
        if self.balance_ceiling:
            _dict['balance_ceiling'] = self.balance_ceiling.to_dict()
        # override the default output from pydantic by calling `to_dict()` of balance_floor
        if self.balance_floor:
            _dict['balance_floor'] = self.balance_floor.to_dict()
        # override the default output from pydantic by calling `to_dict()` of billing_period
        if self.billing_period:
            _dict['billing_period'] = self.billing_period.to_dict()
        # 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()
        # override the default output from pydantic by calling `to_dict()` of spending_limits
        if self.spending_limits:
            _dict['spending_limits'] = self.spending_limits.to_dict()
        return _dict

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

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

        _obj = TemplateFieldsGenericResponse.parse_obj({
            "account_type": obj.get("account_type"),
            "balance_ceiling": BalanceCeiling.from_dict(obj.get("balance_ceiling")) if obj.get("balance_ceiling") is not None else None,
            "balance_floor": BalanceFloor.from_dict(obj.get("balance_floor")) if obj.get("balance_floor") is not None else None,
            "bank_country": obj.get("bank_country"),
            "billing_period": BillingPeriod.from_dict(obj.get("billing_period")) if obj.get("billing_period") is not None else None,
            "chargeoff_period": obj.get("chargeoff_period") if obj.get("chargeoff_period") is not None else 90,
            "currency": obj.get("currency"),
            "delinquency_period": obj.get("delinquency_period") if obj.get("delinquency_period") is not None else 30,
            "fee_product_ids": obj.get("fee_product_ids"),
            "grace_period": obj.get("grace_period") if obj.get("grace_period") is not None else 21,
            "interest_product_id": obj.get("interest_product_id"),
            "is_ach_enabled": obj.get("is_ach_enabled") if obj.get("is_ach_enabled") is not None else False,
            "is_card_enabled": obj.get("is_card_enabled") if obj.get("is_card_enabled") is not None else False,
            "is_external_card_enabled": obj.get("is_external_card_enabled") if obj.get("is_external_card_enabled") is not None else False,
            "is_p2p_enabled": obj.get("is_p2p_enabled") if obj.get("is_p2p_enabled") is not None else False,
            "is_sar_enabled": obj.get("is_sar_enabled") if obj.get("is_sar_enabled") is not None else False,
            "is_wire_enabled": obj.get("is_wire_enabled") if obj.get("is_wire_enabled") is not None else False,
            "minimum_payment": MinimumPayment.from_dict(obj.get("minimum_payment")) if obj.get("minimum_payment") is not None else None,
            "overdraft_limit": obj.get("overdraft_limit"),
            "spend_control_ids": obj.get("spend_control_ids"),
            "spending_limits": SpendingLimits.from_dict(obj.get("spending_limits")) if obj.get("spending_limits") is not None else None
        })
        return _obj

