# coding: utf-8

"""
    easybill REST API

     The first version of the easybill REST API. [CHANGELOG](https://api.easybill.de/rest/v1/CHANGELOG.md)  ## Authentication  You can choose between two available methods: `Basic Auth` or `Bearer Token`.  In each HTTP request, one of the following HTTP headers is required:  ``` # Basic Auth Authorization: Basic base64_encode('<email>:<api_key>') # Bearer Token Authorization: Bearer <api_key> ```  ## Limitations  ### Request Limit  * PLUS: 10 requests per minute * BUSINESS: 60 requests per minute  If the limit is exceeded, you will receive the HTTP error: `429 Too Many Requests`  ### Result Limit  All result lists are limited to 100 by default. This limit can be increased by the query parameter `limit` to a maximum of 1000.  ## Query filter  Many list resources can be filtered. In `/documents` you can filter e.g. by number with `/documents?number=111028654`. If you want to filter multiple numbers, you can either enter them separated by commas `/documents?number=111028654,222006895` or as an array `/documents?number[]=111028654&number[]=222006895`.  **Warning**: The maximum size of an HTTP request line in bytes is 4094. If this limit is exceeded, you will receive the HTTP error: `414 Request-URI Too Large`  ### Escape commas in query  You can escape commans in query `name=Patrick\\, Peter` if you submit the header `X-Easybill-Escape: true` in your request.  ## Property login_id  This is the login of your admin or employee account.  ## Date and Date-Time format Please use the timezone `Europe/Berlin`. * **date** = *Y-m-d* = `2016-12-31` * **date-time** = *Y-m-d H:i:s* = `2016-12-31 03:13:37`  Date or datetime can be `null` because the attributes have been added later and the entry is older.

    The version of the OpenAPI document: 1.96.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, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python

class Contact(BaseModel):
    """
    Contact
    """ # noqa: E501
    city: StrictStr
    state: Optional[StrictStr] = None
    company_name: Optional[StrictStr] = None
    country: Optional[StrictStr] = Field(default=None, description="Two-letter country code")
    department: Optional[StrictStr] = 'null'
    emails: Optional[List[StrictStr]] = None
    fax: Optional[StrictStr] = 'null'
    first_name: Optional[StrictStr] = 'null'
    id: Optional[StrictInt] = None
    last_name: Optional[StrictStr] = 'null'
    login_id: Optional[StrictInt] = None
    mobile: Optional[StrictStr] = 'null'
    note: Optional[StrictStr] = 'null'
    personal: Optional[StrictBool] = False
    phone_1: Optional[StrictStr] = 'null'
    phone_2: Optional[StrictStr] = 'null'
    salutation: Optional[StrictInt] = Field(default=None, description="0: empty<br/> 1: Herrn<br/> 2: Frau<br/> 3: Firma<br/> 4: Herrn und Frau<br/> 5: Eheleute<br/> 6: Familie")
    street: StrictStr
    suffix_1: Optional[StrictStr] = 'null'
    suffix_2: Optional[StrictStr] = 'null'
    title: Optional[StrictStr] = 'null'
    zip_code: Optional[StrictStr] = 'null'
    created_at: Optional[StrictStr] = None
    updated_at: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["city", "state", "company_name", "country", "department", "emails", "fax", "first_name", "id", "last_name", "login_id", "mobile", "note", "personal", "phone_1", "phone_2", "salutation", "street", "suffix_1", "suffix_2", "title", "zip_code", "created_at", "updated_at"]

    model_config = ConfigDict(
        validate_by_name=True,
        validate_by_alias=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"""
        return json.dumps(to_jsonable_python(self.to_dict()))

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of Contact 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.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        """
        excluded_fields: Set[str] = set([
            "id",
            "login_id",
            "created_at",
            "updated_at",
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # set to None if company_name (nullable) is None
        # and model_fields_set contains the field
        if self.company_name is None and "company_name" in self.model_fields_set:
            _dict['company_name'] = None

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "city": obj.get("city"),
            "state": obj.get("state"),
            "company_name": obj.get("company_name"),
            "country": obj.get("country"),
            "department": obj.get("department") if obj.get("department") is not None else 'null',
            "emails": obj.get("emails"),
            "fax": obj.get("fax") if obj.get("fax") is not None else 'null',
            "first_name": obj.get("first_name") if obj.get("first_name") is not None else 'null',
            "id": obj.get("id"),
            "last_name": obj.get("last_name") if obj.get("last_name") is not None else 'null',
            "login_id": obj.get("login_id"),
            "mobile": obj.get("mobile") if obj.get("mobile") is not None else 'null',
            "note": obj.get("note") if obj.get("note") is not None else 'null',
            "personal": obj.get("personal") if obj.get("personal") is not None else False,
            "phone_1": obj.get("phone_1") if obj.get("phone_1") is not None else 'null',
            "phone_2": obj.get("phone_2") if obj.get("phone_2") is not None else 'null',
            "salutation": obj.get("salutation"),
            "street": obj.get("street"),
            "suffix_1": obj.get("suffix_1") if obj.get("suffix_1") is not None else 'null',
            "suffix_2": obj.get("suffix_2") if obj.get("suffix_2") is not None else 'null',
            "title": obj.get("title") if obj.get("title") is not None else 'null',
            "zip_code": obj.get("zip_code") if obj.get("zip_code") is not None else 'null',
            "created_at": obj.get("created_at"),
            "updated_at": obj.get("updated_at")
        })
        return _obj


