# `Humaans.Compensations`
[🔗](https://github.com/sgerrand/ex_humaans/blob/v0.4.2/lib/humaans/compensations.ex#L1)

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).

# `delete_response`

```elixir
@type delete_response() :: {:ok, %{id: String.t(), deleted: bool()}} | {:error, any()}
```

# `list_response`

```elixir
@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, any()}
```

# `response`

```elixir
@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, any()}
```

# `create`

```elixir
@callback create(client :: map(), map()) :: {:ok, map()} | {:error, any()}
```

# `delete`

```elixir
@callback delete(client :: map(), String.t()) :: {:ok, map()} | {:error, any()}
```

# `list`

```elixir
@callback list(client :: map(), map()) :: {:ok, map()} | {:error, any()}
```

# `retrieve`

```elixir
@callback retrieve(client :: map(), String.t()) :: {:ok, map()} | {:error, any()}
```

# `update`

```elixir
@callback update(client :: map(), String.t(), map()) :: {:ok, map()} | {:error, any()}
```

# `create`

```elixir
@spec create(client :: map(), params :: keyword()) :: response()
```

Creates a new compensation resource.

## Parameters

  * `client` - Client map created with `Humaans.new/1`
  * `params` - Map of parameters for the new compensation

## Examples

    client = Humaans.new(access_token: "your_access_token")

    params = %{
      personId: "person_id",
      compensationTypeId: "comp_type_id",
      amount: "70000",
      currency: "EUR",
      period: "annual",
      effectiveDate: "2023-01-01"
    }

    {:ok, compensation} = Humaans.Compensations.create(client, params)

# `delete`

```elixir
@spec delete(client :: map(), id :: String.t()) :: delete_response()
```

Deletes a specific compensation by ID.

## Parameters

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

## Examples

    client = Humaans.new(access_token: "your_access_token")

    {:ok, result} = Humaans.Compensations.delete(client, "comp_id")
    # result contains %{id: "comp_id", deleted: true}

# `list`

```elixir
@spec list(client :: map(), params :: keyword()) :: list_response()
```

Lists all compensation resources.

Returns a list of compensation resources that match the optional filters provided in `params`.

## Parameters

  * `client` - Client map created with `Humaans.new/1`
  * `params` - Optional parameters for filtering the results (default: `%{}`)

## Examples

    client = Humaans.new(access_token: "your_access_token")

    # List all compensations
    {:ok, compensations} = Humaans.Compensations.list(client)

    # List with filtering parameters
    {:ok, compensations} = Humaans.Compensations.list(client, %{personId: "person_id"})

# `retrieve`

```elixir
@spec retrieve(client :: map(), id :: String.t()) :: response()
```

Retrieves a specific compensation by ID.

## Parameters

  * `client` - Client map 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, "comp_id")

# `update`

```elixir
@spec update(client :: map(), id :: String.t(), params :: keyword()) :: response()
```

Updates a specific compensation by ID.

## Parameters

  * `client` - Client map created with `Humaans.new/1`
  * `id` - String ID of the compensation to update
  * `params` - Map of parameters to update

## Examples

    client = Humaans.new(access_token: "your_access_token")

    params = %{amount: "75000", note: "Annual raise"}

    {:ok, updated_comp} = Humaans.Compensations.update(client, "comp_id", params)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
