# coding: utf-8

"""
    Lookup/Ibis web service API

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

    The version of the OpenAPI document: 1.2
    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 typing import List, Optional
from pydantic import BaseModel, Field, StrictBool, StrictStr, conlist
from identitylib.lookup_client.models.contact_phone_number import ContactPhoneNumber
from identitylib.lookup_client.models.contact_web_page import ContactWebPage

class ContactRow(BaseModel):
    """
    Class representing an institution contact row, for use by the web services API.
    """
    description: Optional[StrictStr] = Field(None, description="The contact row's text.")
    bold: Optional[StrictBool] = Field(None, description="Flag indicating if the contact row's text is normally displayed in bold.")
    italic: Optional[StrictBool] = Field(None, description="Flag indicating if the contact row's text is normally displayed in italics.")
    addresses: Optional[conlist(StrictStr)] = Field(None, description="A list of the contact row's addresses. This will always be non-null, but may be an empty list.")
    emails: Optional[conlist(StrictStr)] = Field(None, description="A list of the contact row's email addresses. This will always be non-null, but may be an empty list.")
    people: Optional[conlist(Person)] = Field(None, description="A list of the people referred to by the contact row. This will always be non-null, but may be an empty list.")
    phone_numbers: Optional[conlist(ContactPhoneNumber)] = Field(None, alias="phoneNumbers", description="A list of the contact row's phone numbers. This will always be non-null, but may be an empty list.")
    web_pages: Optional[conlist(ContactWebPage)] = Field(None, alias="webPages", description="A list of the contact row's web pages. This will always be non-null, but may be an empty list.")
    __properties = ["description", "bold", "italic", "addresses", "emails", "people", "phoneNumbers", "webPages"]

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> ContactRow:
        """Create an instance of ContactRow from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of each item in people (list)
        _items = []
        if self.people:
            for _item in self.people:
                if _item:
                    _items.append(_item.to_dict())
            _dict['people'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in phone_numbers (list)
        _items = []
        if self.phone_numbers:
            for _item in self.phone_numbers:
                if _item:
                    _items.append(_item.to_dict())
            _dict['phoneNumbers'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in web_pages (list)
        _items = []
        if self.web_pages:
            for _item in self.web_pages:
                if _item:
                    _items.append(_item.to_dict())
            _dict['webPages'] = _items
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> ContactRow:
        """Create an instance of ContactRow from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return ContactRow.parse_obj(obj)

        _obj = ContactRow.parse_obj({
            "description": obj.get("description"),
            "bold": obj.get("bold"),
            "italic": obj.get("italic"),
            "addresses": obj.get("addresses"),
            "emails": obj.get("emails"),
            "people": [Person.from_dict(_item) for _item in obj.get("people")] if obj.get("people") is not None else None,
            "phone_numbers": [ContactPhoneNumber.from_dict(_item) for _item in obj.get("phoneNumbers")] if obj.get("phoneNumbers") is not None else None,
            "web_pages": [ContactWebPage.from_dict(_item) for _item in obj.get("webPages")] if obj.get("webPages") is not None else None
        })
        return _obj

from identitylib.lookup_client.models.person import Person
ContactRow.update_forward_refs()

