# 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.link_customer_details_entity import LinkCustomerDetailsEntity
from cashfree_pg.models.link_meta_response_entity import LinkMetaResponseEntity
from cashfree_pg.models.link_notify_entity import LinkNotifyEntity
from cashfree_pg.models.vendor_split import VendorSplit
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 LinkEntity(BaseModel):
    """
    Payment link success creation response object
    """
    cf_link_id: Optional[StrictStr] = None
    link_id: Optional[StrictStr] = None
    link_status: Optional[StrictStr] = None
    link_currency: Optional[StrictStr] = None
    link_amount: Optional[Union[StrictFloat, StrictInt]] = None
    link_amount_paid: Optional[Union[StrictFloat, StrictInt]] = None
    link_partial_payments: Optional[StrictBool] = None
    link_minimum_partial_amount: Optional[Union[StrictFloat, StrictInt]] = None
    link_purpose: Optional[StrictStr] = None
    link_created_at: Optional[StrictStr] = None
    customer_details: Optional[LinkCustomerDetailsEntity] = None
    link_meta: Optional[LinkMetaResponseEntity] = None
    link_url: Optional[StrictStr] = None
    link_expiry_time: Optional[StrictStr] = None
    link_notes: Optional[Dict[str, StrictStr]] = Field(default=None, description="Key-value pair that can be used to store additional information about the entity. Maximum 5 key-value pairs")
    link_auto_reminders: Optional[StrictBool] = None
    link_notify: Optional[LinkNotifyEntity] = None
    link_qrcode: Optional[StrictStr] = Field(default=None, description="Base64 encoded string for payment link. You can scan with camera to open a link in the browser to complete the payment.")
    order_splits: Optional[List[VendorSplit]] = None
    __properties = ["cf_link_id", "link_id", "link_status", "link_currency", "link_amount", "link_amount_paid", "link_partial_payments", "link_minimum_partial_amount", "link_purpose", "link_created_at", "customer_details", "link_meta", "link_url", "link_expiry_time", "link_notes", "link_auto_reminders", "link_notify", "link_qrcode", "order_splits"]

    # 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) -> LinkEntity:
        """Create an instance of LinkEntity from a JSON string"""
        return cls.from_dict(json.loads(json_str))
    
    @classmethod
    def from_json_for_one_of(cls, json_str: str) -> LinkEntity:
        """Create an instance of LinkEntity from a JSON string"""
        temp_dict = json.loads(json_str)
        if "cf_link_id, link_id, link_status, link_currency, link_amount, link_amount_paid, link_partial_payments, link_minimum_partial_amount, link_purpose, link_created_at, customer_details, link_meta, link_url, link_expiry_time, link_notes, link_auto_reminders, link_notify, link_qrcode, order_splits" 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 customer_details
        if self.customer_details:
            _dict['customer_details'] = self.customer_details.to_dict()
        # override the default output from pydantic by calling `to_dict()` of link_meta
        if self.link_meta:
            _dict['link_meta'] = self.link_meta.to_dict()
        # override the default output from pydantic by calling `to_dict()` of link_notify
        if self.link_notify:
            _dict['link_notify'] = self.link_notify.to_dict()
        # 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) -> LinkEntity:
        """Create an instance of LinkEntity from a dict"""
        if obj is None:
            return None

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

        _obj = LinkEntity.parse_obj({
            "cf_link_id": obj.get("cf_link_id"),
            "link_id": obj.get("link_id"),
            "link_status": obj.get("link_status"),
            "link_currency": obj.get("link_currency"),
            "link_amount": obj.get("link_amount"),
            "link_amount_paid": obj.get("link_amount_paid"),
            "link_partial_payments": obj.get("link_partial_payments"),
            "link_minimum_partial_amount": obj.get("link_minimum_partial_amount"),
            "link_purpose": obj.get("link_purpose"),
            "link_created_at": obj.get("link_created_at"),
            "customer_details": LinkCustomerDetailsEntity.from_dict(obj.get("customer_details")) if obj.get("customer_details") is not None else None,
            "link_meta": LinkMetaResponseEntity.from_dict(obj.get("link_meta")) if obj.get("link_meta") is not None else None,
            "link_url": obj.get("link_url"),
            "link_expiry_time": obj.get("link_expiry_time"),
            "link_notes": obj.get("link_notes"),
            "link_auto_reminders": obj.get("link_auto_reminders"),
            "link_notify": LinkNotifyEntity.from_dict(obj.get("link_notify")) if obj.get("link_notify") is not None else None,
            "link_qrcode": obj.get("link_qrcode"),
            "order_splits": [VendorSplit.from_dict(_item) for _item in obj.get("order_splits")] if obj.get("order_splits") is not None else None
        })
        return _obj


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

