# coding: utf-8

"""
    CampaignManagementService

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 1.0.0
    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, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union, Set
from openapi_client.models.campaign.attribution_model_type import AttributionModelType
from openapi_client.models.campaign.conversion_goal_category import ConversionGoalCategory
from openapi_client.models.campaign.conversion_goal_count_type import ConversionGoalCountType
from openapi_client.models.campaign.conversion_goal_revenue import ConversionGoalRevenue
from openapi_client.models.campaign.conversion_goal_status import ConversionGoalStatus
from openapi_client.models.campaign.conversion_goal_tracking_status import ConversionGoalTrackingStatus
from openapi_client.models.campaign.entity_scope import EntityScope
from typing_extensions import Self

class PagesViewedPerVisitGoal(BaseModel):
    """
    PagesViewedPerVisitGoal
    """ # noqa: E501
    minimum_pages_viewed: Optional[StrictInt] = Field(default=None, alias="MinimumPagesViewed")
    id: Optional[StrictStr] = Field(default=None, alias="Id")
    name: Optional[StrictStr] = Field(default=None, alias="Name")
    status: Optional[ConversionGoalStatus] = Field(default=None, alias="Status")
    type: Optional[StrictStr] = Field(default='PagesViewedPerVisit', alias="Type")
    scope: Optional[EntityScope] = Field(default=None, alias="Scope")
    count_type: Optional[ConversionGoalCountType] = Field(default=None, alias="CountType")
    revenue: Optional[ConversionGoalRevenue] = Field(default=None, alias="Revenue")
    conversion_window_in_minutes: Optional[StrictInt] = Field(default=None, alias="ConversionWindowInMinutes")
    tag_id: Optional[StrictStr] = Field(default=None, alias="TagId")
    tracking_status: Optional[ConversionGoalTrackingStatus] = Field(default=None, alias="TrackingStatus")
    exclude_from_bidding: Optional[StrictBool] = Field(default=None, alias="ExcludeFromBidding")
    view_through_conversion_window_in_minutes: Optional[StrictInt] = Field(default=None, alias="ViewThroughConversionWindowInMinutes")
    goal_category: Optional[ConversionGoalCategory] = Field(default=None, alias="GoalCategory")
    attribution_model_type: Optional[AttributionModelType] = Field(default=None, alias="AttributionModelType")
    is_enhanced_conversions_enabled: Optional[StrictBool] = Field(default=None, alias="IsEnhancedConversionsEnabled")
    __properties: ClassVar[List[str]] = ["MinimumPagesViewed", "Id", "Name", "Status", "Type", "Scope", "CountType", "Revenue", "ConversionWindowInMinutes", "TagId", "TrackingStatus", "ExcludeFromBidding", "ViewThroughConversionWindowInMinutes", "GoalCategory", "AttributionModelType", "IsEnhancedConversionsEnabled"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )
	
    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 PagesViewedPerVisitGoal 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 revenue
        if self.revenue:
            _dict['Revenue'] = self.revenue.to_dict()
        # set to None if minimum_pages_viewed (nullable) is None
        # and model_fields_set contains the field
        if self.minimum_pages_viewed is None and "minimum_pages_viewed" in self.model_fields_set:
            _dict['MinimumPagesViewed'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "MinimumPagesViewed": obj.get("MinimumPagesViewed") if obj.get("MinimumPagesViewed") is not None else None,
                        "Id": obj.get("Id") if obj.get("Id") is not None else None,
                        "Name": obj.get("Name") if obj.get("Name") is not None else None,
                        "Status": obj.get("Status") if obj.get("Status") is not None else None,
                        "Type": obj.get("Type") if obj.get("Type") is not None else 'PagesViewedPerVisit',
                        "Scope": obj.get("Scope") if obj.get("Scope") is not None else None,
                        "CountType": obj.get("CountType") if obj.get("CountType") is not None else None,
                        "Revenue": ConversionGoalRevenue.from_dict(obj["Revenue"]) if obj.get("Revenue") is not None else None,
                        "ConversionWindowInMinutes": obj.get("ConversionWindowInMinutes") if obj.get("ConversionWindowInMinutes") is not None else None,
                        "TagId": obj.get("TagId") if obj.get("TagId") is not None else None,
                        "TrackingStatus": obj.get("TrackingStatus") if obj.get("TrackingStatus") is not None else None,
                        "ExcludeFromBidding": obj.get("ExcludeFromBidding") if obj.get("ExcludeFromBidding") is not None else None,
                        "ViewThroughConversionWindowInMinutes": obj.get("ViewThroughConversionWindowInMinutes") if obj.get("ViewThroughConversionWindowInMinutes") is not None else None,
                        "GoalCategory": obj.get("GoalCategory") if obj.get("GoalCategory") is not None else None,
                        "AttributionModelType": obj.get("AttributionModelType") if obj.get("AttributionModelType") is not None else None,
                        "IsEnhancedConversionsEnabled": obj.get("IsEnhancedConversionsEnabled") if obj.get("IsEnhancedConversionsEnabled") is not None else None
        })
        return _obj
