Deputy.Utility (Deputy v0.2.1)
View SourceUtility functions for interacting with Deputy system features.
Summary
Functions
Add a webhook.
Create a memo (announcement).
Retrieve current system time for a specific location.
Get setup information for the authenticated user (where can I work/what do I do).
Retrieve current system time.
Get information about the authenticated user (who am I).
Functions
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}}
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}}
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 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"}]}}
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 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"}}