"""mindbodypublicapi.

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

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


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

    Attributes:
        client_contract_id (int): The ID of the contract.
        charge_amount (float): The amount charged.
        subtotal (float): Subtotal before tax.
        tax (float): Tax amount.
        payment_method (PaymentMethodEnum): The payment method.
        schedule_date (datetime): The date and time of the next payment.
        product_id (int): The product id.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "client_contract_id": "ClientContractId",
        "charge_amount": "ChargeAmount",
        "subtotal": "Subtotal",
        "tax": "Tax",
        "payment_method": "PaymentMethod",
        "schedule_date": "ScheduleDate",
        "product_id": "ProductId",
    }

    _optionals = [
        "client_contract_id",
        "charge_amount",
        "subtotal",
        "tax",
        "payment_method",
        "schedule_date",
        "product_id",
    ]

    def __init__(
        self,
        client_contract_id=APIHelper.SKIP,
        charge_amount=APIHelper.SKIP,
        subtotal=APIHelper.SKIP,
        tax=APIHelper.SKIP,
        payment_method=APIHelper.SKIP,
        schedule_date=APIHelper.SKIP,
        product_id=APIHelper.SKIP):
        """Initialize a UpcomingAutopayEvent instance."""
        # Initialize members of the class
        if client_contract_id is not APIHelper.SKIP:
            self.client_contract_id = client_contract_id
        if charge_amount is not APIHelper.SKIP:
            self.charge_amount = charge_amount
        if subtotal is not APIHelper.SKIP:
            self.subtotal = subtotal
        if tax is not APIHelper.SKIP:
            self.tax = tax
        if payment_method is not APIHelper.SKIP:
            self.payment_method = payment_method
        if schedule_date is not APIHelper.SKIP:
            self.schedule_date =\
                 APIHelper.apply_datetime_converter(
                schedule_date, APIHelper.RFC3339DateTime)\
                 if schedule_date else None
        if product_id is not APIHelper.SKIP:
            self.product_id = product_id

    @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
        charge_amount =\
            dictionary.get("ChargeAmount")\
            if dictionary.get("ChargeAmount")\
                else APIHelper.SKIP
        subtotal =\
            dictionary.get("Subtotal")\
            if dictionary.get("Subtotal")\
                else APIHelper.SKIP
        tax =\
            dictionary.get("Tax")\
            if dictionary.get("Tax")\
                else APIHelper.SKIP
        payment_method =\
            dictionary.get("PaymentMethod")\
            if dictionary.get("PaymentMethod")\
                else APIHelper.SKIP
        schedule_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("ScheduleDate")).datetime\
            if dictionary.get("ScheduleDate") else APIHelper.SKIP
        product_id =\
            dictionary.get("ProductId")\
            if dictionary.get("ProductId")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(client_contract_id,
                   charge_amount,
                   subtotal,
                   tax,
                   payment_method,
                   schedule_date,
                   product_id)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _client_contract_id=(
            self.client_contract_id
            if hasattr(self, "client_contract_id")
            else None
        )
        _charge_amount=(
            self.charge_amount
            if hasattr(self, "charge_amount")
            else None
        )
        _subtotal=(
            self.subtotal
            if hasattr(self, "subtotal")
            else None
        )
        _tax=(
            self.tax
            if hasattr(self, "tax")
            else None
        )
        _payment_method=(
            self.payment_method
            if hasattr(self, "payment_method")
            else None
        )
        _schedule_date=(
            self.schedule_date
            if hasattr(self, "schedule_date")
            else None
        )
        _product_id=(
            self.product_id
            if hasattr(self, "product_id")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"client_contract_id={_client_contract_id!r}, "
            f"charge_amount={_charge_amount!r}, "
            f"subtotal={_subtotal!r}, "
            f"tax={_tax!r}, "
            f"payment_method={_payment_method!r}, "
            f"schedule_date={_schedule_date!r}, "
            f"product_id={_product_id!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
        )
        _charge_amount=(
            self.charge_amount
            if hasattr(self, "charge_amount")
            else None
        )
        _subtotal=(
            self.subtotal
            if hasattr(self, "subtotal")
            else None
        )
        _tax=(
            self.tax
            if hasattr(self, "tax")
            else None
        )
        _payment_method=(
            self.payment_method
            if hasattr(self, "payment_method")
            else None
        )
        _schedule_date=(
            self.schedule_date
            if hasattr(self, "schedule_date")
            else None
        )
        _product_id=(
            self.product_id
            if hasattr(self, "product_id")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"client_contract_id={_client_contract_id!s}, "
            f"charge_amount={_charge_amount!s}, "
            f"subtotal={_subtotal!s}, "
            f"tax={_tax!s}, "
            f"payment_method={_payment_method!s}, "
            f"schedule_date={_schedule_date!s}, "
            f"product_id={_product_id!s}, "
            f")"
        )
