"""mindbodypublicapi.

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

# ruff: noqa: E501
from mindbodypublicapi.api_helper import APIHelper
from mindbodypublicapi.models.upcoming_autopay_event import (
    UpcomingAutopayEvent,
)


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

    A client contract.

    Attributes:
        agreement_date (datetime): The date on which the contract was signed.
        autopay_status (AutopayStatusEnum): The status of the client’s autopay.
        auto_renewing (bool): Determines if the contract is auto-renewing.
        first_auto_pay (float): The amount of the first autopay transaction.
        last_auto_pay (float): The amount of the last autopay transaction.
        normal_auto_pay (float): The amount of the normal recurring autopay
            transaction.
        is_month_to_month (bool): Indicates if the contract renews on a
            month-to-month basis.
        auto_renew_client_contract_id (int): The ID of the contract that this one
            auto-renews from.
        contract_text (str): The full text of the contract.
        contract_auto_renewed (bool): Indicates whether the contract was auto-renewed
            from a previous one.
        contract_name (str): The name of the contract.
        end_date (datetime): The date that the contract expires.
        id (int): The unique ID of the sale of the contract. Each time a contract is
            sold, this ID increases sequentially.
        origination_location_id (int): The ID of the location where the contract was
            issued.
        start_date (datetime): The date that the contract became active.
        site_id (int): The ID of the site where the contract was issued.
        upcoming_autopay_events (List[UpcomingAutopayEvent]): Contains details of the
            autopay events.
        contract_id (int): The ID of the contract.
        termination_date (datetime): The date that the contract was terminated.
        minimum_commitment_value (int): Minimum commitment value.
        minimum_commitment_unit (MinimumCommitmentUnitEnum): Minimum commitment unit
            type.
        minimum_commitment_end_date (datetime): The earliest date a contract
            termination can take effect if a minimum commitment applies.  This
            represents the last day the client is obligated to remain on the
            contract.  Returned even if the commitment has already been fulfilled.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "agreement_date": "AgreementDate",
        "autopay_status": "AutopayStatus",
        "auto_renewing": "AutoRenewing",
        "first_auto_pay": "FirstAutoPay",
        "last_auto_pay": "LastAutoPay",
        "normal_auto_pay": "NormalAutoPay",
        "is_month_to_month": "IsMonthToMonth",
        "auto_renew_client_contract_id": "AutoRenewClientContractID",
        "contract_text": "ContractText",
        "contract_auto_renewed": "ContractAutoRenewed",
        "contract_name": "ContractName",
        "end_date": "EndDate",
        "id": "Id",
        "origination_location_id": "OriginationLocationId",
        "start_date": "StartDate",
        "site_id": "SiteId",
        "upcoming_autopay_events": "UpcomingAutopayEvents",
        "contract_id": "ContractID",
        "termination_date": "TerminationDate",
        "minimum_commitment_value": "MinimumCommitmentValue",
        "minimum_commitment_unit": "MinimumCommitmentUnit",
        "minimum_commitment_end_date": "MinimumCommitmentEndDate",
    }

    _optionals = [
        "agreement_date",
        "autopay_status",
        "auto_renewing",
        "first_auto_pay",
        "last_auto_pay",
        "normal_auto_pay",
        "is_month_to_month",
        "auto_renew_client_contract_id",
        "contract_text",
        "contract_auto_renewed",
        "contract_name",
        "end_date",
        "id",
        "origination_location_id",
        "start_date",
        "site_id",
        "upcoming_autopay_events",
        "contract_id",
        "termination_date",
        "minimum_commitment_value",
        "minimum_commitment_unit",
        "minimum_commitment_end_date",
    ]

    def __init__(
        self,
        agreement_date=APIHelper.SKIP,
        autopay_status=APIHelper.SKIP,
        auto_renewing=APIHelper.SKIP,
        first_auto_pay=APIHelper.SKIP,
        last_auto_pay=APIHelper.SKIP,
        normal_auto_pay=APIHelper.SKIP,
        is_month_to_month=APIHelper.SKIP,
        auto_renew_client_contract_id=APIHelper.SKIP,
        contract_text=APIHelper.SKIP,
        contract_auto_renewed=APIHelper.SKIP,
        contract_name=APIHelper.SKIP,
        end_date=APIHelper.SKIP,
        id=APIHelper.SKIP,
        origination_location_id=APIHelper.SKIP,
        start_date=APIHelper.SKIP,
        site_id=APIHelper.SKIP,
        upcoming_autopay_events=APIHelper.SKIP,
        contract_id=APIHelper.SKIP,
        termination_date=APIHelper.SKIP,
        minimum_commitment_value=APIHelper.SKIP,
        minimum_commitment_unit=APIHelper.SKIP,
        minimum_commitment_end_date=APIHelper.SKIP):
        """Initialize a ClientContract instance."""
        # Initialize members of the class
        if agreement_date is not APIHelper.SKIP:
            self.agreement_date =\
                 APIHelper.apply_datetime_converter(
                agreement_date, APIHelper.RFC3339DateTime)\
                 if agreement_date else None
        if autopay_status is not APIHelper.SKIP:
            self.autopay_status = autopay_status
        if auto_renewing is not APIHelper.SKIP:
            self.auto_renewing = auto_renewing
        if first_auto_pay is not APIHelper.SKIP:
            self.first_auto_pay = first_auto_pay
        if last_auto_pay is not APIHelper.SKIP:
            self.last_auto_pay = last_auto_pay
        if normal_auto_pay is not APIHelper.SKIP:
            self.normal_auto_pay = normal_auto_pay
        if is_month_to_month is not APIHelper.SKIP:
            self.is_month_to_month = is_month_to_month
        if auto_renew_client_contract_id is not APIHelper.SKIP:
            self.auto_renew_client_contract_id = auto_renew_client_contract_id
        if contract_text is not APIHelper.SKIP:
            self.contract_text = contract_text
        if contract_auto_renewed is not APIHelper.SKIP:
            self.contract_auto_renewed = contract_auto_renewed
        if contract_name is not APIHelper.SKIP:
            self.contract_name = contract_name
        if end_date is not APIHelper.SKIP:
            self.end_date =\
                 APIHelper.apply_datetime_converter(
                end_date, APIHelper.RFC3339DateTime)\
                 if end_date else None
        if id is not APIHelper.SKIP:
            self.id = id
        if origination_location_id is not APIHelper.SKIP:
            self.origination_location_id = origination_location_id
        if start_date is not APIHelper.SKIP:
            self.start_date =\
                 APIHelper.apply_datetime_converter(
                start_date, APIHelper.RFC3339DateTime)\
                 if start_date else None
        if site_id is not APIHelper.SKIP:
            self.site_id = site_id
        if upcoming_autopay_events is not APIHelper.SKIP:
            self.upcoming_autopay_events = upcoming_autopay_events
        if contract_id is not APIHelper.SKIP:
            self.contract_id = contract_id
        if termination_date is not APIHelper.SKIP:
            self.termination_date =\
                 APIHelper.apply_datetime_converter(
                termination_date, APIHelper.RFC3339DateTime)\
                 if termination_date else None
        if minimum_commitment_value is not APIHelper.SKIP:
            self.minimum_commitment_value = minimum_commitment_value
        if minimum_commitment_unit is not APIHelper.SKIP:
            self.minimum_commitment_unit = minimum_commitment_unit
        if minimum_commitment_end_date is not APIHelper.SKIP:
            self.minimum_commitment_end_date =\
                 APIHelper.apply_datetime_converter(
                minimum_commitment_end_date, APIHelper.RFC3339DateTime)\
                 if minimum_commitment_end_date else None

    @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
        agreement_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("AgreementDate")).datetime\
            if dictionary.get("AgreementDate") else APIHelper.SKIP
        autopay_status =\
            dictionary.get("AutopayStatus")\
            if dictionary.get("AutopayStatus")\
                else APIHelper.SKIP
        auto_renewing =\
            dictionary.get("AutoRenewing")\
            if "AutoRenewing" in dictionary.keys()\
                else APIHelper.SKIP
        first_auto_pay =\
            dictionary.get("FirstAutoPay")\
            if dictionary.get("FirstAutoPay")\
                else APIHelper.SKIP
        last_auto_pay =\
            dictionary.get("LastAutoPay")\
            if dictionary.get("LastAutoPay")\
                else APIHelper.SKIP
        normal_auto_pay =\
            dictionary.get("NormalAutoPay")\
            if dictionary.get("NormalAutoPay")\
                else APIHelper.SKIP
        is_month_to_month =\
            dictionary.get("IsMonthToMonth")\
            if "IsMonthToMonth" in dictionary.keys()\
                else APIHelper.SKIP
        auto_renew_client_contract_id =\
            dictionary.get("AutoRenewClientContractID")\
            if dictionary.get("AutoRenewClientContractID")\
                else APIHelper.SKIP
        contract_text =\
            dictionary.get("ContractText")\
            if dictionary.get("ContractText")\
                else APIHelper.SKIP
        contract_auto_renewed =\
            dictionary.get("ContractAutoRenewed")\
            if "ContractAutoRenewed" in dictionary.keys()\
                else APIHelper.SKIP
        contract_name =\
            dictionary.get("ContractName")\
            if dictionary.get("ContractName")\
                else APIHelper.SKIP
        end_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("EndDate")).datetime\
            if dictionary.get("EndDate") else APIHelper.SKIP
        id =\
            dictionary.get("Id")\
            if dictionary.get("Id")\
                else APIHelper.SKIP
        origination_location_id =\
            dictionary.get("OriginationLocationId")\
            if dictionary.get("OriginationLocationId")\
                else APIHelper.SKIP
        start_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("StartDate")).datetime\
            if dictionary.get("StartDate") else APIHelper.SKIP
        site_id =\
            dictionary.get("SiteId")\
            if dictionary.get("SiteId")\
                else APIHelper.SKIP
        upcoming_autopay_events = None
        if dictionary.get("UpcomingAutopayEvents") is not None:
            upcoming_autopay_events = [
                UpcomingAutopayEvent.from_dictionary(x)
                    for x in dictionary.get("UpcomingAutopayEvents")
            ]
        else:
            upcoming_autopay_events = APIHelper.SKIP
        contract_id =\
            dictionary.get("ContractID")\
            if dictionary.get("ContractID")\
                else APIHelper.SKIP
        termination_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("TerminationDate")).datetime\
            if dictionary.get("TerminationDate") else APIHelper.SKIP
        minimum_commitment_value =\
            dictionary.get("MinimumCommitmentValue")\
            if dictionary.get("MinimumCommitmentValue")\
                else APIHelper.SKIP
        minimum_commitment_unit =\
            dictionary.get("MinimumCommitmentUnit")\
            if dictionary.get("MinimumCommitmentUnit")\
                else APIHelper.SKIP
        minimum_commitment_end_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("MinimumCommitmentEndDate")).datetime\
            if dictionary.get("MinimumCommitmentEndDate") else APIHelper.SKIP

        # Return an object of this model
        return cls(agreement_date,
                   autopay_status,
                   auto_renewing,
                   first_auto_pay,
                   last_auto_pay,
                   normal_auto_pay,
                   is_month_to_month,
                   auto_renew_client_contract_id,
                   contract_text,
                   contract_auto_renewed,
                   contract_name,
                   end_date,
                   id,
                   origination_location_id,
                   start_date,
                   site_id,
                   upcoming_autopay_events,
                   contract_id,
                   termination_date,
                   minimum_commitment_value,
                   minimum_commitment_unit,
                   minimum_commitment_end_date)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _agreement_date=(
            self.agreement_date
            if hasattr(self, "agreement_date")
            else None
        )
        _autopay_status=(
            self.autopay_status
            if hasattr(self, "autopay_status")
            else None
        )
        _auto_renewing=(
            self.auto_renewing
            if hasattr(self, "auto_renewing")
            else None
        )
        _first_auto_pay=(
            self.first_auto_pay
            if hasattr(self, "first_auto_pay")
            else None
        )
        _last_auto_pay=(
            self.last_auto_pay
            if hasattr(self, "last_auto_pay")
            else None
        )
        _normal_auto_pay=(
            self.normal_auto_pay
            if hasattr(self, "normal_auto_pay")
            else None
        )
        _is_month_to_month=(
            self.is_month_to_month
            if hasattr(self, "is_month_to_month")
            else None
        )
        _auto_renew_client_contract_id=(
            self.auto_renew_client_contract_id
            if hasattr(self, "auto_renew_client_contract_id")
            else None
        )
        _contract_text=(
            self.contract_text
            if hasattr(self, "contract_text")
            else None
        )
        _contract_auto_renewed=(
            self.contract_auto_renewed
            if hasattr(self, "contract_auto_renewed")
            else None
        )
        _contract_name=(
            self.contract_name
            if hasattr(self, "contract_name")
            else None
        )
        _end_date=(
            self.end_date
            if hasattr(self, "end_date")
            else None
        )
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _origination_location_id=(
            self.origination_location_id
            if hasattr(self, "origination_location_id")
            else None
        )
        _start_date=(
            self.start_date
            if hasattr(self, "start_date")
            else None
        )
        _site_id=(
            self.site_id
            if hasattr(self, "site_id")
            else None
        )
        _upcoming_autopay_events=(
            self.upcoming_autopay_events
            if hasattr(self, "upcoming_autopay_events")
            else None
        )
        _contract_id=(
            self.contract_id
            if hasattr(self, "contract_id")
            else None
        )
        _termination_date=(
            self.termination_date
            if hasattr(self, "termination_date")
            else None
        )
        _minimum_commitment_value=(
            self.minimum_commitment_value
            if hasattr(self, "minimum_commitment_value")
            else None
        )
        _minimum_commitment_unit=(
            self.minimum_commitment_unit
            if hasattr(self, "minimum_commitment_unit")
            else None
        )
        _minimum_commitment_end_date=(
            self.minimum_commitment_end_date
            if hasattr(self, "minimum_commitment_end_date")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"agreement_date={_agreement_date!r}, "
            f"autopay_status={_autopay_status!r}, "
            f"auto_renewing={_auto_renewing!r}, "
            f"first_auto_pay={_first_auto_pay!r}, "
            f"last_auto_pay={_last_auto_pay!r}, "
            f"normal_auto_pay={_normal_auto_pay!r}, "
            f"is_month_to_month={_is_month_to_month!r}, "
            f"auto_renew_client_contract_id={_auto_renew_client_contract_id!r}, "
            f"contract_text={_contract_text!r}, "
            f"contract_auto_renewed={_contract_auto_renewed!r}, "
            f"contract_name={_contract_name!r}, "
            f"end_date={_end_date!r}, "
            f"id={_id!r}, "
            f"origination_location_id={_origination_location_id!r}, "
            f"start_date={_start_date!r}, "
            f"site_id={_site_id!r}, "
            f"upcoming_autopay_events={_upcoming_autopay_events!r}, "
            f"contract_id={_contract_id!r}, "
            f"termination_date={_termination_date!r}, "
            f"minimum_commitment_value={_minimum_commitment_value!r}, "
            f"minimum_commitment_unit={_minimum_commitment_unit!r}, "
            f"minimum_commitment_end_date={_minimum_commitment_end_date!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _agreement_date=(
            self.agreement_date
            if hasattr(self, "agreement_date")
            else None
        )
        _autopay_status=(
            self.autopay_status
            if hasattr(self, "autopay_status")
            else None
        )
        _auto_renewing=(
            self.auto_renewing
            if hasattr(self, "auto_renewing")
            else None
        )
        _first_auto_pay=(
            self.first_auto_pay
            if hasattr(self, "first_auto_pay")
            else None
        )
        _last_auto_pay=(
            self.last_auto_pay
            if hasattr(self, "last_auto_pay")
            else None
        )
        _normal_auto_pay=(
            self.normal_auto_pay
            if hasattr(self, "normal_auto_pay")
            else None
        )
        _is_month_to_month=(
            self.is_month_to_month
            if hasattr(self, "is_month_to_month")
            else None
        )
        _auto_renew_client_contract_id=(
            self.auto_renew_client_contract_id
            if hasattr(self, "auto_renew_client_contract_id")
            else None
        )
        _contract_text=(
            self.contract_text
            if hasattr(self, "contract_text")
            else None
        )
        _contract_auto_renewed=(
            self.contract_auto_renewed
            if hasattr(self, "contract_auto_renewed")
            else None
        )
        _contract_name=(
            self.contract_name
            if hasattr(self, "contract_name")
            else None
        )
        _end_date=(
            self.end_date
            if hasattr(self, "end_date")
            else None
        )
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _origination_location_id=(
            self.origination_location_id
            if hasattr(self, "origination_location_id")
            else None
        )
        _start_date=(
            self.start_date
            if hasattr(self, "start_date")
            else None
        )
        _site_id=(
            self.site_id
            if hasattr(self, "site_id")
            else None
        )
        _upcoming_autopay_events=(
            self.upcoming_autopay_events
            if hasattr(self, "upcoming_autopay_events")
            else None
        )
        _contract_id=(
            self.contract_id
            if hasattr(self, "contract_id")
            else None
        )
        _termination_date=(
            self.termination_date
            if hasattr(self, "termination_date")
            else None
        )
        _minimum_commitment_value=(
            self.minimum_commitment_value
            if hasattr(self, "minimum_commitment_value")
            else None
        )
        _minimum_commitment_unit=(
            self.minimum_commitment_unit
            if hasattr(self, "minimum_commitment_unit")
            else None
        )
        _minimum_commitment_end_date=(
            self.minimum_commitment_end_date
            if hasattr(self, "minimum_commitment_end_date")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"agreement_date={_agreement_date!s}, "
            f"autopay_status={_autopay_status!s}, "
            f"auto_renewing={_auto_renewing!s}, "
            f"first_auto_pay={_first_auto_pay!s}, "
            f"last_auto_pay={_last_auto_pay!s}, "
            f"normal_auto_pay={_normal_auto_pay!s}, "
            f"is_month_to_month={_is_month_to_month!s}, "
            f"auto_renew_client_contract_id={_auto_renew_client_contract_id!s}, "
            f"contract_text={_contract_text!s}, "
            f"contract_auto_renewed={_contract_auto_renewed!s}, "
            f"contract_name={_contract_name!s}, "
            f"end_date={_end_date!s}, "
            f"id={_id!s}, "
            f"origination_location_id={_origination_location_id!s}, "
            f"start_date={_start_date!s}, "
            f"site_id={_site_id!s}, "
            f"upcoming_autopay_events={_upcoming_autopay_events!s}, "
            f"contract_id={_contract_id!s}, "
            f"termination_date={_termination_date!s}, "
            f"minimum_commitment_value={_minimum_commitment_value!s}, "
            f"minimum_commitment_unit={_minimum_commitment_unit!s}, "
            f"minimum_commitment_end_date={_minimum_commitment_end_date!s}, "
            f")"
        )
