Functions for interacting with locations (companies) in Deputy.
Summary
Functions
Archive a location.
Same as archive/2 but raises on error.
Add a new location.
Same as create/2 but raises on error.
Add a new workplace with areas.
Same as create_workplace/2 but raises on error.
Delete a location.
Same as delete/2 but raises on error.
Get location by ID.
Same as get/2 but raises on error.
Get a location's settings.
Same as get_settings/2 but raises on error.
Get all locations.
Same as list/1 but raises on error.
Get a simplified list of locations.
Same as list_simplified/1 but raises on error.
Update a location.
Same as update/3 but raises on error.
Modify settings for all locations.
Same as update_all_settings/2 but raises on error.
Modify settings for a single location.
Same as update_settings/3 but raises on error.
Functions
@spec archive(Deputy.t(), integer()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Archive a location.
Parameters
client: A Deputy client.id: The ID of the location to archive.
Examples
client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
Deputy.Locations.archive(client, 1)
# => {:ok, %{"success" => true}}
Same as archive/2 but raises on error.
@spec create(Deputy.t(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Add a new location.
Parameters
client: A Deputy client.attrs: A map containing the new location details.
Location parameters
strWorkplaceName: String naming the workplace.strWorkplaceCode: A string with a length of 3 allowing you to define a short code for the location.strAddress: String of the location's address.strAddressNotes: Optional. Notes about the address.intParentCompany: Optional. Integer ID of parent company.intIsWorkplace: Boolean (1 - True, 0 - False) whether the location is considered a workplace.intIsPayrollEntity: Boolean (1 - True, 0 - False) whether the location has payroll setup.strTimezone: Timezone for the workplace using TZ database naming.strPayrollExportCode: Optional. String naming what to use as a code for payroll exports.
Examples
client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
attrs = %{
strWorkplaceName: "New Location",
strWorkplaceCode: "NLC",
strAddress: "123 Test St",
intIsWorkplace: 1,
intIsPayrollEntity: 1,
strTimezone: "America/New_York"
}
Deputy.Locations.create(client, attrs)
# => {:ok, %{"Id" => 123}}
Same as create/2 but raises on error.
@spec create_workplace(Deputy.t(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Add a new workplace with areas.
Parameters
client: A Deputy client.attrs: A map containing the new workplace details.
Workplace parameters
strWorkplaceName: String naming the workplace.strWorkplaceTimezone: Timezone for the workplace using TZ database naming.strAddress: String of the location's address.strLat: The latitude of the location using a string.strLon: The longitude of the location using a string.intCountry: An integer which defines which country the location is in.arrAreaNames: An array of the area names to add to the location.strWorkplaceCode: A string with a length of 3 allowing you to define a short code for the location.strPayrollExportCode: Optional. String naming what to use as a code for payroll exports.blnIsWorkplace: Boolean (1 - True, 0 - False) whether the location is considered a workplace.blnIsPayrollEntity: Boolean (1 - True, 0 - False) whether the location has payroll setup.
Examples
client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
attrs = %{
strWorkplaceName: "New Workplace",
strWorkplaceTimezone: "America/New_York",
strAddress: "123 Test St",
strLat: "40.7128",
strLon: "-74.0060",
intCountry: 1,
arrAreaNames: ["Reception", "Kitchen"],
strWorkplaceCode: "NWP",
blnIsWorkplace: 1,
blnIsPayrollEntity: 1
}
Deputy.Locations.create_workplace(client, attrs)
# => {:ok, %{"Id" => 123}}
Same as create_workplace/2 but raises on error.
@spec delete(Deputy.t(), integer()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Delete a location.
Parameters
client: A Deputy client.id: The ID of the location to delete.
Examples
client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
Deputy.Locations.delete(client, 1)
# => {:ok, %{"success" => true}}
Same as delete/2 but raises on error.
@spec get(Deputy.t(), integer()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Get location by ID.
This calls the /api/v1/my/location/:id endpoint, scoped to the
authenticated user's accessible locations. For that semantic, prefer
Deputy.My.location/2.
Parameters
client: A Deputy client.id: The ID of the location to retrieve.
Examples
client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
Deputy.Locations.get(client, 1)
# => {:ok, %{"Id" => 1, "CompanyName" => "Test Company"}}
Same as get/2 but raises on error.
@spec get_settings(Deputy.t(), integer()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Get a location's settings.
Parameters
client: A Deputy client.id: The ID of the location to retrieve settings for.
Examples
client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
Deputy.Locations.get_settings(client, 1)
# => {:ok, %{"WEEK_START" => 1}}
Same as get_settings/2 but raises on error.
@spec list(Deputy.t()) :: {:ok, [map()]} | {:error, Deputy.Error.t()}
Get all locations.
Examples
client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
Deputy.Locations.list(client)
# => {:ok, [%{"Id" => 1, "CompanyName" => "Test Company"}]}
Same as list/1 but raises on error.
@spec list_simplified(Deputy.t()) :: {:ok, [map()]} | {:error, Deputy.Error.t()}
Get a simplified list of locations.
Examples
client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
Deputy.Locations.list_simplified(client)
# => {:ok, [%{"Id" => 1, "CompanyName" => "Test Company"}]}
Same as list_simplified/1 but raises on error.
@spec update(Deputy.t(), integer(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Update a location.
Parameters
client: A Deputy client.id: The ID of the location to update.attrs: A map containing the fields to update.
Examples
client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
Deputy.Locations.update(client, 1, %{strWorkplaceCode: "UPD"})
# => {:ok, %{"success" => true}}
Same as update/3 but raises on error.
@spec update_all_settings(Deputy.t(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Modify settings for all locations.
Parameters
client: A Deputy client.settings: A map of settings to update.
Examples
client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
Deputy.Locations.update_all_settings(client, %{"WEEK_START" => 2})
# => {:ok, %{"success" => true}}
Same as update_all_settings/2 but raises on error.
@spec update_settings(Deputy.t(), integer(), map()) :: {:ok, map()} | {:error, Deputy.Error.t()}
Modify settings for a single location.
Parameters
client: A Deputy client.id: The ID of the location to update settings for.settings: A map of settings to update.
Examples
client = Deputy.new(base_url: "https://test.deputy.com", api_key: "test-key")
Deputy.Locations.update_settings(client, 1, %{"WEEK_START" => 2})
# => {:ok, %{"success" => true}}
Same as update_settings/3 but raises on error.