# coding: utf-8

"""
    Jellyfin API

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 10.11.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 pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from openapi_client.models.name_value_pair import NameValuePair
from typing import Optional, Set
from typing_extensions import Self

class ListingsProviderInfo(BaseModel):
    """
    ListingsProviderInfo
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, alias="Id")
    type: Optional[StrictStr] = Field(default=None, alias="Type")
    username: Optional[StrictStr] = Field(default=None, alias="Username")
    password: Optional[StrictStr] = Field(default=None, alias="Password")
    listings_id: Optional[StrictStr] = Field(default=None, alias="ListingsId")
    zip_code: Optional[StrictStr] = Field(default=None, alias="ZipCode")
    country: Optional[StrictStr] = Field(default=None, alias="Country")
    path: Optional[StrictStr] = Field(default=None, alias="Path")
    enabled_tuners: Optional[List[StrictStr]] = Field(default=None, alias="EnabledTuners")
    enable_all_tuners: Optional[StrictBool] = Field(default=None, alias="EnableAllTuners")
    news_categories: Optional[List[StrictStr]] = Field(default=None, alias="NewsCategories")
    sports_categories: Optional[List[StrictStr]] = Field(default=None, alias="SportsCategories")
    kids_categories: Optional[List[StrictStr]] = Field(default=None, alias="KidsCategories")
    movie_categories: Optional[List[StrictStr]] = Field(default=None, alias="MovieCategories")
    channel_mappings: Optional[List[NameValuePair]] = Field(default=None, alias="ChannelMappings")
    movie_prefix: Optional[StrictStr] = Field(default=None, alias="MoviePrefix")
    preferred_language: Optional[StrictStr] = Field(default=None, alias="PreferredLanguage")
    user_agent: Optional[StrictStr] = Field(default=None, alias="UserAgent")
    __properties: ClassVar[List[str]] = ["Id", "Type", "Username", "Password", "ListingsId", "ZipCode", "Country", "Path", "EnabledTuners", "EnableAllTuners", "NewsCategories", "SportsCategories", "KidsCategories", "MovieCategories", "ChannelMappings", "MoviePrefix", "PreferredLanguage", "UserAgent"]

    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 ListingsProviderInfo 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 channel_mappings (list)
        _items = []
        if self.channel_mappings:
            for _item_channel_mappings in self.channel_mappings:
                if _item_channel_mappings:
                    _items.append(_item_channel_mappings.to_dict())
            _dict['ChannelMappings'] = _items
        # 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 username (nullable) is None
        # and model_fields_set contains the field
        if self.username is None and "username" in self.model_fields_set:
            _dict['Username'] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "Id": obj.get("Id"),
            "Type": obj.get("Type"),
            "Username": obj.get("Username"),
            "Password": obj.get("Password"),
            "ListingsId": obj.get("ListingsId"),
            "ZipCode": obj.get("ZipCode"),
            "Country": obj.get("Country"),
            "Path": obj.get("Path"),
            "EnabledTuners": obj.get("EnabledTuners"),
            "EnableAllTuners": obj.get("EnableAllTuners"),
            "NewsCategories": obj.get("NewsCategories"),
            "SportsCategories": obj.get("SportsCategories"),
            "KidsCategories": obj.get("KidsCategories"),
            "MovieCategories": obj.get("MovieCategories"),
            "ChannelMappings": [NameValuePair.from_dict(_item) for _item in obj["ChannelMappings"]] if obj.get("ChannelMappings") is not None else None,
            "MoviePrefix": obj.get("MoviePrefix"),
            "PreferredLanguage": obj.get("PreferredLanguage"),
            "UserAgent": obj.get("UserAgent")
        })
        return _obj


