# coding: utf-8

"""
    FlowHunt

    FlowHunt API

    The version of the OpenAPI document: 2.0.0
    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 flowhunt.models.app_url_output import AppUrlOutput
from flowhunt.models.task_status import TaskStatus
from typing import Optional, Set
from typing_extensions import Self

class ScreenshotResponse(BaseModel):
    """
    ScreenshotResponse
    """ # noqa: E501
    id: StrictStr = Field(description="Task ID")
    status: TaskStatus = Field(description="Task status")
    result: Optional[StrictStr] = None
    error_message: Optional[StrictStr] = None
    original_size_url: Optional[AppUrlOutput] = None
    thumbnail_url: Optional[AppUrlOutput] = None
    original_size_url_full_page: Optional[AppUrlOutput] = None
    thumbnail_url_full_page: Optional[AppUrlOutput] = None
    timestamp: Optional[StrictInt] = None
    domain_id: Optional[StrictStr] = None
    url_id: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["id", "status", "result", "error_message", "original_size_url", "thumbnail_url", "original_size_url_full_page", "thumbnail_url_full_page", "timestamp", "domain_id", "url_id"]

    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 ScreenshotResponse 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,
        )
        # override the default output from pydantic by calling `to_dict()` of original_size_url
        if self.original_size_url:
            _dict['original_size_url'] = self.original_size_url.to_dict()
        # override the default output from pydantic by calling `to_dict()` of thumbnail_url
        if self.thumbnail_url:
            _dict['thumbnail_url'] = self.thumbnail_url.to_dict()
        # override the default output from pydantic by calling `to_dict()` of original_size_url_full_page
        if self.original_size_url_full_page:
            _dict['original_size_url_full_page'] = self.original_size_url_full_page.to_dict()
        # override the default output from pydantic by calling `to_dict()` of thumbnail_url_full_page
        if self.thumbnail_url_full_page:
            _dict['thumbnail_url_full_page'] = self.thumbnail_url_full_page.to_dict()
        # set to None if result (nullable) is None
        # and model_fields_set contains the field
        if self.result is None and "result" in self.model_fields_set:
            _dict['result'] = None

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "status": obj.get("status"),
            "result": obj.get("result"),
            "error_message": obj.get("error_message"),
            "original_size_url": AppUrlOutput.from_dict(obj["original_size_url"]) if obj.get("original_size_url") is not None else None,
            "thumbnail_url": AppUrlOutput.from_dict(obj["thumbnail_url"]) if obj.get("thumbnail_url") is not None else None,
            "original_size_url_full_page": AppUrlOutput.from_dict(obj["original_size_url_full_page"]) if obj.get("original_size_url_full_page") is not None else None,
            "thumbnail_url_full_page": AppUrlOutput.from_dict(obj["thumbnail_url_full_page"]) if obj.get("thumbnail_url_full_page") is not None else None,
            "timestamp": obj.get("timestamp"),
            "domain_id": obj.get("domain_id"),
            "url_id": obj.get("url_id")
        })
        return _obj


