# coding: utf-8

"""
    WordLift API

    WordLift API

    The version of the OpenAPI document: 1.0
    Contact: hello@wordlift.io
    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, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from wordlift_client.models.automation_readiness import AutomationReadiness
from wordlift_client.models.content_freshness import ContentFreshness
from wordlift_client.models.content_structure import ContentStructure
from wordlift_client.models.html_semantics import HtmlSemantics
from wordlift_client.models.image_accessibility import ImageAccessibility
from wordlift_client.models.internal_linking import InternalLinking
from wordlift_client.models.js_rendering import JsRendering
from wordlift_client.models.quick_wins_result import QuickWinsResult
from wordlift_client.models.seo_fundamentals import SeoFundamentals
from wordlift_client.models.site_files import SiteFiles
from wordlift_client.models.structured_data import StructuredData
from typing import Optional, Set
from typing_extensions import Self

class AuditData(BaseModel):
    """
    AuditData
    """ # noqa: E501
    url: Optional[StrictStr] = Field(default=None, description="The audited URL (may include trailing slash)")
    domain: Optional[StrictStr] = Field(default=None, description="The base domain of the audited URL")
    timestamp: Optional[datetime] = Field(default=None, description="ISO 8601 timestamp of when the audit was performed")
    overall_score: Optional[Annotated[int, Field(le=100, strict=True, ge=0)]] = Field(default=None, description="Overall SEO and AI-readiness score (0-100)", alias="overallScore")
    score: Optional[Annotated[int, Field(le=100, strict=True, ge=0)]] = Field(default=None, description="Legacy field - same as overallScore")
    summary: Optional[StrictStr] = Field(default=None, description="High-level summary of the audit findings in markdown format")
    site_files: Optional[SiteFiles] = Field(default=None, alias="siteFiles")
    seo_fundamentals: Optional[SeoFundamentals] = Field(default=None, alias="seoFundamentals")
    structured_data: Optional[StructuredData] = Field(default=None, alias="structuredData")
    content_structure: Optional[ContentStructure] = Field(default=None, alias="contentStructure")
    image_accessibility: Optional[ImageAccessibility] = Field(default=None, alias="imageAccessibility")
    html_semantics: Optional[HtmlSemantics] = Field(default=None, alias="htmlSemantics")
    content_freshness: Optional[ContentFreshness] = Field(default=None, alias="contentFreshness")
    internal_linking: Optional[InternalLinking] = Field(default=None, alias="internalLinking")
    automation_readiness: Optional[AutomationReadiness] = Field(default=None, alias="automationReadiness")
    js_rendering: Optional[JsRendering] = Field(default=None, alias="jsRendering")
    quick_wins: Optional[QuickWinsResult] = Field(default=None, alias="quickWins")
    status: Optional[StrictStr] = Field(default=None, description="Status of the audit process")
    account_id: Optional[StrictInt] = Field(default=None, description="Account ID associated with the audit", alias="accountId")
    account_url: Optional[StrictStr] = Field(default=None, description="Account URL associated with the audit", alias="accountUrl")
    __properties: ClassVar[List[str]] = ["url", "domain", "timestamp", "overallScore", "score", "summary", "siteFiles", "seoFundamentals", "structuredData", "contentStructure", "imageAccessibility", "htmlSemantics", "contentFreshness", "internalLinking", "automationReadiness", "jsRendering", "quickWins", "status", "accountId", "accountUrl"]

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

        if value not in set(['completed', 'pending', 'failed']):
            raise ValueError("must be one of enum values ('completed', 'pending', 'failed')")
        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 AuditData 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 site_files
        if self.site_files:
            _dict['siteFiles'] = self.site_files.to_dict()
        # override the default output from pydantic by calling `to_dict()` of seo_fundamentals
        if self.seo_fundamentals:
            _dict['seoFundamentals'] = self.seo_fundamentals.to_dict()
        # override the default output from pydantic by calling `to_dict()` of structured_data
        if self.structured_data:
            _dict['structuredData'] = self.structured_data.to_dict()
        # override the default output from pydantic by calling `to_dict()` of content_structure
        if self.content_structure:
            _dict['contentStructure'] = self.content_structure.to_dict()
        # override the default output from pydantic by calling `to_dict()` of image_accessibility
        if self.image_accessibility:
            _dict['imageAccessibility'] = self.image_accessibility.to_dict()
        # override the default output from pydantic by calling `to_dict()` of html_semantics
        if self.html_semantics:
            _dict['htmlSemantics'] = self.html_semantics.to_dict()
        # override the default output from pydantic by calling `to_dict()` of content_freshness
        if self.content_freshness:
            _dict['contentFreshness'] = self.content_freshness.to_dict()
        # override the default output from pydantic by calling `to_dict()` of internal_linking
        if self.internal_linking:
            _dict['internalLinking'] = self.internal_linking.to_dict()
        # override the default output from pydantic by calling `to_dict()` of automation_readiness
        if self.automation_readiness:
            _dict['automationReadiness'] = self.automation_readiness.to_dict()
        # override the default output from pydantic by calling `to_dict()` of js_rendering
        if self.js_rendering:
            _dict['jsRendering'] = self.js_rendering.to_dict()
        # override the default output from pydantic by calling `to_dict()` of quick_wins
        if self.quick_wins:
            _dict['quickWins'] = self.quick_wins.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "url": obj.get("url"),
            "domain": obj.get("domain"),
            "timestamp": obj.get("timestamp"),
            "overallScore": obj.get("overallScore"),
            "score": obj.get("score"),
            "summary": obj.get("summary"),
            "siteFiles": SiteFiles.from_dict(obj["siteFiles"]) if obj.get("siteFiles") is not None else None,
            "seoFundamentals": SeoFundamentals.from_dict(obj["seoFundamentals"]) if obj.get("seoFundamentals") is not None else None,
            "structuredData": StructuredData.from_dict(obj["structuredData"]) if obj.get("structuredData") is not None else None,
            "contentStructure": ContentStructure.from_dict(obj["contentStructure"]) if obj.get("contentStructure") is not None else None,
            "imageAccessibility": ImageAccessibility.from_dict(obj["imageAccessibility"]) if obj.get("imageAccessibility") is not None else None,
            "htmlSemantics": HtmlSemantics.from_dict(obj["htmlSemantics"]) if obj.get("htmlSemantics") is not None else None,
            "contentFreshness": ContentFreshness.from_dict(obj["contentFreshness"]) if obj.get("contentFreshness") is not None else None,
            "internalLinking": InternalLinking.from_dict(obj["internalLinking"]) if obj.get("internalLinking") is not None else None,
            "automationReadiness": AutomationReadiness.from_dict(obj["automationReadiness"]) if obj.get("automationReadiness") is not None else None,
            "jsRendering": JsRendering.from_dict(obj["jsRendering"]) if obj.get("jsRendering") is not None else None,
            "quickWins": QuickWinsResult.from_dict(obj["quickWins"]) if obj.get("quickWins") is not None else None,
            "status": obj.get("status"),
            "accountId": obj.get("accountId"),
            "accountUrl": obj.get("accountUrl")
        })
        return _obj


