Humaans.Compensations (Humaans v0.5.1)

Copy Markdown View Source

This module provides functions for managing compensation resources in the Humaans API. Compensations represent the actual monetary values assigned to a person under a specific compensation type (e.g., a specific person's salary or bonus).

Summary

Functions

Creates a new compensation.

Deletes a specific compensation by ID.

Lists all compensations.

Retrieves a specific compensation by ID.

Updates a specific compensation 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.Compensation{
       amount: term(),
       compensation_type_id: term(),
       created_at: term(),
       currency: term(),
       effective_date: term(),
       end_date: term(),
       end_reason: term(),
       id: term(),
       note: term(),
       period: term(),
       person_id: term(),
       updated_at: term()
     }
   ]}
  | {:error, Humaans.Error.t()}

response()

@type response() ::
  {:ok,
   %Humaans.Resources.Compensation{
     amount: term(),
     compensation_type_id: term(),
     created_at: term(),
     currency: term(),
     effective_date: term(),
     end_date: term(),
     end_reason: term(),
     id: term(),
     note: term(),
     period: term(),
     person_id: term(),
     updated_at: term()
   }}
  | {:error, Humaans.Error.t()}

Functions

create(client, params)

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

Creates a new compensation.

Parameters

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

Examples

client = Humaans.new(access_token: "your_access_token")
params = %{personId: "person_abc", compensationTypeId: "type_abc", amount: 75_000, currency: "GBP", period: "year", effectiveDate: "2024-01-01"}
{:ok, compensation} = Humaans.Compensations.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 compensation by ID.

Parameters

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

Examples

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

list(client, params \\ %{})

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

Lists all compensations.

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

retrieve(client, id)

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

Retrieves a specific compensation by ID.

Parameters

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

Examples

client = Humaans.new(access_token: "your_access_token")
{:ok, compensation} = Humaans.Compensations.retrieve(client, "compensation_id")

update(client, id, params)

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

Updates a specific compensation by ID.

Parameters

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

Examples

client = Humaans.new(access_token: "your_access_token")
params = %{amount: 80_000}
{:ok, compensation} = Humaans.Compensations.update(client, "compensation_id", params)