# 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, StrictFloat, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing import Optional, Set
from typing_extensions import Self

class CustomerList(BaseModel):
    """
    CustomerList
    """ # noqa: E501
    ad_account_id: Optional[StrictStr] = Field(default=None, description="Associated ad account ID.")
    created_time: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Creation time. Unix timestamp in seconds.")
    exceptions: Optional[Dict[str, Any]] = Field(default=None, description="Customer list errors")
    id: Optional[StrictStr] = Field(default=None, description="Customer list ID.")
    name: Optional[StrictStr] = Field(default=None, description="Customer list name.")
    num_batches: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Total number of list updates.  List creation counts as one batch. Each <a href=\"/docs/redoc/#operation/ads_v3_customer_list_add_handler_PUT\">Append</a> or <a href=\"/docs/redoc/#operation/ads_v3_customer_list_remove_handler_PUT\">Remove API</a> call counts as another. List creation via the Ads Manager UI could result in more than one batch since the UI breaks up large lists.")
    num_removed_user_records: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of removed user records. In a <a href=\"/docs/redoc/#operation/ads_v3_customer_list_remove_handler_PUT\">Remove API</a> call, this counter increases even if the user is not found in the list.")
    num_uploaded_user_records: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Number of uploaded user records. In an <a href=\"/docs/redoc/#operation/ads_v3_customer_list_add_handler_PUT\">Append API</a> call, this counter increases even if the uploaded user is already in the list.")
    status: Optional[StrictStr] = Field(default=None, description="Customer list status. TOO_SMALL - the list has less than 100 Pinterest users.")
    type: Optional[StrictStr] = Field(default=None, description="Always \"customerlist\".")
    updated_time: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Last update time. Unix timestamp in seconds.")
    __properties: ClassVar[List[str]] = ["ad_account_id", "created_time", "exceptions", "id", "name", "num_batches", "num_removed_user_records", "num_uploaded_user_records", "status", "type", "updated_time"]

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

        if value not in set(['PROCESSING', 'READY', 'TOO_SMALL', 'UPLOADING']):
            raise ValueError("must be one of enum values ('PROCESSING', 'READY', 'TOO_SMALL', 'UPLOADING')")
        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 CustomerList 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,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "ad_account_id": obj.get("ad_account_id"),
            "created_time": obj.get("created_time"),
            "exceptions": obj.get("exceptions"),
            "id": obj.get("id"),
            "name": obj.get("name"),
            "num_batches": obj.get("num_batches"),
            "num_removed_user_records": obj.get("num_removed_user_records"),
            "num_uploaded_user_records": obj.get("num_uploaded_user_records"),
            "status": obj.get("status"),
            "type": obj.get("type"),
            "updated_time": obj.get("updated_time")
        })
        return _obj


