# 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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class VeriFactuConfiguration(BaseModel):
    """
    VeriFactuConfiguration
    """ # noqa: E501
    enabled: StrictBool = Field(description="Whether VeriFactu is enabled for this user. When enabled, the user can submit invoices to AEAT. Freelancers who don't need to submit invoices to AEAT can leave it disabled. ")
    apply_by_default: StrictBool = Field(description="Whether VeriFactu should be automatically applied to new invoices. Requires 'enabled' to be true. ")
    nif_status: Optional[StrictStr] = Field(default=None, description="VeriFactu registration status (can be null if VeriFactu was never enabled): - PENDING: Initial registration in progress - ACTIVATED: NIF validated and user created in the corresponding environment - DEACTIVATED: Deactivated (data retained for 30 days) - ERROR: Some step of the process failed ")
    nif_registered_at: Optional[datetime] = Field(default=None, description="Successful activation date in VeriFactu production")
    __properties: ClassVar[List[str]] = ["enabled", "apply_by_default", "nif_status", "nif_registered_at"]

    @field_validator('nif_status')
    def nif_status_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['PENDING', 'ACTIVATED', 'DEACTIVATED', 'ERROR']):
            raise ValueError("must be one of enum values ('PENDING', 'ACTIVATED', 'DEACTIVATED', 'ERROR')")
        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 VeriFactuConfiguration 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 nif_status (nullable) is None
        # and model_fields_set contains the field
        if self.nif_status is None and "nif_status" in self.model_fields_set:
            _dict['nif_status'] = None

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

        return _dict

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

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

        _obj = cls.model_validate({
            "enabled": obj.get("enabled") if obj.get("enabled") is not None else False,
            "apply_by_default": obj.get("apply_by_default") if obj.get("apply_by_default") is not None else False,
            "nif_status": obj.get("nif_status"),
            "nif_registered_at": obj.get("nif_registered_at")
        })
        return _obj


