Deputy.My (Deputy v0.2.1)

View Source

Functions for interacting with endpoints related to the authenticated user.

Summary

Functions

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

Get the authenticated user's colleagues.

Complete a task.

Get the authenticated user's address.

Get the authenticated user's leave requests.

Get a specific location.

Get locations where the authenticated user can work.

Get information about the authenticated user.

Get the authenticated user's memos (newsfeed).

Get the authenticated user's notifications.

Get the authenticated user's rosters.

Get setup information for the authenticated user.

Get the authenticated user's tasks.

Get details for a specific timesheet.

Get the authenticated user's timesheets.

Get the authenticated user's training.

Get the authenticated user's unavailability.

Update the authenticated user's address.

Functions

all_contact_addresses(client)

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

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"}]}

colleagues(client)

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

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"}]}

complete_task(client, id)

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

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}}

contact_address(client)

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

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"}}

leave(client)

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

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"}]}

location(client, id)

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

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"}}

locations(client)

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

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"}]}

me(client)

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

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"}}

memos(client)

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

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"}]}

notifications(client)

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

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"}]}

rosters(client)

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

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"}]}

setup(client)

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

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"}]}}

tasks(client)

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

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"}]}

timesheet_detail(client, id)

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

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"}}

timesheets(client)

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

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"}]}

training(client)

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

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"}]}

unavailability(client)

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

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}}]}

update_contact_address(client, attrs)

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

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}}