# 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.ad_extension_status import AdExtensionStatus
from openapi_client.models.campaign.confirmation_action import ConfirmationAction
from openapi_client.models.campaign.image_asset import ImageAsset
from openapi_client.models.campaign.key_value_pair_ofstring_andstring import KeyValuePairOfstringAndstring
from openapi_client.models.campaign.lead_delivery import LeadDelivery
from openapi_client.models.campaign.lead_form_call_to_action import LeadFormCallToAction
from openapi_client.models.campaign.lead_form_question_definition import LeadFormQuestionDefinition
from openapi_client.models.campaign.schedule import Schedule
from typing_extensions import Self

class LeadFormAdExtension(BaseModel):
    """
    LeadFormAdExtension
    """ # noqa: E501
    call_to_action: Optional[LeadFormCallToAction] = Field(default=None, alias="CallToAction")
    action_name: Optional[StrictStr] = Field(default=None, alias="ActionName")
    action_description: Optional[StrictStr] = Field(default=None, alias="ActionDescription")
    corporate_image: Optional[ImageAsset] = Field(default=None, alias="CorporateImage")
    corporate_image_internal_url: Optional[StrictStr] = Field(default=None, alias="CorporateImageInternalUrl")
    form_headline: Optional[StrictStr] = Field(default=None, alias="FormHeadline")
    form_business_name: Optional[StrictStr] = Field(default=None, alias="FormBusinessName")
    form_description: Optional[StrictStr] = Field(default=None, alias="FormDescription")
    form_policy_url: Optional[StrictStr] = Field(default=None, alias="FormPolicyUrl")
    form_questions: Optional[List[Optional[LeadFormQuestionDefinition]]] = Field(default=None, alias="FormQuestions")
    confirmation_message: Optional[StrictStr] = Field(default=None, alias="ConfirmationMessage")
    confirmation_description: Optional[StrictStr] = Field(default=None, alias="ConfirmationDescription")
    confirmation_action: Optional[ConfirmationAction] = Field(default=None, alias="ConfirmationAction")
    confirmation_url: Optional[StrictStr] = Field(default=None, alias="ConfirmationUrl")
    lead_delivery: Optional[LeadDelivery] = Field(default=None, alias="LeadDelivery")
    lead_emails: Optional[StrictStr] = Field(default=None, alias="LeadEmails")
    lead_webhook_url: Optional[StrictStr] = Field(default=None, alias="LeadWebhookUrl")
    lead_webhook_key: Optional[StrictStr] = Field(default=None, alias="LeadWebhookKey")
    language: Optional[StrictStr] = Field(default=None, alias="Language")
    status: Optional[AdExtensionStatus] = Field(default=None, alias="Status")
    scheduling: Optional[Schedule] = Field(default=None, alias="Scheduling")
    device_preference: Optional[StrictStr] = Field(default=None, alias="DevicePreference")
    id: Optional[StrictStr] = Field(default=None, alias="Id")
    type: Optional[StrictStr] = Field(default='LeadFormAdExtension', alias="Type")
    version: Optional[StrictInt] = Field(default=None, alias="Version")
    forward_compatibility_map: Optional[List[Optional[KeyValuePairOfstringAndstring]]] = Field(default=None, alias="ForwardCompatibilityMap")
    __properties: ClassVar[List[str]] = ["CallToAction", "ActionName", "ActionDescription", "CorporateImage", "CorporateImageInternalUrl", "FormHeadline", "FormBusinessName", "FormDescription", "FormPolicyUrl", "FormQuestions", "ConfirmationMessage", "ConfirmationDescription", "ConfirmationAction", "ConfirmationUrl", "LeadDelivery", "LeadEmails", "LeadWebhookUrl", "LeadWebhookKey", "Language", "Status", "Scheduling", "DevicePreference", "Id", "Type", "Version", "ForwardCompatibilityMap"]

    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 LeadFormAdExtension 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 corporate_image
        if self.corporate_image:
            _dict['CorporateImage'] = self.corporate_image.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in form_questions (list)
        _items = []
        if self.form_questions:
            for _item_form_questions in self.form_questions:
                if _item_form_questions:
                    _items.append(_item_form_questions.to_dict())
            _dict['FormQuestions'] = _items
        # override the default output from pydantic by calling `to_dict()` of scheduling
        if self.scheduling:
            _dict['Scheduling'] = self.scheduling.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in forward_compatibility_map (list)
        _items = []
        if self.forward_compatibility_map:
            for _item_forward_compatibility_map in self.forward_compatibility_map:
                if _item_forward_compatibility_map:
                    _items.append(_item_forward_compatibility_map.to_dict())
            _dict['ForwardCompatibilityMap'] = _items
        # set to None if call_to_action (nullable) is None
        # and model_fields_set contains the field
        if self.call_to_action is None and "call_to_action" in self.model_fields_set:
            _dict['CallToAction'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "CallToAction": obj.get("CallToAction") if obj.get("CallToAction") is not None else None,
                        "ActionName": obj.get("ActionName") if obj.get("ActionName") is not None else None,
                        "ActionDescription": obj.get("ActionDescription") if obj.get("ActionDescription") is not None else None,
                        "CorporateImage": ImageAsset.from_dict(obj["CorporateImage"]) if obj.get("CorporateImage") is not None else None,
                        "CorporateImageInternalUrl": obj.get("CorporateImageInternalUrl") if obj.get("CorporateImageInternalUrl") is not None else None,
                        "FormHeadline": obj.get("FormHeadline") if obj.get("FormHeadline") is not None else None,
                        "FormBusinessName": obj.get("FormBusinessName") if obj.get("FormBusinessName") is not None else None,
                        "FormDescription": obj.get("FormDescription") if obj.get("FormDescription") is not None else None,
                        "FormPolicyUrl": obj.get("FormPolicyUrl") if obj.get("FormPolicyUrl") is not None else None,
                        "FormQuestions": [LeadFormQuestionDefinition.from_dict(_item) for _item in obj["FormQuestions"]] if obj.get("FormQuestions") is not None else None,
                        "ConfirmationMessage": obj.get("ConfirmationMessage") if obj.get("ConfirmationMessage") is not None else None,
                        "ConfirmationDescription": obj.get("ConfirmationDescription") if obj.get("ConfirmationDescription") is not None else None,
                        "ConfirmationAction": obj.get("ConfirmationAction") if obj.get("ConfirmationAction") is not None else None,
                        "ConfirmationUrl": obj.get("ConfirmationUrl") if obj.get("ConfirmationUrl") is not None else None,
                        "LeadDelivery": obj.get("LeadDelivery") if obj.get("LeadDelivery") is not None else None,
                        "LeadEmails": obj.get("LeadEmails") if obj.get("LeadEmails") is not None else None,
                        "LeadWebhookUrl": obj.get("LeadWebhookUrl") if obj.get("LeadWebhookUrl") is not None else None,
                        "LeadWebhookKey": obj.get("LeadWebhookKey") if obj.get("LeadWebhookKey") is not None else None,
                        "Language": obj.get("Language") if obj.get("Language") is not None else None,
                        "Status": obj.get("Status") if obj.get("Status") is not None else None,
                        "Scheduling": Schedule.from_dict(obj["Scheduling"]) if obj.get("Scheduling") is not None else None,
                        "DevicePreference": obj.get("DevicePreference") if obj.get("DevicePreference") 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 'LeadFormAdExtension',
                        "Version": obj.get("Version") if obj.get("Version") is not None else None,
                        "ForwardCompatibilityMap": [KeyValuePairOfstringAndstring.from_dict(_item) for _item in obj["ForwardCompatibilityMap"]] if obj.get("ForwardCompatibilityMap") is not None else None
        })
        return _obj
