"""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.location import (
    Location,
)
from mindbodypublicapi.models.program import (
    Program,
)


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

    Attributes:
        restricted_locations (List[Location]): The locations that the membership is
            restricted to, if any.  Please note that client memberships with location
            restrictions can only be used to pay for scheduled services at the site
            to which they belong. Memberships with location restrictions can not be
            used to pay for scheduled services at other sites within an organization.
        icon_code (str): Text code that represents the `MembershipIcon`.
        membership_id (int): The membership's ID.
        active_date (datetime): The date that this pricing option became active and
            could be used to pay for services.
        count (int): The number of service sessions this pricing option contained
            when first purchased.
        current (bool): When `true`, there are service sessions remaining on the
            pricing option that can be used pay for the current session.<br />  When
            `false`, the client cannot use this pricing option to pay for other
            services.
        expiration_date (datetime): The date when the pricing option expires and can
            no longer be used to pay for services, even if unused service sessions
            remain on the option; expressed as UTC.
        id (int): The unique ID assigned to this pricing option, specific to when it
            was purchased by the client.
        product_id (int): The unique ID of this pricing option, not specific to any
            client's purchase of it.
        name (str): The name of this pricing option.
        payment_date (datetime): The date on which the client paid for this pricing
            option.
        program (Program): The model property of type Program.
        remaining (int): The number of service sessions remaining in the pricing
            option that can still be used.
        site_id (int): The ID of the subscriber site associated with this pricing
            option.
        action (Action1Enum): The action taken.
        client_id (str): The Client ID assigned to this pricing option, specific to
            when it was purchased by the client.
        returned (bool): Identification for purchased service is returned or not.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "restricted_locations": "RestrictedLocations",
        "icon_code": "IconCode",
        "membership_id": "MembershipId",
        "active_date": "ActiveDate",
        "count": "Count",
        "current": "Current",
        "expiration_date": "ExpirationDate",
        "id": "Id",
        "product_id": "ProductId",
        "name": "Name",
        "payment_date": "PaymentDate",
        "program": "Program",
        "remaining": "Remaining",
        "site_id": "SiteId",
        "action": "Action",
        "client_id": "ClientID",
        "returned": "Returned",
    }

    _optionals = [
        "restricted_locations",
        "icon_code",
        "membership_id",
        "active_date",
        "count",
        "current",
        "expiration_date",
        "id",
        "product_id",
        "name",
        "payment_date",
        "program",
        "remaining",
        "site_id",
        "action",
        "client_id",
        "returned",
    ]

    def __init__(
        self,
        restricted_locations=APIHelper.SKIP,
        icon_code=APIHelper.SKIP,
        membership_id=APIHelper.SKIP,
        active_date=APIHelper.SKIP,
        count=APIHelper.SKIP,
        current=APIHelper.SKIP,
        expiration_date=APIHelper.SKIP,
        id=APIHelper.SKIP,
        product_id=APIHelper.SKIP,
        name=APIHelper.SKIP,
        payment_date=APIHelper.SKIP,
        program=APIHelper.SKIP,
        remaining=APIHelper.SKIP,
        site_id=APIHelper.SKIP,
        action=APIHelper.SKIP,
        client_id=APIHelper.SKIP,
        returned=APIHelper.SKIP):
        """Initialize a ClientMembership instance."""
        # Initialize members of the class
        if restricted_locations is not APIHelper.SKIP:
            self.restricted_locations = restricted_locations
        if icon_code is not APIHelper.SKIP:
            self.icon_code = icon_code
        if membership_id is not APIHelper.SKIP:
            self.membership_id = membership_id
        if active_date is not APIHelper.SKIP:
            self.active_date =\
                 APIHelper.apply_datetime_converter(
                active_date, APIHelper.RFC3339DateTime)\
                 if active_date else None
        if count is not APIHelper.SKIP:
            self.count = count
        if current is not APIHelper.SKIP:
            self.current = current
        if expiration_date is not APIHelper.SKIP:
            self.expiration_date =\
                 APIHelper.apply_datetime_converter(
                expiration_date, APIHelper.RFC3339DateTime)\
                 if expiration_date else None
        if id is not APIHelper.SKIP:
            self.id = id
        if product_id is not APIHelper.SKIP:
            self.product_id = product_id
        if name is not APIHelper.SKIP:
            self.name = name
        if payment_date is not APIHelper.SKIP:
            self.payment_date =\
                 APIHelper.apply_datetime_converter(
                payment_date, APIHelper.RFC3339DateTime)\
                 if payment_date else None
        if program is not APIHelper.SKIP:
            self.program = program
        if remaining is not APIHelper.SKIP:
            self.remaining = remaining
        if site_id is not APIHelper.SKIP:
            self.site_id = site_id
        if action is not APIHelper.SKIP:
            self.action = action
        if client_id is not APIHelper.SKIP:
            self.client_id = client_id
        if returned is not APIHelper.SKIP:
            self.returned = returned

    @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
        restricted_locations = None
        if dictionary.get("RestrictedLocations") is not None:
            restricted_locations = [
                Location.from_dictionary(x)
                    for x in dictionary.get("RestrictedLocations")
            ]
        else:
            restricted_locations = APIHelper.SKIP
        icon_code =\
            dictionary.get("IconCode")\
            if dictionary.get("IconCode")\
                else APIHelper.SKIP
        membership_id =\
            dictionary.get("MembershipId")\
            if dictionary.get("MembershipId")\
                else APIHelper.SKIP
        active_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("ActiveDate")).datetime\
            if dictionary.get("ActiveDate") else APIHelper.SKIP
        count =\
            dictionary.get("Count")\
            if dictionary.get("Count")\
                else APIHelper.SKIP
        current =\
            dictionary.get("Current")\
            if "Current" in dictionary.keys()\
                else APIHelper.SKIP
        expiration_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("ExpirationDate")).datetime\
            if dictionary.get("ExpirationDate") else APIHelper.SKIP
        id =\
            dictionary.get("Id")\
            if dictionary.get("Id")\
                else APIHelper.SKIP
        product_id =\
            dictionary.get("ProductId")\
            if dictionary.get("ProductId")\
                else APIHelper.SKIP
        name =\
            dictionary.get("Name")\
            if dictionary.get("Name")\
                else APIHelper.SKIP
        payment_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("PaymentDate")).datetime\
            if dictionary.get("PaymentDate") else APIHelper.SKIP
        program =\
            Program.from_dictionary(
                dictionary.get("Program"))\
                if "Program" in dictionary.keys()\
                else APIHelper.SKIP
        remaining =\
            dictionary.get("Remaining")\
            if dictionary.get("Remaining")\
                else APIHelper.SKIP
        site_id =\
            dictionary.get("SiteId")\
            if dictionary.get("SiteId")\
                else APIHelper.SKIP
        action =\
            dictionary.get("Action")\
            if dictionary.get("Action")\
                else APIHelper.SKIP
        client_id =\
            dictionary.get("ClientID")\
            if dictionary.get("ClientID")\
                else APIHelper.SKIP
        returned =\
            dictionary.get("Returned")\
            if "Returned" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(restricted_locations,
                   icon_code,
                   membership_id,
                   active_date,
                   count,
                   current,
                   expiration_date,
                   id,
                   product_id,
                   name,
                   payment_date,
                   program,
                   remaining,
                   site_id,
                   action,
                   client_id,
                   returned)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _restricted_locations=(
            self.restricted_locations
            if hasattr(self, "restricted_locations")
            else None
        )
        _icon_code=(
            self.icon_code
            if hasattr(self, "icon_code")
            else None
        )
        _membership_id=(
            self.membership_id
            if hasattr(self, "membership_id")
            else None
        )
        _active_date=(
            self.active_date
            if hasattr(self, "active_date")
            else None
        )
        _count=(
            self.count
            if hasattr(self, "count")
            else None
        )
        _current=(
            self.current
            if hasattr(self, "current")
            else None
        )
        _expiration_date=(
            self.expiration_date
            if hasattr(self, "expiration_date")
            else None
        )
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _product_id=(
            self.product_id
            if hasattr(self, "product_id")
            else None
        )
        _name=(
            self.name
            if hasattr(self, "name")
            else None
        )
        _payment_date=(
            self.payment_date
            if hasattr(self, "payment_date")
            else None
        )
        _program=(
            self.program
            if hasattr(self, "program")
            else None
        )
        _remaining=(
            self.remaining
            if hasattr(self, "remaining")
            else None
        )
        _site_id=(
            self.site_id
            if hasattr(self, "site_id")
            else None
        )
        _action=(
            self.action
            if hasattr(self, "action")
            else None
        )
        _client_id=(
            self.client_id
            if hasattr(self, "client_id")
            else None
        )
        _returned=(
            self.returned
            if hasattr(self, "returned")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"restricted_locations={_restricted_locations!r}, "
            f"icon_code={_icon_code!r}, "
            f"membership_id={_membership_id!r}, "
            f"active_date={_active_date!r}, "
            f"count={_count!r}, "
            f"current={_current!r}, "
            f"expiration_date={_expiration_date!r}, "
            f"id={_id!r}, "
            f"product_id={_product_id!r}, "
            f"name={_name!r}, "
            f"payment_date={_payment_date!r}, "
            f"program={_program!r}, "
            f"remaining={_remaining!r}, "
            f"site_id={_site_id!r}, "
            f"action={_action!r}, "
            f"client_id={_client_id!r}, "
            f"returned={_returned!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _restricted_locations=(
            self.restricted_locations
            if hasattr(self, "restricted_locations")
            else None
        )
        _icon_code=(
            self.icon_code
            if hasattr(self, "icon_code")
            else None
        )
        _membership_id=(
            self.membership_id
            if hasattr(self, "membership_id")
            else None
        )
        _active_date=(
            self.active_date
            if hasattr(self, "active_date")
            else None
        )
        _count=(
            self.count
            if hasattr(self, "count")
            else None
        )
        _current=(
            self.current
            if hasattr(self, "current")
            else None
        )
        _expiration_date=(
            self.expiration_date
            if hasattr(self, "expiration_date")
            else None
        )
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _product_id=(
            self.product_id
            if hasattr(self, "product_id")
            else None
        )
        _name=(
            self.name
            if hasattr(self, "name")
            else None
        )
        _payment_date=(
            self.payment_date
            if hasattr(self, "payment_date")
            else None
        )
        _program=(
            self.program
            if hasattr(self, "program")
            else None
        )
        _remaining=(
            self.remaining
            if hasattr(self, "remaining")
            else None
        )
        _site_id=(
            self.site_id
            if hasattr(self, "site_id")
            else None
        )
        _action=(
            self.action
            if hasattr(self, "action")
            else None
        )
        _client_id=(
            self.client_id
            if hasattr(self, "client_id")
            else None
        )
        _returned=(
            self.returned
            if hasattr(self, "returned")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"restricted_locations={_restricted_locations!s}, "
            f"icon_code={_icon_code!s}, "
            f"membership_id={_membership_id!s}, "
            f"active_date={_active_date!s}, "
            f"count={_count!s}, "
            f"current={_current!s}, "
            f"expiration_date={_expiration_date!s}, "
            f"id={_id!s}, "
            f"product_id={_product_id!s}, "
            f"name={_name!s}, "
            f"payment_date={_payment_date!s}, "
            f"program={_program!s}, "
            f"remaining={_remaining!s}, "
            f"site_id={_site_id!s}, "
            f"action={_action!s}, "
            f"client_id={_client_id!s}, "
            f"returned={_returned!s}, "
            f")"
        )
