# 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 datetime import datetime
from typing import Optional, Union
from pydantic import BaseModel, Field, StrictBool, StrictStr, confloat, conint, constr, validator

class ChargebackResponse(BaseModel):
    """
    ChargebackResponse
    """
    token: constr(strict=True, max_length=36, min_length=1) = ...
    transaction_token: constr(strict=True, max_length=36, min_length=1) = ...
    amount: Union[confloat(ge=0.01, strict=True), conint(ge=1, strict=True)] = ...
    reason_description: Optional[StrictStr] = None
    reason_code: Optional[StrictStr] = None
    memo: Optional[constr(strict=True, max_length=1024, min_length=1)] = None
    state: StrictStr = ...
    channel: StrictStr = ...
    network: StrictStr = ...
    network_case_id: Optional[constr(strict=True, max_length=50, min_length=0)] = None
    credit_user: StrictBool = ...
    created_time: datetime = Field(..., description="yyyy-MM-ddTHH:mm:ssZ")
    last_modified_time: datetime = Field(..., description="yyyy-MM-ddTHH:mm:ssZ")
    __properties = ["token", "transaction_token", "amount", "reason_description", "reason_code", "memo", "state", "channel", "network", "network_case_id", "credit_user", "created_time", "last_modified_time"]

    @validator('reason_description')
    def reason_description_validate_enum(cls, v):
        if v is None:
            return v

        if v not in ('SERVICE_NOT_PROVIDED_MERCHANDISE_NOT_RECEIVED', 'CANCELLED_RECURRING_TRANSACTION', 'NOT_AS_DESCRIBED_OR_DEFECTIVE_MERCHANDISE', 'FRAUD_MULTIPLE_TRANSACTIONS', 'FRAUD_TRANSACTION', 'NO_AUTHORIZATION', 'LATE_PRESENTMENT', 'TRANSACTION_NOT_RECOGNIZED', 'INCORRECT_CURRENCY_OR_TRANSACTION_CODE', 'INCORRECT_TRANSACTION_AMOUNT_OR_ACCOUNT_NUMBER', 'NOT_AUTHORIZED_CARD_PRESENT', 'NOT_AUTHORIZED_CARD_ABSENT', 'CREDIT_NOT_PROCESSED', 'NON_RECEIPT_OF_CASH_OR_LOAD_TRANSACTION_VALUE_AT_ATM'):
            raise ValueError("must be one of enum values ('SERVICE_NOT_PROVIDED_MERCHANDISE_NOT_RECEIVED', 'CANCELLED_RECURRING_TRANSACTION', 'NOT_AS_DESCRIBED_OR_DEFECTIVE_MERCHANDISE', 'FRAUD_MULTIPLE_TRANSACTIONS', 'FRAUD_TRANSACTION', 'NO_AUTHORIZATION', 'LATE_PRESENTMENT', 'TRANSACTION_NOT_RECOGNIZED', 'INCORRECT_CURRENCY_OR_TRANSACTION_CODE', 'INCORRECT_TRANSACTION_AMOUNT_OR_ACCOUNT_NUMBER', 'NOT_AUTHORIZED_CARD_PRESENT', 'NOT_AUTHORIZED_CARD_ABSENT', 'CREDIT_NOT_PROCESSED', 'NON_RECEIPT_OF_CASH_OR_LOAD_TRANSACTION_VALUE_AT_ATM')")
        return v

    @validator('state')
    def state_validate_enum(cls, v):
        if v not in ('INITIATED', 'REPRESENTMENT', 'PREARBITRATION', 'ARBITRATION', 'CASE_WON', 'CASE_LOST', 'NETWORK_REJECTED', 'WITHDRAWN'):
            raise ValueError("must be one of enum values ('INITIATED', 'REPRESENTMENT', 'PREARBITRATION', 'ARBITRATION', 'CASE_WON', 'CASE_LOST', 'NETWORK_REJECTED', 'WITHDRAWN')")
        return v

    @validator('channel')
    def channel_validate_enum(cls, v):
        if v not in ('GATEWAY', 'GATEWAY_AUTOMATED', 'ISSUER', 'ISSUER_AUTOMATED'):
            raise ValueError("must be one of enum values ('GATEWAY', 'GATEWAY_AUTOMATED', 'ISSUER', 'ISSUER_AUTOMATED')")
        return v

    @validator('network')
    def network_validate_enum(cls, v):
        if v not in ('MARQETA', 'DISCOVER', 'MASTERCARD', 'PULSE', 'VISA'):
            raise ValueError("must be one of enum values ('MARQETA', 'DISCOVER', 'MASTERCARD', 'PULSE', 'VISA')")
        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) -> ChargebackResponse:
        """Create an instance of ChargebackResponse 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)
        return _dict

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

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

        _obj = ChargebackResponse.parse_obj({
            "token": obj.get("token"),
            "transaction_token": obj.get("transaction_token"),
            "amount": obj.get("amount"),
            "reason_description": obj.get("reason_description"),
            "reason_code": obj.get("reason_code"),
            "memo": obj.get("memo"),
            "state": obj.get("state"),
            "channel": obj.get("channel"),
            "network": obj.get("network"),
            "network_case_id": obj.get("network_case_id"),
            "credit_user": obj.get("credit_user") if obj.get("credit_user") is not None else False,
            "created_time": obj.get("created_time"),
            "last_modified_time": obj.get("last_modified_time")
        })
        return _obj

