# coding: utf-8

"""
    Klaviyo API

    The Klaviyo REST API. Please visit https://developers.klaviyo.com for more details.

    The version of the OpenAPI document: 2024-10-15
    Contact: developers@klaviyo.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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from openapi_client.models.street_address import StreetAddress
from typing import Optional, Set
from typing_extensions import Self

class ContactInformation(BaseModel):
    """
    ContactInformation
    """ # noqa: E501
    default_sender_name: StrictStr = Field(description="This field is used to auto-populate the default sender name on flow and campaign emails.")
    default_sender_email: StrictStr = Field(description="This field is used to auto-populate the default sender email address on flow and campaign emails.")
    website_url: Optional[StrictStr] = None
    organization_name: StrictStr
    street_address: StreetAddress
    __properties: ClassVar[List[str]] = ["default_sender_name", "default_sender_email", "website_url", "organization_name", "street_address"]

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

        return _dict

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

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

        _obj = cls.model_validate({
            "default_sender_name": obj.get("default_sender_name"),
            "default_sender_email": obj.get("default_sender_email"),
            "website_url": obj.get("website_url"),
            "organization_name": obj.get("organization_name"),
            "street_address": StreetAddress.from_dict(obj["street_address"]) if obj.get("street_address") is not None else None
        })
        return _obj


