# coding: utf-8

"""
    YouTube Data API v3

    The YouTube Data API v3 is an API that provides access to YouTube data, such as videos, playlists, and channels.

    The version of the OpenAPI document: v3
    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 youtube_ti.models.channel_to_store_link_details_billing_details import ChannelToStoreLinkDetailsBillingDetails
from youtube_ti.models.channel_to_store_link_details_merchant_affiliate_program_details import ChannelToStoreLinkDetailsMerchantAffiliateProgramDetails
from typing import Optional, Set
from typing_extensions import Self

class ChannelToStoreLinkDetails(BaseModel):
    """
    Information specific to a store on a merchandising platform linked to a YouTube channel.
    """ # noqa: E501
    billing_details: Optional[ChannelToStoreLinkDetailsBillingDetails] = Field(default=None, alias="billingDetails")
    merchant_affiliate_program_details: Optional[ChannelToStoreLinkDetailsMerchantAffiliateProgramDetails] = Field(default=None, alias="merchantAffiliateProgramDetails")
    merchant_id: Optional[StrictStr] = Field(default=None, description="Google Merchant Center id of the store.", alias="merchantId")
    store_name: Optional[StrictStr] = Field(default=None, description="Name of the store.", alias="storeName")
    store_url: Optional[StrictStr] = Field(default=None, description="Landing page of the store.", alias="storeUrl")
    __properties: ClassVar[List[str]] = ["billingDetails", "merchantAffiliateProgramDetails", "merchantId", "storeName", "storeUrl"]

    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 ChannelToStoreLinkDetails 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 billing_details
        if self.billing_details:
            _dict['billingDetails'] = self.billing_details.to_dict()
        # override the default output from pydantic by calling `to_dict()` of merchant_affiliate_program_details
        if self.merchant_affiliate_program_details:
            _dict['merchantAffiliateProgramDetails'] = self.merchant_affiliate_program_details.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "billingDetails": ChannelToStoreLinkDetailsBillingDetails.from_dict(obj["billingDetails"]) if obj.get("billingDetails") is not None else None,
            "merchantAffiliateProgramDetails": ChannelToStoreLinkDetailsMerchantAffiliateProgramDetails.from_dict(obj["merchantAffiliateProgramDetails"]) if obj.get("merchantAffiliateProgramDetails") is not None else None,
            "merchantId": obj.get("merchantId"),
            "storeName": obj.get("storeName"),
            "storeUrl": obj.get("storeUrl")
        })
        return _obj


