"""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.payment_processing_failure import (
    PaymentProcessingFailure,
)
from mindbodypublicapi.models.purchase_contract_response_totals import (
    PurchaseContractResponseTotals,
)


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

    Response model for POST PurchaseContract endpoint

    Attributes:
        client_id (str): The ID of the client who is purchasing the contract.
        unique_client_id (int): The Unique ID of the client who is purchasing the
            contract.
        location_id (int): The ID of the location where the contract is being
            purchased.
        contract_id (int): The ID of the general contract being purchased.
        client_contract_id (int): The ID of the specific contract being purchased by
            this specific client, not to be confused with the `ContractId`, which
            refers to a general contract that the business offers.
        totals (PurchaseContractResponseTotals): Totals for the purchase
        payment_processing_failures (List[PaymentProcessingFailure]): Contains
            information only if SCA challenge is indicated.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "client_id": "ClientId",
        "unique_client_id": "UniqueClientId",
        "location_id": "LocationId",
        "contract_id": "ContractId",
        "client_contract_id": "ClientContractId",
        "totals": "Totals",
        "payment_processing_failures": "PaymentProcessingFailures",
    }

    _optionals = [
        "client_id",
        "unique_client_id",
        "location_id",
        "contract_id",
        "client_contract_id",
        "totals",
        "payment_processing_failures",
    ]

    def __init__(
        self,
        client_id=APIHelper.SKIP,
        unique_client_id=APIHelper.SKIP,
        location_id=APIHelper.SKIP,
        contract_id=APIHelper.SKIP,
        client_contract_id=APIHelper.SKIP,
        totals=APIHelper.SKIP,
        payment_processing_failures=APIHelper.SKIP):
        """Initialize a PurchaseContractResponse instance."""
        # Initialize members of the class
        if client_id is not APIHelper.SKIP:
            self.client_id = client_id
        if unique_client_id is not APIHelper.SKIP:
            self.unique_client_id = unique_client_id
        if location_id is not APIHelper.SKIP:
            self.location_id = location_id
        if contract_id is not APIHelper.SKIP:
            self.contract_id = contract_id
        if client_contract_id is not APIHelper.SKIP:
            self.client_contract_id = client_contract_id
        if totals is not APIHelper.SKIP:
            self.totals = totals
        if payment_processing_failures is not APIHelper.SKIP:
            self.payment_processing_failures = payment_processing_failures

    @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 APIHelper.SKIP
        unique_client_id =\
            dictionary.get("UniqueClientId")\
            if dictionary.get("UniqueClientId")\
                else APIHelper.SKIP
        location_id =\
            dictionary.get("LocationId")\
            if dictionary.get("LocationId")\
                else APIHelper.SKIP
        contract_id =\
            dictionary.get("ContractId")\
            if dictionary.get("ContractId")\
                else APIHelper.SKIP
        client_contract_id =\
            dictionary.get("ClientContractId")\
            if dictionary.get("ClientContractId")\
                else APIHelper.SKIP
        totals =\
            PurchaseContractResponseTotals.from_dictionary(
                dictionary.get("Totals"))\
                if "Totals" in dictionary.keys()\
                else APIHelper.SKIP
        payment_processing_failures = None
        if dictionary.get("PaymentProcessingFailures") is not None:
            payment_processing_failures = [
                PaymentProcessingFailure.from_dictionary(x)
                    for x in dictionary.get("PaymentProcessingFailures")
            ]
        else:
            payment_processing_failures = APIHelper.SKIP

        # Return an object of this model
        return cls(client_id,
                   unique_client_id,
                   location_id,
                   contract_id,
                   client_contract_id,
                   totals,
                   payment_processing_failures)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _client_id=(
            self.client_id
            if hasattr(self, "client_id")
            else None
        )
        _unique_client_id=(
            self.unique_client_id
            if hasattr(self, "unique_client_id")
            else None
        )
        _location_id=(
            self.location_id
            if hasattr(self, "location_id")
            else None
        )
        _contract_id=(
            self.contract_id
            if hasattr(self, "contract_id")
            else None
        )
        _client_contract_id=(
            self.client_contract_id
            if hasattr(self, "client_contract_id")
            else None
        )
        _totals=(
            self.totals
            if hasattr(self, "totals")
            else None
        )
        _payment_processing_failures=(
            self.payment_processing_failures
            if hasattr(self, "payment_processing_failures")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"client_id={_client_id!r}, "
            f"unique_client_id={_unique_client_id!r}, "
            f"location_id={_location_id!r}, "
            f"contract_id={_contract_id!r}, "
            f"client_contract_id={_client_contract_id!r}, "
            f"totals={_totals!r}, "
            f"payment_processing_failures={_payment_processing_failures!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _client_id=(
            self.client_id
            if hasattr(self, "client_id")
            else None
        )
        _unique_client_id=(
            self.unique_client_id
            if hasattr(self, "unique_client_id")
            else None
        )
        _location_id=(
            self.location_id
            if hasattr(self, "location_id")
            else None
        )
        _contract_id=(
            self.contract_id
            if hasattr(self, "contract_id")
            else None
        )
        _client_contract_id=(
            self.client_contract_id
            if hasattr(self, "client_contract_id")
            else None
        )
        _totals=(
            self.totals
            if hasattr(self, "totals")
            else None
        )
        _payment_processing_failures=(
            self.payment_processing_failures
            if hasattr(self, "payment_processing_failures")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"client_id={_client_id!s}, "
            f"unique_client_id={_unique_client_id!s}, "
            f"location_id={_location_id!s}, "
            f"contract_id={_contract_id!s}, "
            f"client_contract_id={_client_contract_id!s}, "
            f"totals={_totals!s}, "
            f"payment_processing_failures={_payment_processing_failures!s}, "
            f")"
        )
