# `Deputy.Utility`
[🔗](https://github.com/sgerrand/ex_deputy/blob/v0.4.0/lib/deputy/utility.ex#L1)

Utility functions for interacting with Deputy system features.

# `add_webhook`

```elixir
@spec add_webhook(Deputy.t(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
```

Add a webhook.

## Parameters

- `client`: A Deputy client.
- `attrs`: A map containing the webhook details.

## Webhook parameters

- `Topic`: Event to subscribe to (e.g., "Timesheet.Insert").
- `Enabled`: Whether the webhook is enabled (1 for true, 0 for false).
- `Type`: Type of webhook (e.g., "URL").
- `Address`: URL to send webhook events to.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> attrs = %{
    ...>   Topic: "Timesheet.Insert",
    ...>   Enabled: 1,
    ...>   Type: "URL",
    ...>   Address: "https://example.com/webhook"
    ...> }
    iex> Deputy.Utility.add_webhook(client, attrs)
    {:ok, %{"Id" => 123}}

# `add_webhook!`

```elixir
@spec add_webhook!(Deputy.t(), map()) :: map()
```

Same as `add_webhook/2` but raises on error.

# `create_memo`

```elixir
@spec create_memo(Deputy.t(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
```

Create a memo (announcement).

## Parameters

- `client`: A Deputy client.
- `attrs`: A map containing the memo details.

## Memo parameters

- `strContent`: Content of the memo.
- `intCompany`: ID of the company/location.
- `blnRequireConfirm`: Whether confirmation is required (1 for true, 0 for false).

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> attrs = %{
    ...>   strContent: "Hello, this is a memo",
    ...>   intCompany: 1,
    ...>   blnRequireConfirm: 0
    ...> }
    iex> Deputy.Utility.create_memo(client, attrs)
    {:ok, %{"Id" => 123}}

# `create_memo!`

```elixir
@spec create_memo!(Deputy.t(), map()) :: map()
```

Same as `create_memo/2` but raises on error.

# `get_location_time`

```elixir
@spec get_location_time(Deputy.t(), integer()) ::
  {:ok, map()} | {:error, Deputy.Error.t()}
```

Retrieve current system time for a specific location.

## Parameters

- `client`: A Deputy client.
- `location_id`: The ID of the location to get time for.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> Deputy.Utility.get_location_time(client, 1)
    {:ok, %{"time" => 1672531200, "tz" => "America/New_York"}}

# `get_location_time!`

```elixir
@spec get_location_time!(Deputy.t(), integer()) :: map()
```

Same as `get_location_time/2` but raises on error.

# `get_setup`

```elixir
@spec get_setup(Deputy.t()) :: {:ok, map()} | {:error, Deputy.Error.t()}
```

Get setup information for the authenticated user (where can I work/what do I do).

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> Deputy.Utility.get_setup(client)
    {:ok, %{"locations" => [%{"Id" => 1, "Name" => "Main Office"}]}}

# `get_setup!`

```elixir
@spec get_setup!(Deputy.t()) :: map()
```

Same as `get_setup/1` but raises on error.

# `get_time`

```elixir
@spec get_time(Deputy.t()) :: {:ok, map()} | {:error, Deputy.Error.t()}
```

Retrieve current system time.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> Deputy.Utility.get_time(client)
    {:ok, %{"time" => 1672531200, "tz" => "UTC"}}

# `get_time!`

```elixir
@spec get_time!(Deputy.t()) :: map()
```

Same as `get_time/1` but raises on error.

# `who_am_i`

```elixir
@spec who_am_i(Deputy.t()) :: {:ok, map()} | {:error, Deputy.Error.t()}
```

Get information about the authenticated user (who am I).

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> Deputy.Utility.who_am_i(client)
    {:ok, %{"Id" => 1, "FirstName" => "John", "LastName" => "Doe"}}

# `who_am_i!`

```elixir
@spec who_am_i!(Deputy.t()) :: map()
```

Same as `who_am_i/1` but raises on error.

---

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