"""mindbodypublicapi.

This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
"""

# ruff: noqa: E501
from mindbodypublicapi.api_helper import APIHelper


class TerminateContractRequest(object):
    """Implementation of the 'TerminateContractRequest' model.

    Attributes:
        client_id (str): The ID of the client.
        client_contract_id (int): The unique ID of the sale of the contract
        termination_date (datetime): The contract termination date.
        termination_code (str): ex. Illness, Injury, Moving, BreakingContract (Note
            this can be customized by each studio).
        termination_comments (str): The comments for terminating a contract.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "client_id": "ClientId",
        "client_contract_id": "ClientContractId",
        "termination_date": "TerminationDate",
        "termination_code": "TerminationCode",
        "termination_comments": "TerminationComments",
    }

    _optionals = [
        "termination_code",
        "termination_comments",
    ]

    def __init__(
        self,
        client_id=None,
        client_contract_id=None,
        termination_date=None,
        termination_code=APIHelper.SKIP,
        termination_comments=APIHelper.SKIP):
        """Initialize a TerminateContractRequest instance."""
        # Initialize members of the class
        self.client_id = client_id
        self.client_contract_id = client_contract_id
        self.termination_date =\
             APIHelper.apply_datetime_converter(
            termination_date, APIHelper.RFC3339DateTime)\
             if termination_date else None
        if termination_code is not APIHelper.SKIP:
            self.termination_code = termination_code
        if termination_comments is not APIHelper.SKIP:
            self.termination_comments = termination_comments

    @classmethod
    def from_dictionary(cls,
                        dictionary):
        """Create an instance of this model from a dictionary

        Args:
            dictionary (dictionary): A dictionary representation of the object
            as obtained from the deserialization of the server's response. The
            keys MUST match property names in the API description.

        Returns:
            object: An instance of this structure class.

        """
        if not isinstance(dictionary, dict) or dictionary is None:
            return None

        # Extract variables from the dictionary
        client_id =\
            dictionary.get("ClientId")\
            if dictionary.get("ClientId")\
                else None
        client_contract_id =\
            dictionary.get("ClientContractId")\
            if dictionary.get("ClientContractId")\
                else None
        termination_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("TerminationDate")).datetime\
            if dictionary.get("TerminationDate") else None
        termination_code =\
            dictionary.get("TerminationCode")\
            if dictionary.get("TerminationCode")\
                else APIHelper.SKIP
        termination_comments =\
            dictionary.get("TerminationComments")\
            if dictionary.get("TerminationComments")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(client_id,
                   client_contract_id,
                   termination_date,
                   termination_code,
                   termination_comments)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _client_id=self.client_id
        _client_contract_id=self.client_contract_id
        _termination_date=self.termination_date
        _termination_code=(
            self.termination_code
            if hasattr(self, "termination_code")
            else None
        )
        _termination_comments=(
            self.termination_comments
            if hasattr(self, "termination_comments")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"client_id={_client_id!r}, "
            f"client_contract_id={_client_contract_id!r}, "
            f"termination_date={_termination_date!r}, "
            f"termination_code={_termination_code!r}, "
            f"termination_comments={_termination_comments!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _client_id=self.client_id
        _client_contract_id=self.client_contract_id
        _termination_date=self.termination_date
        _termination_code=(
            self.termination_code
            if hasattr(self, "termination_code")
            else None
        )
        _termination_comments=(
            self.termination_comments
            if hasattr(self, "termination_comments")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"client_id={_client_id!s}, "
            f"client_contract_id={_client_contract_id!s}, "
            f"termination_date={_termination_date!s}, "
            f"termination_code={_termination_code!s}, "
            f"termination_comments={_termination_comments!s}, "
            f")"
        )
