Humaans.TimesheetEntries (Humaans v0.5.1)

Copy Markdown View Source

This module provides functions for managing timesheet entry resources in the Humaans API. Timesheet entries represent individual time records for a person, such as hours worked on a specific date.

Summary

Functions

Creates a new timesheet_entry.

Deletes a specific timesheet_entry by ID.

Lists all timesheet_entries.

Retrieves a specific timesheet_entry by ID.

Updates a specific timesheet_entry by ID.

Types

delete_response()

@type delete_response() ::
  {:ok, %{id: String.t(), deleted: bool()}} | {:error, Humaans.Error.t()}

list_response()

@type list_response() ::
  {:ok,
   [
     %Humaans.Resources.TimesheetEntry{
       created_at: term(),
       date: term(),
       duration: term(),
       end_time: term(),
       id: term(),
       person_id: term(),
       start_time: term(),
       updated_at: term()
     }
   ]}
  | {:error, Humaans.Error.t()}

response()

@type response() ::
  {:ok,
   %Humaans.Resources.TimesheetEntry{
     created_at: term(),
     date: term(),
     duration: term(),
     end_time: term(),
     id: term(),
     person_id: term(),
     start_time: term(),
     updated_at: term()
   }}
  | {:error, Humaans.Error.t()}

Functions

create(client, params)

@spec create(client :: map(), params :: map() | keyword()) ::
  {:ok, Humaans.Resources.TimesheetEntry.t()} | {:error, Humaans.Error.t()}

Creates a new timesheet_entry.

Parameters

  • client - Client created with Humaans.new/1
  • params - Map of attributes for the new timesheet_entry

Examples

client = Humaans.new(access_token: "your_access_token")
params = %{personId: "person_abc", date: "2024-06-01", startTime: "09:00", endTime: "17:00"}
{:ok, timesheet_entry} = Humaans.TimesheetEntries.create(client, params)

delete(client, id)

@spec delete(client :: map(), id :: String.t()) ::
  {:ok, %{id: String.t(), deleted: boolean()}} | {:error, Humaans.Error.t()}

Deletes a specific timesheet_entry by ID.

Parameters

  • client - Client created with Humaans.new/1
  • id - String ID of the timesheet_entry to delete

Examples

client = Humaans.new(access_token: "your_access_token")
{:ok, %{id: "timesheet_entry_id", deleted: true}} = Humaans.TimesheetEntries.delete(client, "timesheet_entry_id")

list(client, params \\ %{})

@spec list(client :: map(), params :: map() | keyword()) ::
  {:ok, [Humaans.Resources.TimesheetEntry.t()]} | {:error, Humaans.Error.t()}

Lists all timesheet_entries.

Returns a list of timesheet_entries matching the optional filter params.

Parameters

  • client - Client created with Humaans.new/1
  • params - Optional map of filter parameters (default: %{})

Examples

client = Humaans.new(access_token: "your_access_token")
{:ok, timesheet_entries} = Humaans.TimesheetEntries.list(client)
{:ok, timesheet_entries} = Humaans.TimesheetEntries.list(client, %{})

retrieve(client, id)

@spec retrieve(client :: map(), id :: String.t()) ::
  {:ok, Humaans.Resources.TimesheetEntry.t()} | {:error, Humaans.Error.t()}

Retrieves a specific timesheet_entry by ID.

Parameters

  • client - Client created with Humaans.new/1
  • id - String ID of the timesheet_entry to retrieve

Examples

client = Humaans.new(access_token: "your_access_token")
{:ok, timesheet_entry} = Humaans.TimesheetEntries.retrieve(client, "timesheet_entry_id")

update(client, id, params)

@spec update(client :: map(), id :: String.t(), params :: map() | keyword()) ::
  {:ok, Humaans.Resources.TimesheetEntry.t()} | {:error, Humaans.Error.t()}

Updates a specific timesheet_entry by ID.

Parameters

  • client - Client created with Humaans.new/1
  • id - String ID of the timesheet_entry to update
  • params - Map of attributes to update

Examples

client = Humaans.new(access_token: "your_access_token")
{:ok, timesheet_entry} = Humaans.TimesheetEntries.update(client, "timesheet_entry_id", %{})