# 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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, 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 Transactions(BaseModel):
    """
    transactions resource object
    """ # noqa: E501
    checkout_session_id: Optional[UUID] = Field(default=None, description="Unique identifier (UUID format)")
    created_at: Optional[datetime] = Field(default=None, description="ISO 8601 datetime")
    currency_code: Optional[StrictStr] = Field(default=None, description="Three-letter ISO currency code (e.g., XOF, USD, EUR)")
    customer_id: Optional[UUID] = Field(default=None, description="Unique identifier (UUID format)")
    description: Optional[StrictStr] = None
    discount_amount: Optional[Union[StrictFloat, StrictInt]] = None
    environment: Optional[StrictStr] = None
    fee_amount: Optional[Union[StrictFloat, StrictInt]] = None
    fee_structure_id: Optional[UUID] = Field(default=None, description="Unique identifier (UUID format)")
    gross_amount: Optional[Union[StrictFloat, StrictInt]] = None
    is_bnpl: Optional[StrictBool] = None
    is_pos: Optional[StrictBool] = None
    metadata: Optional[Dict[str, Any]] = Field(default=None, description="Set of key-value pairs for storing additional information")
    net_amount: Optional[Union[StrictFloat, StrictInt]] = None
    organization_id: Optional[UUID] = Field(default=None, description="Unique identifier (UUID format)")
    payment_method_code: Optional[StrictStr] = None
    price_id: Optional[UUID] = Field(default=None, description="Unique identifier (UUID format)")
    product_id: Optional[UUID] = Field(default=None, description="Unique identifier (UUID format)")
    provider_code: Optional[StrictStr] = None
    quantity: Optional[Union[StrictFloat, StrictInt]] = None
    spi_account_number: Optional[StrictStr] = None
    spi_bulk_instruction_id: Optional[UUID] = Field(default=None, description="Unique identifier (UUID format)")
    spi_date_envoi: Optional[StrictStr] = None
    spi_date_irrevocabilite: Optional[StrictStr] = None
    spi_discount_amount: Optional[Union[StrictFloat, StrictInt]] = None
    spi_discount_rate: Optional[Union[StrictFloat, StrictInt]] = None
    spi_end2end_id: Optional[UUID] = Field(default=None, description="Unique identifier (UUID format)")
    spi_payment_category: Optional[StrictStr] = None
    spi_payment_flow_type: Optional[StrictStr] = None
    spi_payment_status: Optional[StrictStr] = None
    spi_rejection_reason: 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")
    subscription_id: Optional[UUID] = Field(default=None, description="Unique identifier (UUID format)")
    transaction_id: Optional[UUID] = Field(default=None, description="Unique identifier (UUID format)")
    transaction_type: Optional[StrictStr] = None
    updated_at: Optional[datetime] = Field(default=None, description="ISO 8601 datetime")
    __properties: ClassVar[List[str]] = ["checkout_session_id", "created_at", "currency_code", "customer_id", "description", "discount_amount", "environment", "fee_amount", "fee_structure_id", "gross_amount", "is_bnpl", "is_pos", "metadata", "net_amount", "organization_id", "payment_method_code", "price_id", "product_id", "provider_code", "quantity", "spi_account_number", "spi_bulk_instruction_id", "spi_date_envoi", "spi_date_irrevocabilite", "spi_discount_amount", "spi_discount_rate", "spi_end2end_id", "spi_payment_category", "spi_payment_flow_type", "spi_payment_status", "spi_rejection_reason", "spi_tx_id", "status", "subscription_id", "transaction_id", "transaction_type", "updated_at"]

    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 Transactions 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.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        """
        excluded_fields: Set[str] = set([
            "created_at",
            "transaction_id",
            "updated_at",
        ])

        _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 Transactions from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "checkout_session_id": obj.get("checkout_session_id"),
            "created_at": obj.get("created_at"),
            "currency_code": obj.get("currency_code"),
            "customer_id": obj.get("customer_id"),
            "description": obj.get("description"),
            "discount_amount": obj.get("discount_amount"),
            "environment": obj.get("environment"),
            "fee_amount": obj.get("fee_amount"),
            "fee_structure_id": obj.get("fee_structure_id"),
            "gross_amount": obj.get("gross_amount"),
            "is_bnpl": obj.get("is_bnpl"),
            "is_pos": obj.get("is_pos"),
            "metadata": obj.get("metadata"),
            "net_amount": obj.get("net_amount"),
            "organization_id": obj.get("organization_id"),
            "payment_method_code": obj.get("payment_method_code"),
            "price_id": obj.get("price_id"),
            "product_id": obj.get("product_id"),
            "provider_code": obj.get("provider_code"),
            "quantity": obj.get("quantity"),
            "spi_account_number": obj.get("spi_account_number"),
            "spi_bulk_instruction_id": obj.get("spi_bulk_instruction_id"),
            "spi_date_envoi": obj.get("spi_date_envoi"),
            "spi_date_irrevocabilite": obj.get("spi_date_irrevocabilite"),
            "spi_discount_amount": obj.get("spi_discount_amount"),
            "spi_discount_rate": obj.get("spi_discount_rate"),
            "spi_end2end_id": obj.get("spi_end2end_id"),
            "spi_payment_category": obj.get("spi_payment_category"),
            "spi_payment_flow_type": obj.get("spi_payment_flow_type"),
            "spi_payment_status": obj.get("spi_payment_status"),
            "spi_rejection_reason": obj.get("spi_rejection_reason"),
            "spi_tx_id": obj.get("spi_tx_id"),
            "status": obj.get("status"),
            "subscription_id": obj.get("subscription_id"),
            "transaction_id": obj.get("transaction_id"),
            "transaction_type": obj.get("transaction_type"),
            "updated_at": obj.get("updated_at")
        })
        return _obj


