# coding: utf-8

"""
    Fiscal document service API

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: v1
    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, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from cloudbeds_fiscal_document.models.creation_method import CreationMethod
from typing import Optional, Set
from typing_extensions import Self

class GetCreditNotePreviewRequest(BaseModel):
    """
    GetCreditNotePreviewRequest
    """ # noqa: E501
    sequence_id: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=None, alias="sequenceId")
    invoice_id: Annotated[int, Field(strict=True, ge=1)] = Field(alias="invoiceId")
    reason: Optional[StrictStr] = None
    user_id: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, alias="userId")
    method: CreationMethod
    transaction_ids: Optional[List[StrictInt]] = Field(default=None, description="Include transactions with the specified IDs (deprecated, use `includeTransactionIds` instead)", alias="transactionIds")
    folio_ids: Optional[List[StrictInt]] = Field(default=None, description="Include all transactions from the specified folio IDs", alias="folioIds")
    exclude_transaction_ids: Optional[List[StrictInt]] = Field(default=None, description="Exclude transactions with the specified IDs", alias="excludeTransactionIds")
    include_transaction_ids: Optional[List[StrictInt]] = Field(default=None, description="Include transactions with the specified IDs", alias="includeTransactionIds")
    __properties: ClassVar[List[str]] = ["sequenceId", "invoiceId", "reason", "userId", "method", "transactionIds", "folioIds", "excludeTransactionIds", "includeTransactionIds"]

    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 GetCreditNotePreviewRequest 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 sequence_id (nullable) is None
        # and model_fields_set contains the field
        if self.sequence_id is None and "sequence_id" in self.model_fields_set:
            _dict['sequenceId'] = None

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "sequenceId": obj.get("sequenceId"),
            "invoiceId": obj.get("invoiceId"),
            "reason": obj.get("reason"),
            "userId": obj.get("userId"),
            "method": obj.get("method"),
            "transactionIds": obj.get("transactionIds"),
            "folioIds": obj.get("folioIds"),
            "excludeTransactionIds": obj.get("excludeTransactionIds"),
            "includeTransactionIds": obj.get("includeTransactionIds")
        })
        return _obj


