# coding: utf-8

"""
    Cyberwave API

    Cyberwave platform REST API. Use 'Bearer YOUR_TOKEN' for authentication.

    The version of the OpenAPI document: 1.0.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 datetime import datetime
from pydantic import BaseModel, ConfigDict, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing import Optional, Set
from typing_extensions import Self

class OpportunitySchema(BaseModel):
    """
    OpportunitySchema
    """ # noqa: E501
    uuid: StrictStr
    name: StrictStr
    description: StrictStr
    opportunity_type: StrictStr
    stage: StrictStr
    value: Optional[Union[StrictFloat, StrictInt]] = None
    contact_name: StrictStr
    contact_email: StrictStr
    company_name: StrictStr
    expected_close_date: Optional[StrictStr] = None
    notes: StrictStr
    metadata: Dict[str, Any]
    year: StrictInt
    is_archived: StrictBool
    sort_order: StrictInt
    owner_uuid: StrictStr
    organization_uuid: StrictStr
    workspace_uuid: Optional[StrictStr] = None
    workspace_name: Optional[StrictStr] = None
    assigned_to_uuid: Optional[StrictStr] = None
    assigned_to_name: Optional[StrictStr] = None
    created_at: datetime
    updated_at: datetime
    created_by: StrictStr
    created_by_name: Optional[StrictStr] = None
    updated_by: StrictStr
    __properties: ClassVar[List[str]] = ["uuid", "name", "description", "opportunity_type", "stage", "value", "contact_name", "contact_email", "company_name", "expected_close_date", "notes", "metadata", "year", "is_archived", "sort_order", "owner_uuid", "organization_uuid", "workspace_uuid", "workspace_name", "assigned_to_uuid", "assigned_to_name", "created_at", "updated_at", "created_by", "created_by_name", "updated_by"]

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "uuid": obj.get("uuid"),
            "name": obj.get("name"),
            "description": obj.get("description"),
            "opportunity_type": obj.get("opportunity_type"),
            "stage": obj.get("stage"),
            "value": obj.get("value"),
            "contact_name": obj.get("contact_name"),
            "contact_email": obj.get("contact_email"),
            "company_name": obj.get("company_name"),
            "expected_close_date": obj.get("expected_close_date"),
            "notes": obj.get("notes"),
            "metadata": obj.get("metadata"),
            "year": obj.get("year"),
            "is_archived": obj.get("is_archived"),
            "sort_order": obj.get("sort_order"),
            "owner_uuid": obj.get("owner_uuid"),
            "organization_uuid": obj.get("organization_uuid"),
            "workspace_uuid": obj.get("workspace_uuid"),
            "workspace_name": obj.get("workspace_name"),
            "assigned_to_uuid": obj.get("assigned_to_uuid"),
            "assigned_to_name": obj.get("assigned_to_name"),
            "created_at": obj.get("created_at"),
            "updated_at": obj.get("updated_at"),
            "created_by": obj.get("created_by"),
            "created_by_name": obj.get("created_by_name"),
            "updated_by": obj.get("updated_by")
        })
        return _obj


