"""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,
)
from mindbodypublicapi.models.staff import Staff


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

    A course.

    Attributes:
        id (int): The course ID.
        name (str): The course name.
        description (str): A description of the course.
        notes (str): Any notes that have been written about the course.
        start_date (datetime): Date and time that the course starts.
        end_date (datetime): Date and time that the course ends.
        location (Location): The model property of type Location.
        organizer (Staff): The Staff
        program (Program): The model property of type Program.
        image_url (str): The URL of the image associated with this course, if one
            exists.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "id": "Id",
        "name": "Name",
        "description": "Description",
        "notes": "Notes",
        "start_date": "StartDate",
        "end_date": "EndDate",
        "location": "Location",
        "organizer": "Organizer",
        "program": "Program",
        "image_url": "ImageUrl",
    }

    _optionals = [
        "id",
        "name",
        "description",
        "notes",
        "start_date",
        "end_date",
        "location",
        "organizer",
        "program",
        "image_url",
    ]

    def __init__(
        self,
        id=APIHelper.SKIP,
        name=APIHelper.SKIP,
        description=APIHelper.SKIP,
        notes=APIHelper.SKIP,
        start_date=APIHelper.SKIP,
        end_date=APIHelper.SKIP,
        location=APIHelper.SKIP,
        organizer=APIHelper.SKIP,
        program=APIHelper.SKIP,
        image_url=APIHelper.SKIP):
        """Initialize a Course 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 notes is not APIHelper.SKIP:
            self.notes = notes
        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 location is not APIHelper.SKIP:
            self.location = location
        if organizer is not APIHelper.SKIP:
            self.organizer = organizer
        if program is not APIHelper.SKIP:
            self.program = program
        if image_url is not APIHelper.SKIP:
            self.image_url = image_url

    @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
        notes =\
            dictionary.get("Notes")\
            if dictionary.get("Notes")\
                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
        location =\
            Location.from_dictionary(
                dictionary.get("Location"))\
                if "Location" in dictionary.keys()\
                else APIHelper.SKIP
        organizer =\
            Staff.from_dictionary(
                dictionary.get("Organizer"))\
                if "Organizer" in dictionary.keys()\
                else APIHelper.SKIP
        program =\
            Program.from_dictionary(
                dictionary.get("Program"))\
                if "Program" in dictionary.keys()\
                else APIHelper.SKIP
        image_url =\
            dictionary.get("ImageUrl")\
            if dictionary.get("ImageUrl")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(id,
                   name,
                   description,
                   notes,
                   start_date,
                   end_date,
                   location,
                   organizer,
                   program,
                   image_url)

    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
        )
        _notes=(
            self.notes
            if hasattr(self, "notes")
            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
        )
        _location=(
            self.location
            if hasattr(self, "location")
            else None
        )
        _organizer=(
            self.organizer
            if hasattr(self, "organizer")
            else None
        )
        _program=(
            self.program
            if hasattr(self, "program")
            else None
        )
        _image_url=(
            self.image_url
            if hasattr(self, "image_url")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!r}, "
            f"name={_name!r}, "
            f"description={_description!r}, "
            f"notes={_notes!r}, "
            f"start_date={_start_date!r}, "
            f"end_date={_end_date!r}, "
            f"location={_location!r}, "
            f"organizer={_organizer!r}, "
            f"program={_program!r}, "
            f"image_url={_image_url!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
        )
        _notes=(
            self.notes
            if hasattr(self, "notes")
            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
        )
        _location=(
            self.location
            if hasattr(self, "location")
            else None
        )
        _organizer=(
            self.organizer
            if hasattr(self, "organizer")
            else None
        )
        _program=(
            self.program
            if hasattr(self, "program")
            else None
        )
        _image_url=(
            self.image_url
            if hasattr(self, "image_url")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!s}, "
            f"name={_name!s}, "
            f"description={_description!s}, "
            f"notes={_notes!s}, "
            f"start_date={_start_date!s}, "
            f"end_date={_end_date!s}, "
            f"location={_location!s}, "
            f"organizer={_organizer!s}, "
            f"program={_program!s}, "
            f"image_url={_image_url!s}, "
            f")"
        )
