"""mindbodypublicapi.

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

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


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

    Attributes:
        staff_id (int): The ID of the requested staff member.
        task (str): The staff member’s job title.
        time_in (datetime): The time that the staff member started the job task.
        time_out (datetime): The time that the staff member stopped doing the job
            task.
        hours (float): The number of hours on this time card, rounded to the nearest
            fourth decimal place.
        hourly_rate (float): The hourly rate the business pays this staff for this
            `Task`.
        earnings (float): The total amount earned by the staff member for this time
            card entry.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "staff_id": "StaffId",
        "task": "Task",
        "time_in": "TimeIn",
        "time_out": "TimeOut",
        "hours": "Hours",
        "hourly_rate": "HourlyRate",
        "earnings": "Earnings",
    }

    _optionals = [
        "staff_id",
        "task",
        "time_in",
        "time_out",
        "hours",
        "hourly_rate",
        "earnings",
    ]

    def __init__(
        self,
        staff_id=APIHelper.SKIP,
        task=APIHelper.SKIP,
        time_in=APIHelper.SKIP,
        time_out=APIHelper.SKIP,
        hours=APIHelper.SKIP,
        hourly_rate=APIHelper.SKIP,
        earnings=APIHelper.SKIP):
        """Initialize a TimeCardEvent instance."""
        # Initialize members of the class
        if staff_id is not APIHelper.SKIP:
            self.staff_id = staff_id
        if task is not APIHelper.SKIP:
            self.task = task
        if time_in is not APIHelper.SKIP:
            self.time_in =\
                 APIHelper.apply_datetime_converter(
                time_in, APIHelper.RFC3339DateTime)\
                 if time_in else None
        if time_out is not APIHelper.SKIP:
            self.time_out =\
                 APIHelper.apply_datetime_converter(
                time_out, APIHelper.RFC3339DateTime)\
                 if time_out else None
        if hours is not APIHelper.SKIP:
            self.hours = hours
        if hourly_rate is not APIHelper.SKIP:
            self.hourly_rate = hourly_rate
        if earnings is not APIHelper.SKIP:
            self.earnings = earnings

    @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
        staff_id =\
            dictionary.get("StaffId")\
            if dictionary.get("StaffId")\
                else APIHelper.SKIP
        task =\
            dictionary.get("Task")\
            if dictionary.get("Task")\
                else APIHelper.SKIP
        time_in = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("TimeIn")).datetime\
            if dictionary.get("TimeIn") else APIHelper.SKIP
        time_out = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("TimeOut")).datetime\
            if dictionary.get("TimeOut") else APIHelper.SKIP
        hours =\
            dictionary.get("Hours")\
            if dictionary.get("Hours")\
                else APIHelper.SKIP
        hourly_rate =\
            dictionary.get("HourlyRate")\
            if dictionary.get("HourlyRate")\
                else APIHelper.SKIP
        earnings =\
            dictionary.get("Earnings")\
            if dictionary.get("Earnings")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(staff_id,
                   task,
                   time_in,
                   time_out,
                   hours,
                   hourly_rate,
                   earnings)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _staff_id=(
            self.staff_id
            if hasattr(self, "staff_id")
            else None
        )
        _task=(
            self.task
            if hasattr(self, "task")
            else None
        )
        _time_in=(
            self.time_in
            if hasattr(self, "time_in")
            else None
        )
        _time_out=(
            self.time_out
            if hasattr(self, "time_out")
            else None
        )
        _hours=(
            self.hours
            if hasattr(self, "hours")
            else None
        )
        _hourly_rate=(
            self.hourly_rate
            if hasattr(self, "hourly_rate")
            else None
        )
        _earnings=(
            self.earnings
            if hasattr(self, "earnings")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"staff_id={_staff_id!r}, "
            f"task={_task!r}, "
            f"time_in={_time_in!r}, "
            f"time_out={_time_out!r}, "
            f"hours={_hours!r}, "
            f"hourly_rate={_hourly_rate!r}, "
            f"earnings={_earnings!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _staff_id=(
            self.staff_id
            if hasattr(self, "staff_id")
            else None
        )
        _task=(
            self.task
            if hasattr(self, "task")
            else None
        )
        _time_in=(
            self.time_in
            if hasattr(self, "time_in")
            else None
        )
        _time_out=(
            self.time_out
            if hasattr(self, "time_out")
            else None
        )
        _hours=(
            self.hours
            if hasattr(self, "hours")
            else None
        )
        _hourly_rate=(
            self.hourly_rate
            if hasattr(self, "hourly_rate")
            else None
        )
        _earnings=(
            self.earnings
            if hasattr(self, "earnings")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"staff_id={_staff_id!s}, "
            f"task={_task!s}, "
            f"time_in={_time_in!s}, "
            f"time_out={_time_out!s}, "
            f"hours={_hours!s}, "
            f"hourly_rate={_hourly_rate!s}, "
            f"earnings={_earnings!s}, "
            f")"
        )
