# 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 datetime import datetime
from typing import List, Optional
from pydantic import BaseModel, Field, StrictBool, StrictStr, conint, conlist
from synctera_client_ng.models.payment_type import PaymentType
from synctera_client_ng.models.spend_control_direction import SpendControlDirection
from synctera_client_ng.models.spend_control_time_range import SpendControlTimeRange

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

    Do not edit the class manually.
    """
    action_case: StrictBool = Field(..., description="If set, create a case for transactions that do not conform to the spend control")
    action_decline: StrictBool = Field(..., description="If set, decline transactions that do not conform to the spend control")
    amount_limit: conint(strict=True, ge=0) = Field(..., description="Monetary limit for the spend control in the smallest currency unit (eg cents)")
    creation_time: datetime = Field(..., description="The timestamp representing when the spend control was created")
    direction: Optional[SpendControlDirection] = None
    id: StrictStr = Field(..., description="Spend Control ID")
    is_active: StrictBool = Field(..., description="Indicates if spend control is active")
    last_modified_time: datetime = Field(..., description="The timestamp representing when the spend control was last modified")
    name: StrictStr = Field(..., description="Name assigned to spend control")
    payment_types: Optional[conlist(PaymentType)] = Field(None, description="A list of payment types to which a spend control will apply, if set. If not set or the array is empty, then the spend control will apply to all types of payments.")
    time_range: SpendControlTimeRange = ...
    number_of_related_accounts: conint(strict=True, ge=0) = Field(..., description="A count of how many accounts are using this spend control")
    __properties = ["action_case", "action_decline", "amount_limit", "creation_time", "direction", "id", "is_active", "last_modified_time", "name", "payment_types", "time_range", "number_of_related_accounts"]

    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) -> SpendControlResponse:
        """Create an instance of SpendControlResponse 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={
                            "creation_time",
                            "id",
                            "last_modified_time",
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of time_range
        if self.time_range:
            _dict['time_range'] = self.time_range.to_dict()
        return _dict

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

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

        _obj = SpendControlResponse.parse_obj({
            "action_case": obj.get("action_case"),
            "action_decline": obj.get("action_decline"),
            "amount_limit": obj.get("amount_limit"),
            "creation_time": obj.get("creation_time"),
            "direction": obj.get("direction"),
            "id": obj.get("id"),
            "is_active": obj.get("is_active"),
            "last_modified_time": obj.get("last_modified_time"),
            "name": obj.get("name"),
            "payment_types": obj.get("payment_types"),
            "time_range": SpendControlTimeRange.from_dict(obj.get("time_range")) if obj.get("time_range") is not None else None,
            "number_of_related_accounts": obj.get("number_of_related_accounts")
        })
        return _obj

