# coding: utf-8

"""
    BeeL Public API

    Public invoicing API for self-employed professionals in Spain with full VeriFactu support.  **Authentication:** This API uses **API Keys** for authentication. Endpoints are designed for external integrations, automation, and programmatic access.  For browser-based authentication, use the Private API (with Session Cookies).  **Key Features:** - VeriFactu regulatory compliance - Complete invoice management (standard, corrective, simplified) - Customer management - Tax and invoice series configuration - PDF generation - Email sending - Duplicate prevention (idempotency)  **Idempotency:** Creation endpoints (POST) support the `Idempotency-Key` header to prevent duplicates in case of retries.  **Identifiers:** - All resources use UUIDs for technical identification - Invoice numbers are human-readable and searchable 

    The version of the OpenAPI document: 1.0.0
    Contact: it@beel.es
    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, StrictBool, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class CustomerValidationMetadata(BaseModel):
    """
    Metadata about the validation operation. Compatible with bulk JSON, CSV import and Holded Excel import. 
    """ # noqa: E501
    total_customers: StrictInt = Field(description="Total number of customers submitted")
    is_dry_run: StrictBool = Field(description="Whether it was validation (true) or import (false)")
    processing_time_ms: StrictInt = Field(description="Processing time in milliseconds")
    source_type: StrictStr = Field(description="Data source type: - BULK_JSON: Data sent as JSON to bulk endpoint - CSV_IMPORT: Data parsed from CSV file - HOLDED_EXCEL: Data parsed from Holded Excel file ")
    filename: Optional[StrictStr] = Field(default=None, description="File name (CSV or Excel depending on source_type)")
    file_size_bytes: Optional[StrictInt] = Field(default=None, description="File size in bytes")
    total_rows: Optional[StrictInt] = Field(default=None, description="Total file rows excluding headers")
    __properties: ClassVar[List[str]] = ["total_customers", "is_dry_run", "processing_time_ms", "source_type", "filename", "file_size_bytes", "total_rows"]

    @field_validator('source_type')
    def source_type_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['BULK_JSON', 'CSV_IMPORT', 'HOLDED_EXCEL']):
            raise ValueError("must be one of enum values ('BULK_JSON', 'CSV_IMPORT', 'HOLDED_EXCEL')")
        return value

    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 CustomerValidationMetadata 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,
        )
        # set to None if filename (nullable) is None
        # and model_fields_set contains the field
        if self.filename is None and "filename" in self.model_fields_set:
            _dict['filename'] = None

        # set to None if file_size_bytes (nullable) is None
        # and model_fields_set contains the field
        if self.file_size_bytes is None and "file_size_bytes" in self.model_fields_set:
            _dict['file_size_bytes'] = None

        # set to None if total_rows (nullable) is None
        # and model_fields_set contains the field
        if self.total_rows is None and "total_rows" in self.model_fields_set:
            _dict['total_rows'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "total_customers": obj.get("total_customers"),
            "is_dry_run": obj.get("is_dry_run"),
            "processing_time_ms": obj.get("processing_time_ms"),
            "source_type": obj.get("source_type"),
            "filename": obj.get("filename"),
            "file_size_bytes": obj.get("file_size_bytes"),
            "total_rows": obj.get("total_rows")
        })
        return _obj


