"""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.appointment import (
    Appointment,
)
from mindbodypublicapi.models.class_schedule import (
    ClassSchedule,
)
from mindbodypublicapi.models.mclass import (
    Class,
)
from mindbodypublicapi.models.shopping_cart import (
    ShoppingCart,
)


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

    The API Response model for Checkout Shopping Cart APIs

    Attributes:
        shopping_cart (ShoppingCart): Represents a shopping cart.
        classes (List[Class]): Contains information about the classes.
        appointments (List[Appointment]): Contains information about the appointments.
        enrollments (List[ClassSchedule]): Contains information about enrollment
            class schedules.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "shopping_cart": "ShoppingCart",
        "classes": "Classes",
        "appointments": "Appointments",
        "enrollments": "Enrollments",
    }

    _optionals = [
        "shopping_cart",
        "classes",
        "appointments",
        "enrollments",
    ]

    def __init__(
        self,
        shopping_cart=APIHelper.SKIP,
        classes=APIHelper.SKIP,
        appointments=APIHelper.SKIP,
        enrollments=APIHelper.SKIP):
        """Initialize a CheckoutShoppingCartResponse instance."""
        # Initialize members of the class
        if shopping_cart is not APIHelper.SKIP:
            self.shopping_cart = shopping_cart
        if classes is not APIHelper.SKIP:
            self.classes = classes
        if appointments is not APIHelper.SKIP:
            self.appointments = appointments
        if enrollments is not APIHelper.SKIP:
            self.enrollments = enrollments

    @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
        shopping_cart =\
            ShoppingCart.from_dictionary(
                dictionary.get("ShoppingCart"))\
                if "ShoppingCart" in dictionary.keys()\
                else APIHelper.SKIP
        classes = None
        if dictionary.get("Classes") is not None:
            classes = [
                Class.from_dictionary(x)
                    for x in dictionary.get("Classes")
            ]
        else:
            classes = APIHelper.SKIP
        appointments = None
        if dictionary.get("Appointments") is not None:
            appointments = [
                Appointment.from_dictionary(x)
                    for x in dictionary.get("Appointments")
            ]
        else:
            appointments = APIHelper.SKIP
        enrollments = None
        if dictionary.get("Enrollments") is not None:
            enrollments = [
                ClassSchedule.from_dictionary(x)
                    for x in dictionary.get("Enrollments")
            ]
        else:
            enrollments = APIHelper.SKIP

        # Return an object of this model
        return cls(shopping_cart,
                   classes,
                   appointments,
                   enrollments)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _shopping_cart=(
            self.shopping_cart
            if hasattr(self, "shopping_cart")
            else None
        )
        _classes=(
            self.classes
            if hasattr(self, "classes")
            else None
        )
        _appointments=(
            self.appointments
            if hasattr(self, "appointments")
            else None
        )
        _enrollments=(
            self.enrollments
            if hasattr(self, "enrollments")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"shopping_cart={_shopping_cart!r}, "
            f"classes={_classes!r}, "
            f"appointments={_appointments!r}, "
            f"enrollments={_enrollments!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _shopping_cart=(
            self.shopping_cart
            if hasattr(self, "shopping_cart")
            else None
        )
        _classes=(
            self.classes
            if hasattr(self, "classes")
            else None
        )
        _appointments=(
            self.appointments
            if hasattr(self, "appointments")
            else None
        )
        _enrollments=(
            self.enrollments
            if hasattr(self, "enrollments")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"shopping_cart={_shopping_cart!s}, "
            f"classes={_classes!s}, "
            f"appointments={_appointments!s}, "
            f"enrollments={_enrollments!s}, "
            f")"
        )
