"""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.program_membership import (
    ProgramMembership,
)


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

    Attributes:
        membership_id (int): The membership id.
        membership_name (str): The membership name.
        priority (int): The priority/sort order.
        member_retail_discount (float): The membership discount for retail as a
            percentage.
        member_service_discount (float): The membership discount for services as a
            percentage.
        allow_clients_to_schedule_unpaid (bool): Allow clients in this membership to
            schedule unpaid.
        online_booking_restricted_to_members_only (List[ProgramMembership]): List of
            programs that are restricted to clients in this membership only.
        day_of_month_scheduling_opens_for_next_month (int): Day of month scheduling
            opens for next month.  Unrestricted is a null value.
        restrict_self_sign_in_to_members_only (bool): Restrict self sign in to
            members only.
        allow_members_to_book_appointments_without_paying (bool): Allow members to
            book appointments without paying.
        allow_members_to_purchase_non_members_services (bool): Allow members to
            purchase non-members services.
        allow_members_to_purchase_non_members_products (bool): Allow members to
            purchase non-members products.
        is_active (bool): Indicates if the membership is active.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "membership_id": "MembershipId",
        "membership_name": "MembershipName",
        "priority": "Priority",
        "member_retail_discount": "MemberRetailDiscount",
        "member_service_discount": "MemberServiceDiscount",
        "allow_clients_to_schedule_unpaid": "AllowClientsToScheduleUnpaid",
        "online_booking_restricted_to_members_only":
            "OnlineBookingRestrictedToMembersOnly",
        "day_of_month_scheduling_opens_for_next_month":
            "DayOfMonthSchedulingOpensForNextMonth",
        "restrict_self_sign_in_to_members_only": "RestrictSelfSignInToMembersOnly",
        "allow_members_to_book_appointments_without_paying":
            "AllowMembersToBookAppointmentsWithoutPaying",
        "allow_members_to_purchase_non_members_services":
            "AllowMembersToPurchaseNonMembersServices",
        "allow_members_to_purchase_non_members_products":
            "AllowMembersToPurchaseNonMembersProducts",
        "is_active": "IsActive",
    }

    _optionals = [
        "membership_id",
        "membership_name",
        "priority",
        "member_retail_discount",
        "member_service_discount",
        "allow_clients_to_schedule_unpaid",
        "online_booking_restricted_to_members_only",
        "day_of_month_scheduling_opens_for_next_month",
        "restrict_self_sign_in_to_members_only",
        "allow_members_to_book_appointments_without_paying",
        "allow_members_to_purchase_non_members_services",
        "allow_members_to_purchase_non_members_products",
        "is_active",
    ]

    def __init__(
        self,
        membership_id=APIHelper.SKIP,
        membership_name=APIHelper.SKIP,
        priority=APIHelper.SKIP,
        member_retail_discount=APIHelper.SKIP,
        member_service_discount=APIHelper.SKIP,
        allow_clients_to_schedule_unpaid=APIHelper.SKIP,
        online_booking_restricted_to_members_only=APIHelper.SKIP,
        day_of_month_scheduling_opens_for_next_month=APIHelper.SKIP,
        restrict_self_sign_in_to_members_only=APIHelper.SKIP,
        allow_members_to_book_appointments_without_paying=APIHelper.SKIP,
        allow_members_to_purchase_non_members_services=APIHelper.SKIP,
        allow_members_to_purchase_non_members_products=APIHelper.SKIP,
        is_active=APIHelper.SKIP):
        """Initialize a Membership instance."""
        # Initialize members of the class
        if membership_id is not APIHelper.SKIP:
            self.membership_id = membership_id
        if membership_name is not APIHelper.SKIP:
            self.membership_name = membership_name
        if priority is not APIHelper.SKIP:
            self.priority = priority
        if member_retail_discount is not APIHelper.SKIP:
            self.member_retail_discount = member_retail_discount
        if member_service_discount is not APIHelper.SKIP:
            self.member_service_discount = member_service_discount
        if allow_clients_to_schedule_unpaid is not APIHelper.SKIP:
            self.allow_clients_to_schedule_unpaid = allow_clients_to_schedule_unpaid
        if online_booking_restricted_to_members_only is not APIHelper.SKIP:
            self.online_booking_restricted_to_members_only =\
                 online_booking_restricted_to_members_only
        if day_of_month_scheduling_opens_for_next_month is not APIHelper.SKIP:
            self.day_of_month_scheduling_opens_for_next_month =\
                 day_of_month_scheduling_opens_for_next_month
        if restrict_self_sign_in_to_members_only is not APIHelper.SKIP:
            self.restrict_self_sign_in_to_members_only =\
                 restrict_self_sign_in_to_members_only
        if allow_members_to_book_appointments_without_paying is not APIHelper.SKIP:
            self.allow_members_to_book_appointments_without_paying =\
                 allow_members_to_book_appointments_without_paying
        if allow_members_to_purchase_non_members_services is not APIHelper.SKIP:
            self.allow_members_to_purchase_non_members_services =\
                 allow_members_to_purchase_non_members_services
        if allow_members_to_purchase_non_members_products is not APIHelper.SKIP:
            self.allow_members_to_purchase_non_members_products =\
                 allow_members_to_purchase_non_members_products
        if is_active is not APIHelper.SKIP:
            self.is_active = is_active

    @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
        membership_id =\
            dictionary.get("MembershipId")\
            if dictionary.get("MembershipId")\
                else APIHelper.SKIP
        membership_name =\
            dictionary.get("MembershipName")\
            if dictionary.get("MembershipName")\
                else APIHelper.SKIP
        priority =\
            dictionary.get("Priority")\
            if dictionary.get("Priority")\
                else APIHelper.SKIP
        member_retail_discount =\
            dictionary.get("MemberRetailDiscount")\
            if dictionary.get("MemberRetailDiscount")\
                else APIHelper.SKIP
        member_service_discount =\
            dictionary.get("MemberServiceDiscount")\
            if dictionary.get("MemberServiceDiscount")\
                else APIHelper.SKIP
        allow_clients_to_schedule_unpaid =\
            dictionary.get("AllowClientsToScheduleUnpaid")\
            if "AllowClientsToScheduleUnpaid" in dictionary.keys()\
                else APIHelper.SKIP
        online_booking_restricted_to_members_only = None
        if dictionary.get("OnlineBookingRestrictedToMembersOnly") is not None:
            online_booking_restricted_to_members_only = [
                ProgramMembership.from_dictionary(x)
                    for x in dictionary.get("OnlineBookingRestrictedToMembersOnly")
            ]
        else:
            online_booking_restricted_to_members_only = APIHelper.SKIP
        day_of_month_scheduling_opens_for_next_month =\
            dictionary.get("DayOfMonthSchedulingOpensForNextMonth")\
            if dictionary.get("DayOfMonthSchedulingOpensForNextMonth")\
                else APIHelper.SKIP
        restrict_self_sign_in_to_members_only =\
            dictionary.get("RestrictSelfSignInToMembersOnly")\
            if "RestrictSelfSignInToMembersOnly" in dictionary.keys()\
                else APIHelper.SKIP
        allow_members_to_book_appointments_without_paying =\
            dictionary.get("AllowMembersToBookAppointmentsWithoutPaying")\
            if "AllowMembersToBookAppointmentsWithoutPaying" in dictionary.keys()\
                else APIHelper.SKIP
        allow_members_to_purchase_non_members_services =\
            dictionary.get("AllowMembersToPurchaseNonMembersServices")\
            if "AllowMembersToPurchaseNonMembersServices" in dictionary.keys()\
                else APIHelper.SKIP
        allow_members_to_purchase_non_members_products =\
            dictionary.get("AllowMembersToPurchaseNonMembersProducts")\
            if "AllowMembersToPurchaseNonMembersProducts" in dictionary.keys()\
                else APIHelper.SKIP
        is_active =\
            dictionary.get("IsActive")\
            if "IsActive" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(membership_id,
                   membership_name,
                   priority,
                   member_retail_discount,
                   member_service_discount,
                   allow_clients_to_schedule_unpaid,
                   online_booking_restricted_to_members_only,
                   day_of_month_scheduling_opens_for_next_month,
                   restrict_self_sign_in_to_members_only,
                   allow_members_to_book_appointments_without_paying,
                   allow_members_to_purchase_non_members_services,
                   allow_members_to_purchase_non_members_products,
                   is_active)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _membership_id=(
            self.membership_id
            if hasattr(self, "membership_id")
            else None
        )
        _membership_name=(
            self.membership_name
            if hasattr(self, "membership_name")
            else None
        )
        _priority=(
            self.priority
            if hasattr(self, "priority")
            else None
        )
        _member_retail_discount=(
            self.member_retail_discount
            if hasattr(self, "member_retail_discount")
            else None
        )
        _member_service_discount=(
            self.member_service_discount
            if hasattr(self, "member_service_discount")
            else None
        )
        _allow_clients_to_schedule_unpaid=(
            self.allow_clients_to_schedule_unpaid
            if hasattr(self, "allow_clients_to_schedule_unpaid")
            else None
        )
        _online_booking_restricted_to_members_only=(
            self.online_booking_restricted_to_members_only
            if hasattr(self, "online_booking_restricted_to_members_only")
            else None
        )
        _day_of_month_scheduling_opens_for_next_month=(
            self.day_of_month_scheduling_opens_for_next_month
            if hasattr(self, "day_of_month_scheduling_opens_for_next_month")
            else None
        )
        _restrict_self_sign_in_to_members_only=(
            self.restrict_self_sign_in_to_members_only
            if hasattr(self, "restrict_self_sign_in_to_members_only")
            else None
        )
        _allow_members_to_book_appointments_without_paying=(
            self.allow_members_to_book_appointments_without_paying
            if hasattr(self, "allow_members_to_book_appointments_without_paying")
            else None
        )
        _allow_members_to_purchase_non_members_services=(
            self.allow_members_to_purchase_non_members_services
            if hasattr(self, "allow_members_to_purchase_non_members_services")
            else None
        )
        _allow_members_to_purchase_non_members_products=(
            self.allow_members_to_purchase_non_members_products
            if hasattr(self, "allow_members_to_purchase_non_members_products")
            else None
        )
        _is_active=(
            self.is_active
            if hasattr(self, "is_active")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"membership_id={_membership_id!r}, "
            f"membership_name={_membership_name!r}, "
            f"priority={_priority!r}, "
            f"member_retail_discount={_member_retail_discount!r}, "
            f"member_service_discount={_member_service_discount!r}, "
            f"allow_clients_to_schedule_unpaid={_allow_clients_to_schedule_unpaid!r}, "
            f"online_booking_restricted_to_members_only={_online_booking_restricted_to_members_only!r}, "
            f"day_of_month_scheduling_opens_for_next_month={_day_of_month_scheduling_opens_for_next_month!r}, "
            f"restrict_self_sign_in_to_members_only={_restrict_self_sign_in_to_members_only!r}, "
            f"allow_members_to_book_appointments_without_paying={_allow_members_to_book_appointments_without_paying!r}, "
            f"allow_members_to_purchase_non_members_services={_allow_members_to_purchase_non_members_services!r}, "
            f"allow_members_to_purchase_non_members_products={_allow_members_to_purchase_non_members_products!r}, "
            f"is_active={_is_active!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _membership_id=(
            self.membership_id
            if hasattr(self, "membership_id")
            else None
        )
        _membership_name=(
            self.membership_name
            if hasattr(self, "membership_name")
            else None
        )
        _priority=(
            self.priority
            if hasattr(self, "priority")
            else None
        )
        _member_retail_discount=(
            self.member_retail_discount
            if hasattr(self, "member_retail_discount")
            else None
        )
        _member_service_discount=(
            self.member_service_discount
            if hasattr(self, "member_service_discount")
            else None
        )
        _allow_clients_to_schedule_unpaid=(
            self.allow_clients_to_schedule_unpaid
            if hasattr(self, "allow_clients_to_schedule_unpaid")
            else None
        )
        _online_booking_restricted_to_members_only=(
            self.online_booking_restricted_to_members_only
            if hasattr(self, "online_booking_restricted_to_members_only")
            else None
        )
        _day_of_month_scheduling_opens_for_next_month=(
            self.day_of_month_scheduling_opens_for_next_month
            if hasattr(self, "day_of_month_scheduling_opens_for_next_month")
            else None
        )
        _restrict_self_sign_in_to_members_only=(
            self.restrict_self_sign_in_to_members_only
            if hasattr(self, "restrict_self_sign_in_to_members_only")
            else None
        )
        _allow_members_to_book_appointments_without_paying=(
            self.allow_members_to_book_appointments_without_paying
            if hasattr(self, "allow_members_to_book_appointments_without_paying")
            else None
        )
        _allow_members_to_purchase_non_members_services=(
            self.allow_members_to_purchase_non_members_services
            if hasattr(self, "allow_members_to_purchase_non_members_services")
            else None
        )
        _allow_members_to_purchase_non_members_products=(
            self.allow_members_to_purchase_non_members_products
            if hasattr(self, "allow_members_to_purchase_non_members_products")
            else None
        )
        _is_active=(
            self.is_active
            if hasattr(self, "is_active")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"membership_id={_membership_id!s}, "
            f"membership_name={_membership_name!s}, "
            f"priority={_priority!s}, "
            f"member_retail_discount={_member_retail_discount!s}, "
            f"member_service_discount={_member_service_discount!s}, "
            f"allow_clients_to_schedule_unpaid={_allow_clients_to_schedule_unpaid!s}, "
            f"online_booking_restricted_to_members_only={_online_booking_restricted_to_members_only!s}, "
            f"day_of_month_scheduling_opens_for_next_month={_day_of_month_scheduling_opens_for_next_month!s}, "
            f"restrict_self_sign_in_to_members_only={_restrict_self_sign_in_to_members_only!s}, "
            f"allow_members_to_book_appointments_without_paying={_allow_members_to_book_appointments_without_paying!s}, "
            f"allow_members_to_purchase_non_members_services={_allow_members_to_purchase_non_members_services!s}, "
            f"allow_members_to_purchase_non_members_products={_allow_members_to_purchase_non_members_products!s}, "
            f"is_active={_is_active!s}, "
            f")"
        )
