Humaans.TimeAway (Humaans v0.6.0)

Copy Markdown View Source

This module provides functions for managing time away resources in the Humaans API.

Summary

Functions

Creates a new time_away.

Deletes a specific time_away by ID.

Lists all time_away.

Retrieves a specific time_away by ID.

Updates a specific time_away 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.TimeAway{
       approved_by: term(),
       created_at: term(),
       end_date: term(),
       id: term(),
       notes: term(),
       person_id: term(),
       reason: term(),
       start_date: term(),
       status: term(),
       time_away_type_id: term(),
       updated_at: term()
     }
   ]}
  | {:error, Humaans.Error.t()}

response()

@type response() ::
  {:ok,
   %Humaans.Resources.TimeAway{
     approved_by: term(),
     created_at: term(),
     end_date: term(),
     id: term(),
     notes: term(),
     person_id: term(),
     reason: term(),
     start_date: term(),
     status: term(),
     time_away_type_id: term(),
     updated_at: term()
   }}
  | {:error, Humaans.Error.t()}

Functions

create(client, params)

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

Creates a new time_away.

Parameters

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

Examples

client = Humaans.new(access_token: "your_access_token")
params = %{personId: "person_abc", timeAwayTypeId: "type_abc", startDate: "2025-01-01", endDate: "2025-01-05"}
{:ok, time_away} = Humaans.TimeAway.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 time_away by ID.

Parameters

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

Examples

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

list(client, params \\ %{})

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

Lists all time_away.

Returns a list of time_away 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, time_away} = Humaans.TimeAway.list(client)
{:ok, time_away} = Humaans.TimeAway.list(client, %{})

retrieve(client, id)

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

Retrieves a specific time_away by ID.

Parameters

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

Examples

client = Humaans.new(access_token: "your_access_token")
{:ok, time_away} = Humaans.TimeAway.retrieve(client, "time_away_id")

update(client, id, params)

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

Updates a specific time_away by ID.

Parameters

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

Examples

client = Humaans.new(access_token: "your_access_token")
params = %{notes: "Updated note"}
{:ok, time_away} = Humaans.TimeAway.update(client, "time_away_id", params)