"""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.client_membership import (
    ClientMembership,
)


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

    Attributes:
        client_id (str): ID of the client.
        memberships (List[ClientMembership]): Contains information about the Client
            Memberships details.
        error_message (str): The model property of type str.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "client_id": "ClientId",
        "memberships": "Memberships",
        "error_message": "ErrorMessage",
    }

    _optionals = [
        "client_id",
        "memberships",
        "error_message",
    ]

    def __init__(
        self,
        client_id=APIHelper.SKIP,
        memberships=APIHelper.SKIP,
        error_message=APIHelper.SKIP):
        """Initialize a ClientMemberships instance."""
        # Initialize members of the class
        if client_id is not APIHelper.SKIP:
            self.client_id = client_id
        if memberships is not APIHelper.SKIP:
            self.memberships = memberships
        if error_message is not APIHelper.SKIP:
            self.error_message = error_message

    @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
        memberships = None
        if dictionary.get("Memberships") is not None:
            memberships = [
                ClientMembership.from_dictionary(x)
                    for x in dictionary.get("Memberships")
            ]
        else:
            memberships = APIHelper.SKIP
        error_message =\
            dictionary.get("ErrorMessage")\
            if dictionary.get("ErrorMessage")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(client_id,
                   memberships,
                   error_message)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _client_id=(
            self.client_id
            if hasattr(self, "client_id")
            else None
        )
        _memberships=(
            self.memberships
            if hasattr(self, "memberships")
            else None
        )
        _error_message=(
            self.error_message
            if hasattr(self, "error_message")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"client_id={_client_id!r}, "
            f"memberships={_memberships!r}, "
            f"error_message={_error_message!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _client_id=(
            self.client_id
            if hasattr(self, "client_id")
            else None
        )
        _memberships=(
            self.memberships
            if hasattr(self, "memberships")
            else None
        )
        _error_message=(
            self.error_message
            if hasattr(self, "error_message")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"client_id={_client_id!s}, "
            f"memberships={_memberships!s}, "
            f"error_message={_error_message!s}, "
            f")"
        )
