# coding: utf-8

"""
    Marqeta Core API

    Simplified management of your payment programs  # noqa: E501

    The version of the OpenAPI document: 3.0.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 Optional, Union
from pydantic import BaseModel, StrictBool, StrictStr, confloat, conint, constr, validator
from marqeta_client.models.merchant_scope import MerchantScope
from marqeta_client.models.money_in_transaction import MoneyInTransaction
from marqeta_client.models.spend_control_association import SpendControlAssociation

class VelocityControlResponse(BaseModel):
    """
    VelocityControlResponse
    """
    token: Optional[constr(strict=True, max_length=36, min_length=1)] = None
    name: Optional[constr(strict=True, max_length=255, min_length=0)] = None
    association: Optional[SpendControlAssociation] = None
    merchant_scope: Optional[MerchantScope] = None
    usage_limit: Optional[conint(strict=True, ge=-1)] = None
    approvals_only: Optional[StrictBool] = None
    include_purchases: Optional[StrictBool] = None
    include_withdrawals: Optional[StrictBool] = None
    include_transfers: Optional[StrictBool] = None
    include_cashback: Optional[StrictBool] = None
    include_credits: Optional[StrictBool] = None
    money_in_transaction: Optional[MoneyInTransaction] = None
    currency_code: StrictStr = ...
    amount_limit: Union[confloat(ge=0, strict=True), conint(ge=0, strict=True)] = ...
    velocity_window: StrictStr = ...
    active: Optional[StrictBool] = None
    __properties = ["token", "name", "association", "merchant_scope", "usage_limit", "approvals_only", "include_purchases", "include_withdrawals", "include_transfers", "include_cashback", "include_credits", "money_in_transaction", "currency_code", "amount_limit", "velocity_window", "active"]

    @validator('velocity_window')
    def velocity_window_validate_enum(cls, v):
        if v not in ('DAY', 'WEEK', 'MONTH', 'LIFETIME', 'TRANSACTION'):
            raise ValueError("must be one of enum values ('DAY', 'WEEK', 'MONTH', 'LIFETIME', 'TRANSACTION')")
        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) -> VelocityControlResponse:
        """Create an instance of VelocityControlResponse 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 association
        if self.association:
            _dict['association'] = self.association.to_dict()
        # override the default output from pydantic by calling `to_dict()` of merchant_scope
        if self.merchant_scope:
            _dict['merchant_scope'] = self.merchant_scope.to_dict()
        # override the default output from pydantic by calling `to_dict()` of money_in_transaction
        if self.money_in_transaction:
            _dict['money_in_transaction'] = self.money_in_transaction.to_dict()
        return _dict

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

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

        _obj = VelocityControlResponse.parse_obj({
            "token": obj.get("token"),
            "name": obj.get("name"),
            "association": SpendControlAssociation.from_dict(obj.get("association")) if obj.get("association") is not None else None,
            "merchant_scope": MerchantScope.from_dict(obj.get("merchant_scope")) if obj.get("merchant_scope") is not None else None,
            "usage_limit": obj.get("usage_limit"),
            "approvals_only": obj.get("approvals_only"),
            "include_purchases": obj.get("include_purchases"),
            "include_withdrawals": obj.get("include_withdrawals"),
            "include_transfers": obj.get("include_transfers"),
            "include_cashback": obj.get("include_cashback"),
            "include_credits": obj.get("include_credits"),
            "money_in_transaction": MoneyInTransaction.from_dict(obj.get("money_in_transaction")) if obj.get("money_in_transaction") is not None else None,
            "currency_code": obj.get("currency_code"),
            "amount_limit": obj.get("amount_limit"),
            "velocity_window": obj.get("velocity_window"),
            "active": obj.get("active")
        })
        return _obj

