# coding: utf-8

"""
    Twenty Api

    Twenty is a customer relationship management (CRM) platform designed to help businesses manage their customer interactions and relationships effectively. The Twenty API provides programmatic access to the features and functionalities of the Twenty CRM platform, allowing developers to integrate and interact with the CRM data and operations.

    The version of the OpenAPI document: v0.1
    Contact: felix@twenty.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, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from uuid import UUID
from twentycrm_client.models.attachment_created_by import AttachmentCreatedBy
from twentycrm_client.models.attachment_updated_by import AttachmentUpdatedBy
from twentycrm_client.models.company_address import CompanyAddress
from twentycrm_client.models.company_annual_recurring_revenue import CompanyAnnualRecurringRevenue
from twentycrm_client.models.company_domain_name import CompanyDomainName
from twentycrm_client.models.company_linkedin_link import CompanyLinkedinLink
from twentycrm_client.models.company_x_link import CompanyXLink
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python

class Company(BaseModel):
    """
    A company
    """ # noqa: E501
    name: Optional[StrictStr] = Field(default=None, description="The company name")
    domain_name: Optional[CompanyDomainName] = Field(default=None, alias="domainName")
    address: Optional[CompanyAddress] = None
    employees: Optional[StrictInt] = Field(default=None, description="Number of employees in the company")
    linkedin_link: Optional[CompanyLinkedinLink] = Field(default=None, alias="linkedinLink")
    x_link: Optional[CompanyXLink] = Field(default=None, alias="xLink")
    annual_recurring_revenue: Optional[CompanyAnnualRecurringRevenue] = Field(default=None, alias="annualRecurringRevenue")
    ideal_customer_profile: Optional[StrictBool] = Field(default=None, description="Ideal Customer Profile: Indicates whether the company is the most suitable and valuable customer for you", alias="idealCustomerProfile")
    position: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Company record position")
    created_by: Optional[AttachmentCreatedBy] = Field(default=None, alias="createdBy")
    updated_by: Optional[AttachmentUpdatedBy] = Field(default=None, alias="updatedBy")
    account_owner_id: Optional[UUID] = Field(default=None, alias="accountOwnerId")
    __properties: ClassVar[List[str]] = ["name", "domainName", "address", "employees", "linkedinLink", "xLink", "annualRecurringRevenue", "idealCustomerProfile", "position", "createdBy", "updatedBy", "accountOwnerId"]

    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 Company 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 domain_name
        if self.domain_name:
            _dict['domainName'] = self.domain_name.to_dict()
        # override the default output from pydantic by calling `to_dict()` of address
        if self.address:
            _dict['address'] = self.address.to_dict()
        # override the default output from pydantic by calling `to_dict()` of linkedin_link
        if self.linkedin_link:
            _dict['linkedinLink'] = self.linkedin_link.to_dict()
        # override the default output from pydantic by calling `to_dict()` of x_link
        if self.x_link:
            _dict['xLink'] = self.x_link.to_dict()
        # override the default output from pydantic by calling `to_dict()` of annual_recurring_revenue
        if self.annual_recurring_revenue:
            _dict['annualRecurringRevenue'] = self.annual_recurring_revenue.to_dict()
        # override the default output from pydantic by calling `to_dict()` of created_by
        if self.created_by:
            _dict['createdBy'] = self.created_by.to_dict()
        # override the default output from pydantic by calling `to_dict()` of updated_by
        if self.updated_by:
            _dict['updatedBy'] = self.updated_by.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "name": obj.get("name"),
            "domainName": CompanyDomainName.from_dict(obj["domainName"]) if obj.get("domainName") is not None else None,
            "address": CompanyAddress.from_dict(obj["address"]) if obj.get("address") is not None else None,
            "employees": obj.get("employees"),
            "linkedinLink": CompanyLinkedinLink.from_dict(obj["linkedinLink"]) if obj.get("linkedinLink") is not None else None,
            "xLink": CompanyXLink.from_dict(obj["xLink"]) if obj.get("xLink") is not None else None,
            "annualRecurringRevenue": CompanyAnnualRecurringRevenue.from_dict(obj["annualRecurringRevenue"]) if obj.get("annualRecurringRevenue") is not None else None,
            "idealCustomerProfile": obj.get("idealCustomerProfile"),
            "position": obj.get("position"),
            "createdBy": AttachmentCreatedBy.from_dict(obj["createdBy"]) if obj.get("createdBy") is not None else None,
            "updatedBy": AttachmentUpdatedBy.from_dict(obj["updatedBy"]) if obj.get("updatedBy") is not None else None,
            "accountOwnerId": obj.get("accountOwnerId")
        })
        return _obj


