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

Functions for interacting with endpoints related to the authenticated user.

# `all_contact_addresses`

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

Get all the authenticated user's addresses including emergency contacts.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> Deputy.My.all_contact_addresses(client)
    {:ok, [%{"Street1" => "123 Main St", "City" => "New York"}]}

# `all_contact_addresses!`

```elixir
@spec all_contact_addresses!(Deputy.t()) :: [map()]
```

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

# `colleagues`

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

Get the authenticated user's colleagues.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> Deputy.My.colleagues(client)
    {:ok, [%{"Id" => 2, "FirstName" => "Jane", "LastName" => "Smith"}]}

# `colleagues!`

```elixir
@spec colleagues!(Deputy.t()) :: [map()]
```

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

# `complete_task`

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

Complete a task.

## Parameters

- `client`: A Deputy client.
- `id`: The ID of the task to complete.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> Deputy.My.complete_task(client, 1)
    {:ok, %{"success" => true}}

# `complete_task!`

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

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

# `contact_address`

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

Get the authenticated user's address.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> Deputy.My.contact_address(client)
    {:ok, %{"Street1" => "123 Main St", "City" => "New York"}}

# `contact_address!`

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

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

# `leave`

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

Get the authenticated user's leave requests.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> Deputy.My.leave(client)
    {:ok, [%{"Id" => 1, "DateStart" => "2023-01-01", "DateEnd" => "2023-01-05"}]}

# `leave!`

```elixir
@spec leave!(Deputy.t()) :: [map()]
```

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

# `location`

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

Get a specific location.

## Parameters

- `client`: A Deputy client.
- `id`: The ID of the location.

## Examples

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

# `location!`

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

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

# `locations`

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

Get locations where the authenticated user can work.

## Examples

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

# `locations!`

```elixir
@spec locations!(Deputy.t()) :: [map()]
```

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

# `me`

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

Get information about the authenticated user.

## Examples

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

# `me!`

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

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

# `memos`

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

Get the authenticated user's memos (newsfeed).

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> Deputy.My.memos(client)
    {:ok, [%{"Id" => 1, "Content" => "Welcome to Deputy"}]}

# `memos!`

```elixir
@spec memos!(Deputy.t()) :: [map()]
```

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

# `notifications`

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

Get the authenticated user's notifications.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> Deputy.My.notifications(client)
    {:ok, [%{"Id" => 1, "Message" => "You have a new roster"}]}

# `notifications!`

```elixir
@spec notifications!(Deputy.t()) :: [map()]
```

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

# `rosters`

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

Get the authenticated user's rosters.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> Deputy.My.rosters(client)
    {:ok, [%{"Id" => 1, "StartTime" => "2023-01-01T09:00:00"}]}

# `rosters!`

```elixir
@spec rosters!(Deputy.t()) :: [map()]
```

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

# `setup`

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

Get setup information for the authenticated user.

## Examples

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

# `setup!`

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

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

# `tasks`

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

Get the authenticated user's tasks.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> Deputy.My.tasks(client)
    {:ok, [%{"Id" => 1, "TaskName" => "Complete training"}]}

# `tasks!`

```elixir
@spec tasks!(Deputy.t()) :: [map()]
```

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

# `timesheet_detail`

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

Get details for a specific timesheet.

## Parameters

- `client`: A Deputy client.
- `id`: The ID of the timesheet.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> Deputy.My.timesheet_detail(client, 1)
    {:ok, %{"Id" => 1, "StartTime" => "2023-01-01T09:00:00"}}

# `timesheet_detail!`

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

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

# `timesheets`

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

Get the authenticated user's timesheets.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> Deputy.My.timesheets(client)
    {:ok, [%{"Id" => 1, "StartTime" => "2023-01-01T09:00:00"}]}

# `timesheets!`

```elixir
@spec timesheets!(Deputy.t()) :: [map()]
```

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

# `training`

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

Get the authenticated user's training.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> Deputy.My.training(client)
    {:ok, [%{"Id" => 1, "Name" => "Safety Training"}]}

# `training!`

```elixir
@spec training!(Deputy.t()) :: [map()]
```

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

# `unavailability`

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

Get the authenticated user's unavailability.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> Deputy.My.unavailability(client)
    {:ok, [%{"Id" => 1, "Start" => %{"timestamp" => 1657001675}}]}

# `unavailability!`

```elixir
@spec unavailability!(Deputy.t()) :: [map()]
```

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

# `update_contact_address`

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

Update the authenticated user's address.

## Parameters

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

## Address parameters

- `ContactName`: Name for the contact.
- `UnitNo`: Unit number.
- `Street1`: Street address.
- `City`: City.
- `State`: State code.
- `Postcode`: Postal code.
- `Country`: Country ID.
- `Notes`: Optional notes.

## Examples

    iex> client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
    iex> attrs = %{
    ...>   ContactName: "John Doe",
    ...>   UnitNo: "2",
    ...>   Street1: "123 Main St",
    ...>   City: "New York",
    ...>   State: "NY",
    ...>   Postcode: "10001",
    ...>   Country: 1
    ...> }
    iex> Deputy.My.update_contact_address(client, attrs)
    {:ok, %{"success" => true}}

# `update_contact_address!`

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

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

---

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