# coding: utf-8

"""
    SRO Master API

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

    The version of the OpenAPI document: 0.1.39
    Contact: info@nexium.me
    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 date
from pydantic import BaseModel, ConfigDict, Field, StrictInt
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from sromaster.models.smr_contracts_contract_status import SMRContractsContractStatus
from sromaster.models.smr_contracts_result import SMRContractsResult
from sromaster.models.smr_contracts_status import SMRContractsStatus
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python

class SMRContractsUpdate(BaseModel):
    """
    SMRContractsUpdate
    """ # noqa: E501
    organisation_id: Optional[StrictInt] = None
    url: Optional[Annotated[str, Field(strict=True, max_length=2048)]] = None
    commercial_offer_asset_id: Optional[StrictInt] = None
    invoice_asset_id: Optional[StrictInt] = None
    contract_asset_id: Optional[StrictInt] = None
    posting_date: Optional[date] = None
    contract_date: Optional[date] = None
    status: Optional[SMRContractsStatus] = None
    contract_status: Optional[SMRContractsContractStatus] = None
    result: Optional[SMRContractsResult] = None
    __properties: ClassVar[List[str]] = ["organisation_id", "url", "commercial_offer_asset_id", "invoice_asset_id", "contract_asset_id", "posting_date", "contract_date", "status", "contract_status", "result"]

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "organisation_id": obj.get("organisation_id"),
            "url": obj.get("url"),
            "commercial_offer_asset_id": obj.get("commercial_offer_asset_id"),
            "invoice_asset_id": obj.get("invoice_asset_id"),
            "contract_asset_id": obj.get("contract_asset_id"),
            "posting_date": obj.get("posting_date"),
            "contract_date": obj.get("contract_date"),
            "status": obj.get("status"),
            "contract_status": obj.get("contract_status"),
            "result": obj.get("result")
        })
        return _obj


