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

class ConversionEventAppInfo(BaseModel):
    """
    Object containing information about the application where event occurred.
    """ # noqa: E501
    app_id: Optional[Annotated[str, Field(strict=True, max_length=200)]] = Field(default=None, description="App ID in Google Play Store, AppStore or other stores.")
    app_name: Optional[Annotated[str, Field(strict=True, max_length=200)]] = Field(default=None, description="Name of the app. Primarily used for Mobile Apps.")
    app_package_name: Optional[Annotated[str, Field(strict=True, max_length=200)]] = Field(default=None, description="App package name")
    app_store: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(default=None, description="The name of the app distributor or store from which the app was installed. Some options: Samsung Galaxy Store, Google Play Store, Amazon Store, Apple App Store, F-Droid, Aptoide, Obtanium, Huawei AppGallery, Xiaomi Mi GetApps")
    app_version: Optional[Annotated[str, Field(strict=True, max_length=100)]] = Field(default=None, description="App version. Primarily used for mobile apps")
    install_time: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=None, description="App install time. Unix timestamp in seconds")
    user_agent: Optional[Annotated[str, Field(strict=True, max_length=16384)]] = Field(default=None, description="User Agent request header. Primarily used for Web events")
    window_height: Optional[Annotated[int, Field(le=30720, strict=True, ge=0)]] = Field(default=None, description="Inner height of the window or viewport.")
    window_width: Optional[Annotated[int, Field(le=30720, strict=True, ge=0)]] = Field(default=None, description="Inner width of the window or viewport.")
    __properties: ClassVar[List[str]] = ["app_id", "app_name", "app_package_name", "app_store", "app_version", "install_time", "user_agent", "window_height", "window_width"]

    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 ConversionEventAppInfo 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 ConversionEventAppInfo from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "app_id": obj.get("app_id"),
            "app_name": obj.get("app_name"),
            "app_package_name": obj.get("app_package_name"),
            "app_store": obj.get("app_store"),
            "app_version": obj.get("app_version"),
            "install_time": obj.get("install_time"),
            "user_agent": obj.get("user_agent"),
            "window_height": obj.get("window_height"),
            "window_width": obj.get("window_width")
        })
        return _obj


