# coding: utf-8

"""
    

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

    The version of the OpenAPI document: 
    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
from typing import Any, ClassVar, Dict, List, Optional
from goodmem._generated.models.ocr_input_format import OcrInputFormat
from typing import Optional, Set
from typing_extensions import Self

class OcrDocumentRequest(BaseModel):
    """
    Request body for OCR document processing.
    """ # noqa: E501
    content: Optional[StrictStr] = Field(description="Base64-encoded document bytes")
    format: Optional[OcrInputFormat] = None
    include_raw_json: Optional[StrictBool] = Field(default=None, description="Include raw OCR JSON payload in the response", alias="includeRawJson")
    include_markdown: Optional[StrictBool] = Field(default=None, description="Include markdown rendering in the response", alias="includeMarkdown")
    start_page: Optional[StrictInt] = Field(default=None, description="0-based inclusive start page", alias="startPage")
    end_page: Optional[StrictInt] = Field(default=None, description="0-based inclusive end page", alias="endPage")
    __properties: ClassVar[List[str]] = ["content", "format", "includeRawJson", "includeMarkdown", "startPage", "endPage"]

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "content": obj.get("content"),
            "format": obj.get("format"),
            "includeRawJson": obj.get("includeRawJson"),
            "includeMarkdown": obj.get("includeMarkdown"),
            "startPage": obj.get("startPage"),
            "endPage": obj.get("endPage")
        })
        return _obj


