# coding: utf-8

"""
    lomi. API

    Payment processing API for francophone West African businesses.

    The version of the OpenAPI document: 1.1.0
    Contact: hello@lomi.africa
    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 pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from uuid import UUID
from typing import Optional, Set
from typing_extensions import Self

class RefundsUpdate(BaseModel):
    """
    Request body for updating a refunds object. Only include fields you want to modify.
    """ # noqa: E501
    amount: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Amount in the smallest currency unit (e.g., cents for USD, same for XOF)")
    fee_amount: Optional[Union[StrictFloat, StrictInt]] = None
    metadata: Optional[Dict[str, Any]] = Field(default=None, description="Set of key-value pairs for storing additional information")
    reason: Optional[StrictStr] = None
    refund_id: Optional[UUID] = Field(default=None, description="Unique identifier (UUID format)")
    refunded_amount: Optional[Union[StrictFloat, StrictInt]] = None
    spi_account_number: Optional[StrictStr] = None
    spi_end2end_id: Optional[UUID] = Field(default=None, description="Unique identifier (UUID format)")
    spi_fund_return_status: Optional[StrictStr] = None
    spi_motif_code: Optional[StrictStr] = None
    spi_rejection_reason: Optional[StrictStr] = None
    spi_retour_date_demande: Optional[StrictStr] = None
    spi_retour_date_irrevocabilite: Optional[StrictStr] = None
    spi_tx_id: Optional[UUID] = Field(default=None, description="Unique identifier (UUID format)")
    status: Optional[StrictStr] = Field(default=None, description="Current status of the resource")
    transaction_id: Optional[UUID] = Field(default=None, description="Unique identifier (UUID format)")
    __properties: ClassVar[List[str]] = ["amount", "fee_amount", "metadata", "reason", "refund_id", "refunded_amount", "spi_account_number", "spi_end2end_id", "spi_fund_return_status", "spi_motif_code", "spi_rejection_reason", "spi_retour_date_demande", "spi_retour_date_irrevocabilite", "spi_tx_id", "status", "transaction_id"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of RefundsUpdate from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of RefundsUpdate from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "amount": obj.get("amount"),
            "fee_amount": obj.get("fee_amount"),
            "metadata": obj.get("metadata"),
            "reason": obj.get("reason"),
            "refund_id": obj.get("refund_id"),
            "refunded_amount": obj.get("refunded_amount"),
            "spi_account_number": obj.get("spi_account_number"),
            "spi_end2end_id": obj.get("spi_end2end_id"),
            "spi_fund_return_status": obj.get("spi_fund_return_status"),
            "spi_motif_code": obj.get("spi_motif_code"),
            "spi_rejection_reason": obj.get("spi_rejection_reason"),
            "spi_retour_date_demande": obj.get("spi_retour_date_demande"),
            "spi_retour_date_irrevocabilite": obj.get("spi_retour_date_irrevocabilite"),
            "spi_tx_id": obj.get("spi_tx_id"),
            "status": obj.get("status"),
            "transaction_id": obj.get("transaction_id")
        })
        return _obj


