# coding: utf-8

"""
Cashfree Payment Gateway APIs

Cashfree's Payment Gateway APIs provide developers with a streamlined pathway to integrate advanced payment processing capabilities into their applications, platforms and websites.

The version of the OpenAPI document: 2023-08-01
Contact: developers@cashfree.com
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
"""  # noqa: E501

from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from datetime import date, datetime


from cashfree_pg.models.es_order_recon_response_data_inner_order_splits_inner import ESOrderReconResponseDataInnerOrderSplitsInner
from pydantic import validate_arguments, ValidationError, Field, StrictStr, StrictBytes, StrictInt, StrictFloat, StrictBool, field_validator, BaseModel
from typing import Any, Dict, List, Optional, Tuple, Union
from typing_extensions import Annotated

class ESOrderReconResponseDataInner(BaseModel):
    """
    ESOrderReconResponseDataInner
    """
    amount: Optional[Union[StrictFloat, StrictInt]] = None
    settlement_eligibility_time: Optional[StrictStr] = None
    merchant_order_id: Optional[StrictStr] = None
    tx_time: Optional[StrictStr] = None
    settled: Optional[StrictStr] = None
    entity_id: Optional[StrictStr] = None
    merchant_settlement_utr: Optional[StrictStr] = None
    currency: Optional[StrictStr] = None
    sale_type: Optional[StrictStr] = None
    customer_name: Optional[StrictStr] = None
    customer_email: Optional[StrictStr] = None
    customer_phone: Optional[StrictStr] = None
    merchant_vendor_commission: Optional[StrictStr] = None
    split_service_charge: Optional[StrictStr] = None
    split_service_tax: Optional[StrictStr] = None
    pg_service_tax: Optional[StrictStr] = None
    pg_service_charge: Optional[StrictStr] = None
    pg_charge_postpaid: Optional[StrictStr] = None
    merchant_settlement_id: Optional[StrictStr] = None
    added_on: Optional[StrictStr] = None
    tags: Optional[StrictStr] = None
    entity_type: Optional[StrictStr] = None
    settlement_initiated_on: Optional[StrictStr] = None
    settlement_time: Optional[StrictStr] = None
    order_splits: Optional[List[ESOrderReconResponseDataInnerOrderSplitsInner]] = None
    eligible_split_balance: Optional[StrictStr] = None
    __properties = ["amount", "settlement_eligibility_time", "merchant_order_id", "tx_time", "settled", "entity_id", "merchant_settlement_utr", "currency", "sale_type", "customer_name", "customer_email", "customer_phone", "merchant_vendor_commission", "split_service_charge", "split_service_tax", "pg_service_tax", "pg_service_charge", "pg_charge_postpaid", "merchant_settlement_id", "added_on", "tags", "entity_type", "settlement_initiated_on", "settlement_time", "order_splits", "eligible_split_balance"]

    # Updated to Pydantic v2
    """Pydantic configuration"""
    model_config = {
        "populate_by_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) -> ESOrderReconResponseDataInner:
        """Create an instance of ESOrderReconResponseDataInner from a JSON string"""
        return cls.from_dict(json.loads(json_str))
    
    @classmethod
    def from_json_for_one_of(cls, json_str: str) -> ESOrderReconResponseDataInner:
        """Create an instance of ESOrderReconResponseDataInner from a JSON string"""
        temp_dict = json.loads(json_str)
        if "amount, settlement_eligibility_time, merchant_order_id, tx_time, settled, entity_id, merchant_settlement_utr, currency, sale_type, customer_name, customer_email, customer_phone, merchant_vendor_commission, split_service_charge, split_service_tax, pg_service_tax, pg_service_charge, pg_charge_postpaid, merchant_settlement_id, added_on, tags, entity_type, settlement_initiated_on, settlement_time, order_splits, eligible_split_balance" in temp_dict.keys():
            return cls.from_dict(json.loads(json_str))
        return None

    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 each item in order_splits (list)
        _items = []
        if self.order_splits:
            for _item in self.order_splits:
                if _item:
                    _items.append(_item.to_dict())
            _dict['order_splits'] = _items
        return _dict

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

        if not isinstance(obj, dict):
            return ESOrderReconResponseDataInner.parse_obj(obj)

        _obj = ESOrderReconResponseDataInner.parse_obj({
            "amount": obj.get("amount"),
            "settlement_eligibility_time": obj.get("settlement_eligibility_time"),
            "merchant_order_id": obj.get("merchant_order_id"),
            "tx_time": obj.get("tx_time"),
            "settled": obj.get("settled"),
            "entity_id": obj.get("entity_id"),
            "merchant_settlement_utr": obj.get("merchant_settlement_utr"),
            "currency": obj.get("currency"),
            "sale_type": obj.get("sale_type"),
            "customer_name": obj.get("customer_name"),
            "customer_email": obj.get("customer_email"),
            "customer_phone": obj.get("customer_phone"),
            "merchant_vendor_commission": obj.get("merchant_vendor_commission"),
            "split_service_charge": obj.get("split_service_charge"),
            "split_service_tax": obj.get("split_service_tax"),
            "pg_service_tax": obj.get("pg_service_tax"),
            "pg_service_charge": obj.get("pg_service_charge"),
            "pg_charge_postpaid": obj.get("pg_charge_postpaid"),
            "merchant_settlement_id": obj.get("merchant_settlement_id"),
            "added_on": obj.get("added_on"),
            "tags": obj.get("tags"),
            "entity_type": obj.get("entity_type"),
            "settlement_initiated_on": obj.get("settlement_initiated_on"),
            "settlement_time": obj.get("settlement_time"),
            "order_splits": [ESOrderReconResponseDataInnerOrderSplitsInner.from_dict(_item) for _item in obj.get("order_splits")] if obj.get("order_splits") is not None else None,
            "eligible_split_balance": obj.get("eligible_split_balance")
        })
        return _obj


# Pydantic v2: resolve forward references & Annotated types
ESOrderReconResponseDataInner.model_rebuild()

