# coding: utf-8

"""
    Pinterest REST API

    Pinterest's REST API

    The version of the OpenAPI document: 5.23.0
    Contact: blah+oapicf@cliffano.com
    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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from pinterestsdk.models.catalogs_feed_ingestion_details import CatalogsFeedIngestionDetails
from pinterestsdk.models.catalogs_feed_processing_status import CatalogsFeedProcessingStatus
from pinterestsdk.models.catalogs_feed_product_counts import CatalogsFeedProductCounts
from pinterestsdk.models.catalogs_feed_validation_details import CatalogsFeedValidationDetails
from pinterestsdk.models.catalogs_feed_video_counts import CatalogsFeedVideoCounts
from typing import Optional, Set
from typing_extensions import Self

class CatalogsFeedProcessingResult(BaseModel):
    """
    CatalogsFeedProcessingResult
    """ # noqa: E501
    created_at: datetime
    id: StrictStr
    updated_at: datetime
    ingestion_details: CatalogsFeedIngestionDetails
    product_counts: Optional[CatalogsFeedProductCounts]
    status: CatalogsFeedProcessingStatus
    validation_details: CatalogsFeedValidationDetails
    video_counts: Optional[CatalogsFeedVideoCounts] = None
    __properties: ClassVar[List[str]] = ["created_at", "id", "updated_at", "ingestion_details", "product_counts", "status", "validation_details", "video_counts"]

    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 CatalogsFeedProcessingResult 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 ingestion_details
        if self.ingestion_details:
            _dict['ingestion_details'] = self.ingestion_details.to_dict()
        # override the default output from pydantic by calling `to_dict()` of product_counts
        if self.product_counts:
            _dict['product_counts'] = self.product_counts.to_dict()
        # override the default output from pydantic by calling `to_dict()` of validation_details
        if self.validation_details:
            _dict['validation_details'] = self.validation_details.to_dict()
        # override the default output from pydantic by calling `to_dict()` of video_counts
        if self.video_counts:
            _dict['video_counts'] = self.video_counts.to_dict()
        # set to None if product_counts (nullable) is None
        # and model_fields_set contains the field
        if self.product_counts is None and "product_counts" in self.model_fields_set:
            _dict['product_counts'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "created_at": obj.get("created_at"),
            "id": obj.get("id"),
            "updated_at": obj.get("updated_at"),
            "ingestion_details": CatalogsFeedIngestionDetails.from_dict(obj["ingestion_details"]) if obj.get("ingestion_details") is not None else None,
            "product_counts": CatalogsFeedProductCounts.from_dict(obj["product_counts"]) if obj.get("product_counts") is not None else None,
            "status": obj.get("status"),
            "validation_details": CatalogsFeedValidationDetails.from_dict(obj["validation_details"]) if obj.get("validation_details") is not None else None,
            "video_counts": CatalogsFeedVideoCounts.from_dict(obj["video_counts"]) if obj.get("video_counts") is not None else None
        })
        return _obj


