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
@type delete_response() :: {:ok, %{id: String.t(), deleted: bool()}} | {:error, Humaans.Error.t()}
@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()}
@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
@spec create(client :: map(), params :: map() | keyword()) :: {:ok, Humaans.Resources.Compensation.t()} | {:error, Humaans.Error.t()}
Creates a new compensation.
Parameters
client- Client created withHumaans.new/1params- 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)
@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 withHumaans.new/1id- 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")
@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 withHumaans.new/1params- 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, %{})
@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 withHumaans.new/1id- String ID of the compensation to retrieve
Examples
client = Humaans.new(access_token: "your_access_token")
{:ok, compensation} = Humaans.Compensations.retrieve(client, "compensation_id")
@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 withHumaans.new/1id- String ID of the compensation to updateparams- 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)