"""mindbodypublicapi.

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

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


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

    Attributes:
        client_contract_id (int): Client Contract Id
        autopay_start_date (datetime): Autopay start date
        autopay_end_date (datetime): (optional) - Indefinite if not provided
        product_id (int): Product Id to update (optional if contract has only one
            product)
        replace_with_product_id (int): (optional) - Replaces the product with this
            product
        amount (float): Overrides autopay amount or amount that would come from
            ProductId
        overwrite_all_product_i_ds (bool): (optional) - If true, will update autopays
            with any productID

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "client_contract_id": "ClientContractId",
        "autopay_start_date": "AutopayStartDate",
        "autopay_end_date": "AutopayEndDate",
        "product_id": "ProductId",
        "replace_with_product_id": "ReplaceWithProductId",
        "amount": "Amount",
        "overwrite_all_product_i_ds": "OverwriteAllProductIDs",
    }

    _optionals = [
        "client_contract_id",
        "autopay_start_date",
        "autopay_end_date",
        "product_id",
        "replace_with_product_id",
        "amount",
        "overwrite_all_product_i_ds",
    ]

    def __init__(
        self,
        client_contract_id=APIHelper.SKIP,
        autopay_start_date=APIHelper.SKIP,
        autopay_end_date=APIHelper.SKIP,
        product_id=APIHelper.SKIP,
        replace_with_product_id=APIHelper.SKIP,
        amount=APIHelper.SKIP,
        overwrite_all_product_i_ds=APIHelper.SKIP):
        """Initialize a UpdateClientContractAutopaysRequest instance."""
        # Initialize members of the class
        if client_contract_id is not APIHelper.SKIP:
            self.client_contract_id = client_contract_id
        if autopay_start_date is not APIHelper.SKIP:
            self.autopay_start_date =\
                 APIHelper.apply_datetime_converter(
                autopay_start_date, APIHelper.RFC3339DateTime)\
                 if autopay_start_date else None
        if autopay_end_date is not APIHelper.SKIP:
            self.autopay_end_date =\
                 APIHelper.apply_datetime_converter(
                autopay_end_date, APIHelper.RFC3339DateTime)\
                 if autopay_end_date else None
        if product_id is not APIHelper.SKIP:
            self.product_id = product_id
        if replace_with_product_id is not APIHelper.SKIP:
            self.replace_with_product_id = replace_with_product_id
        if amount is not APIHelper.SKIP:
            self.amount = amount
        if overwrite_all_product_i_ds is not APIHelper.SKIP:
            self.overwrite_all_product_i_ds = overwrite_all_product_i_ds

    @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_contract_id =\
            dictionary.get("ClientContractId")\
            if dictionary.get("ClientContractId")\
                else APIHelper.SKIP
        autopay_start_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("AutopayStartDate")).datetime\
            if dictionary.get("AutopayStartDate") else APIHelper.SKIP
        autopay_end_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("AutopayEndDate")).datetime\
            if dictionary.get("AutopayEndDate") else APIHelper.SKIP
        product_id =\
            dictionary.get("ProductId")\
            if dictionary.get("ProductId")\
                else APIHelper.SKIP
        replace_with_product_id =\
            dictionary.get("ReplaceWithProductId")\
            if dictionary.get("ReplaceWithProductId")\
                else APIHelper.SKIP
        amount =\
            dictionary.get("Amount")\
            if dictionary.get("Amount")\
                else APIHelper.SKIP
        overwrite_all_product_i_ds =\
            dictionary.get("OverwriteAllProductIDs")\
            if "OverwriteAllProductIDs" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(client_contract_id,
                   autopay_start_date,
                   autopay_end_date,
                   product_id,
                   replace_with_product_id,
                   amount,
                   overwrite_all_product_i_ds)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _client_contract_id=(
            self.client_contract_id
            if hasattr(self, "client_contract_id")
            else None
        )
        _autopay_start_date=(
            self.autopay_start_date
            if hasattr(self, "autopay_start_date")
            else None
        )
        _autopay_end_date=(
            self.autopay_end_date
            if hasattr(self, "autopay_end_date")
            else None
        )
        _product_id=(
            self.product_id
            if hasattr(self, "product_id")
            else None
        )
        _replace_with_product_id=(
            self.replace_with_product_id
            if hasattr(self, "replace_with_product_id")
            else None
        )
        _amount=(
            self.amount
            if hasattr(self, "amount")
            else None
        )
        _overwrite_all_product_i_ds=(
            self.overwrite_all_product_i_ds
            if hasattr(self, "overwrite_all_product_i_ds")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"client_contract_id={_client_contract_id!r}, "
            f"autopay_start_date={_autopay_start_date!r}, "
            f"autopay_end_date={_autopay_end_date!r}, "
            f"product_id={_product_id!r}, "
            f"replace_with_product_id={_replace_with_product_id!r}, "
            f"amount={_amount!r}, "
            f"overwrite_all_product_i_ds={_overwrite_all_product_i_ds!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _client_contract_id=(
            self.client_contract_id
            if hasattr(self, "client_contract_id")
            else None
        )
        _autopay_start_date=(
            self.autopay_start_date
            if hasattr(self, "autopay_start_date")
            else None
        )
        _autopay_end_date=(
            self.autopay_end_date
            if hasattr(self, "autopay_end_date")
            else None
        )
        _product_id=(
            self.product_id
            if hasattr(self, "product_id")
            else None
        )
        _replace_with_product_id=(
            self.replace_with_product_id
            if hasattr(self, "replace_with_product_id")
            else None
        )
        _amount=(
            self.amount
            if hasattr(self, "amount")
            else None
        )
        _overwrite_all_product_i_ds=(
            self.overwrite_all_product_i_ds
            if hasattr(self, "overwrite_all_product_i_ds")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"client_contract_id={_client_contract_id!s}, "
            f"autopay_start_date={_autopay_start_date!s}, "
            f"autopay_end_date={_autopay_end_date!s}, "
            f"product_id={_product_id!s}, "
            f"replace_with_product_id={_replace_with_product_id!s}, "
            f"amount={_amount!s}, "
            f"overwrite_all_product_i_ds={_overwrite_all_product_i_ds!s}, "
            f")"
        )
