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

class ConversionEventsUserDataProperties(BaseModel):
    """
    ConversionEventsUserDataProperties
    """ # noqa: E501
    click_id: Optional[StrictStr] = Field(default=None, description="The unique identifier stored in _epik cookie on your domain or &epik= query parameter in the URL. We highly recommend this on checkout events at least. It may improve reporting performance such as ROAS/CPA.")
    client_ip_address: Optional[StrictStr] = Field(default=None, description="The user's IP address, which can be either in IPv4 or IPv6 format. Used for matching. We highly recommend this for all events. It may improve reporting performance such as ROAS/CPA.")
    client_user_agent: Optional[StrictStr] = Field(default=None, description="The user agent string of the user's web browser. We highly recommend this for all events. It may improve reporting performance such as ROAS/CPA.")
    country: Optional[List[StrictStr]] = Field(default=None, description="Sha256 hashes of two-character ISO-3166 country code indicating the user's country, in lowercase. The string should be in the UTF-8 format.")
    ct: Optional[List[StrictStr]] = Field(default=None, description="Sha256 hashes of user's city, in lowercase, and without spaces or punctuation. User residency city (mostly billing). The string should be in the UTF-8 format.")
    db: Optional[List[StrictStr]] = Field(default=None, description="Sha256 hashes of user's date of birthday, given as year, month, and day. The string should be in the UTF-8 format.")
    em: Optional[List[StrictStr]] = Field(default=None, description="Sha256 hashes of lowercase version of user's email addresses. Used for matching. We highly recommend this on checkout events at least. It may improve reporting performance such as ROAS/CPA. The string should be in the UTF-8 format.")
    external_id: Optional[List[StrictStr]] = Field(default=None, description="Sha256 hashes of the unique id from the advertiser that identifies a user in their space, e.g. user id, loyalty id, etc. We highly recommend this on all events. It may improve reporting performance such as ROAS/CPA. The string should be in the UTF-8 format.")
    fn: Optional[List[StrictStr]] = Field(default=None, description="Sha256 hashes of user's first name, in lowercase. We highly recommend this on checkout events at least. It may improve reporting performance such as ROAS/CPA. The string should be in the UTF-8 format.")
    ge: Optional[List[StrictStr]] = Field(default=None, description="Sha256 hashes of user's gender, in lowercase. Either \"f\" or \"m\" or \"n\" for non-binary gender. The string should be in the UTF-8 format.")
    hashed_maids: Optional[List[StrictStr]] = Field(default=None, description="Sha256 hashes of user's \"Google Advertising IDs\" (GAIDs) or \"Apple's Identifier for Advertisers\" (IDFAs). Used for matching. We highly recommend this on checkout events at least. It may improve reporting performance such as ROAS/CPA. The string should be in the UTF-8 format.")
    ln: Optional[List[StrictStr]] = Field(default=None, description="Sha256 hashes of user's last name, in lowercase. We highly recommend this on checkout events at least. It may improve reporting performance such as ROAS/CPA. The string should be in the UTF-8 format.")
    partner_id: Optional[StrictStr] = Field(default=None, description="A unique identifier of visitors' information defined by third party partners. e.g RampID")
    ph: Optional[List[StrictStr]] = Field(default=None, description="Sha256 hashes of user's phone numbers, only digits with country code, area code, and number. Remove any symbols, letters, spaces and leading zeros. We highly recommend this on checkout events at least. It may improve reporting performance such as ROAS/CPA. The string should be in the UTF-8 format.")
    st: Optional[List[StrictStr]] = Field(default=None, description="Sha256 hashes of user's state, given as a two-letter code in lowercase. User residency state (mostly billing). The string should be in the UTF-8 format.")
    zp: Optional[List[StrictStr]] = Field(default=None, description="Sha256 hashes of user's zipcode, only digits. User residency zipcode (mostly billing). The string should be in the UTF-8 format.")
    __properties: ClassVar[List[str]] = ["click_id", "client_ip_address", "client_user_agent", "country", "ct", "db", "em", "external_id", "fn", "ge", "hashed_maids", "ln", "partner_id", "ph", "st", "zp"]

    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 ConversionEventsUserDataProperties 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,
        )
        # set to None if click_id (nullable) is None
        # and model_fields_set contains the field
        if self.click_id is None and "click_id" in self.model_fields_set:
            _dict['click_id'] = None

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

        return _dict

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

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

        _obj = cls.model_validate({
            "click_id": obj.get("click_id"),
            "client_ip_address": obj.get("client_ip_address"),
            "client_user_agent": obj.get("client_user_agent"),
            "country": obj.get("country"),
            "ct": obj.get("ct"),
            "db": obj.get("db"),
            "em": obj.get("em"),
            "external_id": obj.get("external_id"),
            "fn": obj.get("fn"),
            "ge": obj.get("ge"),
            "hashed_maids": obj.get("hashed_maids"),
            "ln": obj.get("ln"),
            "partner_id": obj.get("partner_id"),
            "ph": obj.get("ph"),
            "st": obj.get("st"),
            "zp": obj.get("zp")
        })
        return _obj


