Get Hours Api 0 0

Last updated on Nov 26, 2024 01:37 in API
Posted Bykirt

The getHours function retrieves and returns logged work hours for employees based on provided filters such as employee_id, start_date, and end_date.

Process Flow:

  1. Token Validation: The API validates the authentication token passed either in the header or body of the request. If the token is invalid or expired, a 401 Unauthorized error is returned.

  2. Permissions Check: The API ensures the user has the necessary permissions (i.e., hours_get or hours_search).

  3. Input Validation: The API checks if required parameters (employee_id, start_date, end_date) are present and valid. If any are missing or incorrect, appropriate error messages are returned.

  4. Employee Validation: The employee associated with employee_id is validated by checking if the employee exists in the system.

  5. Hours Filtering: If valid parameters are provided, the API filters the hours data based on start_date, end_date, hours_type, and hours_value.

  6. Data Fetching & Formatting: The API fetches the hours records from the database, formats the response (including employee and hours type details), and returns the result.

Response:

  • Returns a list of hours records, including details like employee name, hours worked, and the type of hours (e.g., "Tips").
  • In case of errors (invalid token, missing fields, etc.), an appropriate error message is returned.


** The time is base on America/New_York timezone