# 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
from pydantic import BaseModel, StrictBool, StrictInt, StrictStr, validator
from marqeta_client.models.airline import Airline
from marqeta_client.models.transit import Transit

class TransactionMetadata(BaseModel):
    """
    TransactionMetadata
    """
    transaction_category: Optional[StrictStr] = None
    payment_channel: Optional[StrictStr] = None
    cross_border_transaction: Optional[StrictBool] = False
    authorization_life_cycle: Optional[StrictInt] = None
    is_lodging_auto_rental: Optional[StrictBool] = False
    is_deferred_authorization: Optional[StrictBool] = None
    lodging_auto_rental_start_date: Optional[datetime] = None
    transit: Optional[Transit] = None
    airline: Optional[Airline] = None
    moto_indicator: Optional[StrictStr] = None
    one_leg_out: Optional[StrictBool] = None
    __properties = ["transaction_category", "payment_channel", "cross_border_transaction", "authorization_life_cycle", "is_lodging_auto_rental", "is_deferred_authorization", "lodging_auto_rental_start_date", "transit", "airline", "moto_indicator", "one_leg_out"]

    @validator('transaction_category')
    def transaction_category_validate_enum(cls, v):
        if v is None:
            return v

        if v not in ('RETAIL_SALE', 'BILL_PAY', 'HOTEL', 'HEALTH_CARE', 'RESTAURANT', 'AUTO_RENTAL', 'AIRLINE', 'PAYMENT', 'HOSPITALIZATION_COLLEGE', 'PHONE_MAIL_ECOMMERCE', 'ATM', 'TRANSIT'):
            raise ValueError("must be one of enum values ('RETAIL_SALE', 'BILL_PAY', 'HOTEL', 'HEALTH_CARE', 'RESTAURANT', 'AUTO_RENTAL', 'AIRLINE', 'PAYMENT', 'HOSPITALIZATION_COLLEGE', 'PHONE_MAIL_ECOMMERCE', 'ATM', 'TRANSIT')")
        return v

    @validator('payment_channel')
    def payment_channel_validate_enum(cls, v):
        if v is None:
            return v

        if v not in ('OTHER', 'ATM', 'ECOMMERCE', 'MAIL', 'PHONE', 'MOTO'):
            raise ValueError("must be one of enum values ('OTHER', 'ATM', 'ECOMMERCE', 'MAIL', 'PHONE', 'MOTO')")
        return v

    @validator('moto_indicator')
    def moto_indicator_validate_enum(cls, v):
        if v is None:
            return v

        if v not in ('UNKNOWN', 'MANUAL', 'RECURRING', 'INSTALLMENT', 'OTHERS'):
            raise ValueError("must be one of enum values ('UNKNOWN', 'MANUAL', 'RECURRING', 'INSTALLMENT', 'OTHERS')")
        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) -> TransactionMetadata:
        """Create an instance of TransactionMetadata 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 transit
        if self.transit:
            _dict['transit'] = self.transit.to_dict()
        # override the default output from pydantic by calling `to_dict()` of airline
        if self.airline:
            _dict['airline'] = self.airline.to_dict()
        return _dict

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

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

        _obj = TransactionMetadata.parse_obj({
            "transaction_category": obj.get("transaction_category"),
            "payment_channel": obj.get("payment_channel"),
            "cross_border_transaction": obj.get("cross_border_transaction") if obj.get("cross_border_transaction") is not None else False,
            "authorization_life_cycle": obj.get("authorization_life_cycle"),
            "is_lodging_auto_rental": obj.get("is_lodging_auto_rental") if obj.get("is_lodging_auto_rental") is not None else False,
            "is_deferred_authorization": obj.get("is_deferred_authorization"),
            "lodging_auto_rental_start_date": obj.get("lodging_auto_rental_start_date"),
            "transit": Transit.from_dict(obj.get("transit")) if obj.get("transit") is not None else None,
            "airline": Airline.from_dict(obj.get("airline")) if obj.get("airline") is not None else None,
            "moto_indicator": obj.get("moto_indicator"),
            "one_leg_out": obj.get("one_leg_out")
        })
        return _obj

