# 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.campaign_ad_group_ids import CampaignAdGroupIds
from openapi_client.models.campaign.frequency import Frequency
from openapi_client.models.campaign.import_option import ImportOption
from typing_extensions import Self

class GoogleImportJob(BaseModel):
    """
    GoogleImportJob
    """ # noqa: E501
    credential_id: Optional[StrictStr] = Field(default=None, alias="CredentialId")
    google_account_id: Optional[StrictStr] = Field(default=None, alias="GoogleAccountId")
    campaign_ad_group_ids: Optional[List[Optional[CampaignAdGroupIds]]] = Field(default=None, alias="CampaignAdGroupIds")
    google_user_name: Optional[StrictStr] = Field(default=None, alias="GoogleUserName")
    name: Optional[StrictStr] = Field(default=None, alias="Name")
    id: Optional[StrictStr] = Field(default=None, alias="Id")
    type: Optional[StrictStr] = Field(default='GoogleImportJob', alias="Type")
    status: Optional[StrictStr] = Field(default=None, alias="Status")
    notification_type: Optional[StrictStr] = Field(default=None, alias="NotificationType")
    created_by_user_id: Optional[StrictStr] = Field(default=None, alias="CreatedByUserId")
    created_by_user_name: Optional[StrictStr] = Field(default=None, alias="CreatedByUserName")
    frequency: Optional[Frequency] = Field(default=None, alias="Frequency")
    last_run_time_in_utc: Optional[datetime] = Field(default=None, alias="LastRunTimeInUTC")
    created_date_time_in_utc: Optional[datetime] = Field(default=None, alias="CreatedDateTimeInUTC")
    import_option: Optional[ImportOption] = Field(default=None, alias="ImportOption")
    notification_email: Optional[StrictStr] = Field(default=None, alias="NotificationEmail")
    __properties: ClassVar[List[str]] = ["CredentialId", "GoogleAccountId", "CampaignAdGroupIds", "GoogleUserName", "Name", "Id", "Type", "Status", "NotificationType", "CreatedByUserId", "CreatedByUserName", "Frequency", "LastRunTimeInUTC", "CreatedDateTimeInUTC", "ImportOption", "NotificationEmail"]

    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 GoogleImportJob 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 each item in campaign_ad_group_ids (list)
        _items = []
        if self.campaign_ad_group_ids:
            for _item_campaign_ad_group_ids in self.campaign_ad_group_ids:
                if _item_campaign_ad_group_ids:
                    _items.append(_item_campaign_ad_group_ids.to_dict())
            _dict['CampaignAdGroupIds'] = _items
        # override the default output from pydantic by calling `to_dict()` of frequency
        if self.frequency:
            _dict['Frequency'] = self.frequency.to_dict()
        # override the default output from pydantic by calling `to_dict()` of import_option
        if self.import_option:
            _dict['ImportOption'] = self.import_option.to_dict()
        # set to None if credential_id (nullable) is None
        # and model_fields_set contains the field
        if self.credential_id is None and "credential_id" in self.model_fields_set:
            _dict['CredentialId'] = None

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "CredentialId": obj.get("CredentialId") if obj.get("CredentialId") is not None else None,
                        "GoogleAccountId": obj.get("GoogleAccountId") if obj.get("GoogleAccountId") is not None else None,
                        "CampaignAdGroupIds": [CampaignAdGroupIds.from_dict(_item) for _item in obj["CampaignAdGroupIds"]] if obj.get("CampaignAdGroupIds") is not None else None,
                        "GoogleUserName": obj.get("GoogleUserName") if obj.get("GoogleUserName") is not None else None,
                        "Name": obj.get("Name") if obj.get("Name") is not None else None,
                        "Id": obj.get("Id") if obj.get("Id") is not None else None,
                        "Type": obj.get("Type") if obj.get("Type") is not None else 'GoogleImportJob',
                        "Status": obj.get("Status") if obj.get("Status") is not None else None,
                        "NotificationType": obj.get("NotificationType") if obj.get("NotificationType") is not None else None,
                        "CreatedByUserId": obj.get("CreatedByUserId") if obj.get("CreatedByUserId") is not None else None,
                        "CreatedByUserName": obj.get("CreatedByUserName") if obj.get("CreatedByUserName") is not None else None,
                        "Frequency": Frequency.from_dict(obj["Frequency"]) if obj.get("Frequency") is not None else None,
                        "LastRunTimeInUTC": obj.get("LastRunTimeInUTC") if obj.get("LastRunTimeInUTC") is not None else None,
                        "CreatedDateTimeInUTC": obj.get("CreatedDateTimeInUTC") if obj.get("CreatedDateTimeInUTC") is not None else None,
                        "ImportOption": ImportOption.from_dict(obj["ImportOption"]) if obj.get("ImportOption") is not None else None,
                        "NotificationEmail": obj.get("NotificationEmail") if obj.get("NotificationEmail") is not None else None
        })
        return _obj
