"""mindbodypublicapi.

This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
"""

# ruff: noqa: E501
from mindbodypublicapi.api_helper import APIHelper


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

    Semesters help you quickly classify enrollments.

    Attributes:
        id (int): This semester’s unique ID.
        name (str): Name of the semester.
        description (str): The description of the semester.
        start_date (datetime): Start date of the semester.
        end_date (datetime): End date of the semester.
        multi_registration_discount (float): Discount for multiple registration in
            the semester.
        multi_registration_deadline (datetime): Registration deadline of the semester.
        active (bool): When `true`, indicates that the semester is active.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "id": "Id",
        "name": "Name",
        "description": "Description",
        "start_date": "StartDate",
        "end_date": "EndDate",
        "multi_registration_discount": "MultiRegistrationDiscount",
        "multi_registration_deadline": "MultiRegistrationDeadline",
        "active": "Active",
    }

    _optionals = [
        "id",
        "name",
        "description",
        "start_date",
        "end_date",
        "multi_registration_discount",
        "multi_registration_deadline",
        "active",
    ]

    def __init__(
        self,
        id=APIHelper.SKIP,
        name=APIHelper.SKIP,
        description=APIHelper.SKIP,
        start_date=APIHelper.SKIP,
        end_date=APIHelper.SKIP,
        multi_registration_discount=APIHelper.SKIP,
        multi_registration_deadline=APIHelper.SKIP,
        active=APIHelper.SKIP):
        """Initialize a Semester instance."""
        # Initialize members of the class
        if id is not APIHelper.SKIP:
            self.id = id
        if name is not APIHelper.SKIP:
            self.name = name
        if description is not APIHelper.SKIP:
            self.description = description
        if start_date is not APIHelper.SKIP:
            self.start_date =\
                 APIHelper.apply_datetime_converter(
                start_date, APIHelper.RFC3339DateTime)\
                 if start_date else None
        if end_date is not APIHelper.SKIP:
            self.end_date =\
                 APIHelper.apply_datetime_converter(
                end_date, APIHelper.RFC3339DateTime)\
                 if end_date else None
        if multi_registration_discount is not APIHelper.SKIP:
            self.multi_registration_discount = multi_registration_discount
        if multi_registration_deadline is not APIHelper.SKIP:
            self.multi_registration_deadline =\
                 APIHelper.apply_datetime_converter(
                multi_registration_deadline, APIHelper.RFC3339DateTime)\
                 if multi_registration_deadline else None
        if active is not APIHelper.SKIP:
            self.active = 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
        id =\
            dictionary.get("Id")\
            if dictionary.get("Id")\
                else APIHelper.SKIP
        name =\
            dictionary.get("Name")\
            if dictionary.get("Name")\
                else APIHelper.SKIP
        description =\
            dictionary.get("Description")\
            if dictionary.get("Description")\
                else APIHelper.SKIP
        start_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("StartDate")).datetime\
            if dictionary.get("StartDate") else APIHelper.SKIP
        end_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("EndDate")).datetime\
            if dictionary.get("EndDate") else APIHelper.SKIP
        multi_registration_discount =\
            dictionary.get("MultiRegistrationDiscount")\
            if dictionary.get("MultiRegistrationDiscount")\
                else APIHelper.SKIP
        multi_registration_deadline = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("MultiRegistrationDeadline")).datetime\
            if dictionary.get("MultiRegistrationDeadline") else APIHelper.SKIP
        active =\
            dictionary.get("Active")\
            if "Active" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(id,
                   name,
                   description,
                   start_date,
                   end_date,
                   multi_registration_discount,
                   multi_registration_deadline,
                   active)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _name=(
            self.name
            if hasattr(self, "name")
            else None
        )
        _description=(
            self.description
            if hasattr(self, "description")
            else None
        )
        _start_date=(
            self.start_date
            if hasattr(self, "start_date")
            else None
        )
        _end_date=(
            self.end_date
            if hasattr(self, "end_date")
            else None
        )
        _multi_registration_discount=(
            self.multi_registration_discount
            if hasattr(self, "multi_registration_discount")
            else None
        )
        _multi_registration_deadline=(
            self.multi_registration_deadline
            if hasattr(self, "multi_registration_deadline")
            else None
        )
        _active=(
            self.active
            if hasattr(self, "active")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!r}, "
            f"name={_name!r}, "
            f"description={_description!r}, "
            f"start_date={_start_date!r}, "
            f"end_date={_end_date!r}, "
            f"multi_registration_discount={_multi_registration_discount!r}, "
            f"multi_registration_deadline={_multi_registration_deadline!r}, "
            f"active={_active!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _name=(
            self.name
            if hasattr(self, "name")
            else None
        )
        _description=(
            self.description
            if hasattr(self, "description")
            else None
        )
        _start_date=(
            self.start_date
            if hasattr(self, "start_date")
            else None
        )
        _end_date=(
            self.end_date
            if hasattr(self, "end_date")
            else None
        )
        _multi_registration_discount=(
            self.multi_registration_discount
            if hasattr(self, "multi_registration_discount")
            else None
        )
        _multi_registration_deadline=(
            self.multi_registration_deadline
            if hasattr(self, "multi_registration_deadline")
            else None
        )
        _active=(
            self.active
            if hasattr(self, "active")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!s}, "
            f"name={_name!s}, "
            f"description={_description!s}, "
            f"start_date={_start_date!s}, "
            f"end_date={_end_date!s}, "
            f"multi_registration_discount={_multi_registration_discount!s}, "
            f"multi_registration_deadline={_multi_registration_deadline!s}, "
            f"active={_active!s}, "
            f")"
        )
