# 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 pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class Account(BaseModel):
    """
    Account
    """ # noqa: E501
    about: Optional[StrictStr] = Field(default=None, description="Profile about description.")
    account_type: Optional[StrictStr] = Field(default=None, description="Type of account")
    board_count: Optional[StrictInt] = Field(default=None, description="User account board count.<br/>**Note**: Board count on user account level may differ from counts found elsewhere due to attribution of collaborative Boards.")
    business_name: Optional[StrictStr] = None
    follower_count: Optional[StrictInt] = Field(default=None, description="User account follower count.")
    following_count: Optional[StrictInt] = Field(default=None, description="User account following count.")
    id: Optional[Annotated[str, Field(strict=True)]] = Field(default=None, description="User account ID.")
    monthly_views: Optional[StrictInt] = Field(default=None, description="User account monthly views.")
    pin_count: Optional[StrictInt] = Field(default=None, description="User account pin count. This includes both created and saved pins.")
    profile_image: Optional[StrictStr] = None
    username: Optional[StrictStr] = None
    website_url: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["about", "account_type", "board_count", "business_name", "follower_count", "following_count", "id", "monthly_views", "pin_count", "profile_image", "username", "website_url"]

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

        if value not in set(['PINNER', 'BUSINESS']):
            raise ValueError("must be one of enum values ('PINNER', 'BUSINESS')")
        return value

    @field_validator('id')
    def id_validate_regular_expression(cls, value):
        """Validates the regular expression"""
        if value is None:
            return value

        if not re.match(r"^\d+$", value):
            raise ValueError(r"must validate the regular expression /^\d+$/")
        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 Account 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.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        """
        excluded_fields: Set[str] = set([
            "board_count",
            "follower_count",
            "following_count",
            "monthly_views",
            "pin_count",
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # set to None if board_count (nullable) is None
        # and model_fields_set contains the field
        if self.board_count is None and "board_count" in self.model_fields_set:
            _dict['board_count'] = None

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "about": obj.get("about"),
            "account_type": obj.get("account_type"),
            "board_count": obj.get("board_count"),
            "business_name": obj.get("business_name"),
            "follower_count": obj.get("follower_count"),
            "following_count": obj.get("following_count"),
            "id": obj.get("id"),
            "monthly_views": obj.get("monthly_views"),
            "pin_count": obj.get("pin_count"),
            "profile_image": obj.get("profile_image"),
            "username": obj.get("username"),
            "website_url": obj.get("website_url")
        })
        return _obj


