# coding: utf-8

"""
    ReportingService

    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.reporting.account_through_ad_group_report_scope import AccountThroughAdGroupReportScope
from openapi_client.models.reporting.report_aggregation import ReportAggregation
from openapi_client.models.reporting.report_format import ReportFormat
from openapi_client.models.reporting.report_time import ReportTime
from openapi_client.models.reporting.user_location_performance_report_column import UserLocationPerformanceReportColumn
from openapi_client.models.reporting.user_location_performance_report_filter import UserLocationPerformanceReportFilter
from typing_extensions import Self

class UserLocationPerformanceReportRequest(BaseModel):
    """
    UserLocationPerformanceReportRequest
    """ # noqa: E501
    scope: Optional[AccountThroughAdGroupReportScope] = Field(default=None, alias="Scope")
    filter: Optional[UserLocationPerformanceReportFilter] = Field(default=None, alias="Filter")
    time: Optional[ReportTime] = Field(default=None, alias="Time")
    aggregation: Optional[ReportAggregation] = Field(default=None, alias="Aggregation")
    columns: Optional[List[Optional[UserLocationPerformanceReportColumn]]] = Field(default=None, alias="Columns")
    report_name: Optional[StrictStr] = Field(default=None, alias="ReportName")
    format: Optional[ReportFormat] = Field(default=None, alias="Format")
    return_only_complete_data: Optional[StrictBool] = Field(default=None, alias="ReturnOnlyCompleteData")
    exclude_report_header: Optional[StrictBool] = Field(default=None, alias="ExcludeReportHeader")
    exclude_report_footer: Optional[StrictBool] = Field(default=None, alias="ExcludeReportFooter")
    exclude_column_headers: Optional[StrictBool] = Field(default=None, alias="ExcludeColumnHeaders")
    format_version: Optional[StrictStr] = Field(default=None, alias="FormatVersion")
    type: Optional[StrictStr] = Field(default='UserLocationPerformanceReportRequest', alias="Type")
    __properties: ClassVar[List[str]] = ["Scope", "Filter", "Time", "Aggregation", "Columns", "ReportName", "Format", "ReturnOnlyCompleteData", "ExcludeReportHeader", "ExcludeReportFooter", "ExcludeColumnHeaders", "FormatVersion", "Type"]

    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 UserLocationPerformanceReportRequest 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 scope
        if self.scope:
            _dict['Scope'] = self.scope.to_dict()
        # override the default output from pydantic by calling `to_dict()` of filter
        if self.filter:
            _dict['Filter'] = self.filter.to_dict()
        # override the default output from pydantic by calling `to_dict()` of time
        if self.time:
            _dict['Time'] = self.time.to_dict()
        # 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 filter (nullable) is None
        # and model_fields_set contains the field
        if self.filter is None and "filter" in self.model_fields_set:
            _dict['Filter'] = None

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "Scope": AccountThroughAdGroupReportScope.from_dict(obj["Scope"]) if obj.get("Scope") is not None else None,
                        "Filter": UserLocationPerformanceReportFilter.from_dict(obj["Filter"]) if obj.get("Filter") is not None else None,
                        "Time": ReportTime.from_dict(obj["Time"]) if obj.get("Time") is not None else None,
                        "Aggregation": obj.get("Aggregation") if obj.get("Aggregation") is not None else None,
                        "Columns": obj.get("Columns"),
                        "ReportName": obj.get("ReportName") if obj.get("ReportName") is not None else None,
                        "Format": obj.get("Format") if obj.get("Format") is not None else None,
                        "ReturnOnlyCompleteData": obj.get("ReturnOnlyCompleteData") if obj.get("ReturnOnlyCompleteData") is not None else None,
                        "ExcludeReportHeader": obj.get("ExcludeReportHeader") if obj.get("ExcludeReportHeader") is not None else None,
                        "ExcludeReportFooter": obj.get("ExcludeReportFooter") if obj.get("ExcludeReportFooter") is not None else None,
                        "ExcludeColumnHeaders": obj.get("ExcludeColumnHeaders") if obj.get("ExcludeColumnHeaders") is not None else None,
                        "FormatVersion": obj.get("FormatVersion") if obj.get("FormatVersion") is not None else None,
                        "Type": obj.get("Type") if obj.get("Type") is not None else 'UserLocationPerformanceReportRequest'
        })
        return _obj
