Deputy.My (Deputy v0.5.0)

Copy Markdown 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.

Same as colleagues/1 but raises on error.

Complete a task.

Same as complete_task/2 but raises on error.

Get the authenticated user's address.

Same as contact_address/1 but raises on error.

Get the authenticated user's leave requests.

Same as leave/1 but raises on error.

Get a specific location.

Same as location/2 but raises on error.

Get locations where the authenticated user can work.

Same as locations/1 but raises on error.

Get information about the authenticated user.

Same as me/1 but raises on error.

Get the authenticated user's memos (newsfeed).

Same as memos/1 but raises on error.

Get the authenticated user's notifications.

Same as notifications/1 but raises on error.

Get the authenticated user's rosters.

Same as rosters/1 but raises on error.

Get setup information for the authenticated user.

Same as setup/1 but raises on error.

Get the authenticated user's tasks.

Same as tasks/1 but raises on error.

Get details for a specific timesheet.

Same as timesheet_detail/2 but raises on error.

Get the authenticated user's timesheets.

Same as timesheets/1 but raises on error.

Get the authenticated user's training.

Same as training/1 but raises on error.

Get the authenticated user's unavailability.

Same as unavailability/1 but raises on error.

Update the authenticated user's address.

Functions

all_contact_addresses(client)

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

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

Examples

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

all_contact_addresses!(client)

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

Same as all_contact_addresses/1 but raises on error.

colleagues(client)

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

Get the authenticated user's colleagues.

Examples

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

colleagues!(client)

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

Same as colleagues/1 but raises on error.

complete_task(client, id)

@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

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

complete_task!(client, id)

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

Same as complete_task/2 but raises on error.

contact_address(client)

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

Get the authenticated user's address.

Examples

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

contact_address!(client)

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

Same as contact_address/1 but raises on error.

leave(client)

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

Get the authenticated user's leave requests.

Examples

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

leave!(client)

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

Same as leave/1 but raises on error.

location(client, id)

@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

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

location!(client, id)

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

Same as location/2 but raises on error.

locations(client)

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

Get locations where the authenticated user can work.

Examples

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

locations!(client)

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

Same as locations/1 but raises on error.

me(client)

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

Get information about the authenticated user.

Examples

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

me!(client)

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

Same as me/1 but raises on error.

memos(client)

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

Get the authenticated user's memos (newsfeed).

Examples

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

memos!(client)

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

Same as memos/1 but raises on error.

notifications(client)

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

Get the authenticated user's notifications.

Examples

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

notifications!(client)

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

Same as notifications/1 but raises on error.

rosters(client)

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

Get the authenticated user's rosters.

Examples

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

rosters!(client)

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

Same as rosters/1 but raises on error.

setup(client)

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

Get setup information for the authenticated user.

Examples

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

setup!(client)

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

Same as setup/1 but raises on error.

tasks(client)

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

Get the authenticated user's tasks.

Examples

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

tasks!(client)

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

Same as tasks/1 but raises on error.

timesheet_detail(client, id)

@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

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

timesheet_detail!(client, id)

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

Same as timesheet_detail/2 but raises on error.

timesheets(client)

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

Get the authenticated user's timesheets.

Examples

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

timesheets!(client)

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

Same as timesheets/1 but raises on error.

training(client)

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

Get the authenticated user's training.

Examples

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

training!(client)

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

Same as training/1 but raises on error.

unavailability(client)

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

Get the authenticated user's unavailability.

Examples

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

unavailability!(client)

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

Same as unavailability/1 but raises on error.

update_contact_address(client, attrs)

@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

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

update_contact_address!(client, attrs)

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

Same as update_contact_address/2 but raises on error.