BambooHR.Files (BambooHR v0.5.0)

Copy Markdown View Source

Functions for interacting with company and employee file resources in the BambooHR API.

Covers file categories, uploads, downloads, metadata updates, and deletion, for both company-wide files and employee-scoped files.

Summary

Functions

Creates one or more company file categories.

Creates one or more employee file categories (not company file categories).

Permanently deletes a company file.

Permanently deletes an employee file.

Downloads a company file by its ID.

Downloads an employee file by its ID.

Retrieves all company file categories and the files within each category that the requesting user is permitted to see.

Lists the file categories and files visible to the caller for the specified employee.

Updates metadata for an existing company file.

Updates metadata for an existing employee file.

Functions

create_company_file_category(client, category_names)

@spec create_company_file_category(BambooHR.Client.t(), [String.t()]) ::
  BambooHR.Client.response()

Creates one or more company file categories.

On success, returns nil (no response body).

Parameters

  • client - Client configuration created with BambooHR.Client.new/1
  • category_names - List of category name strings; each must be non-empty and unique among existing company file categories

Examples

iex> BambooHR.Files.create_company_file_category(client, ["Contracts"])
{:ok, nil}

create_employee_file_category(client, category_names)

@spec create_employee_file_category(BambooHR.Client.t(), [String.t()]) ::
  BambooHR.Client.response()

Creates one or more employee file categories (not company file categories).

On success, returns nil (no response body).

Parameters

  • client - Client configuration created with BambooHR.Client.new/1
  • category_names - List of category name strings; each must be non-empty and unique among existing employee file categories

Examples

iex> BambooHR.Files.create_employee_file_category(client, ["Certifications"])
{:ok, nil}

delete_company_file(client, file_id)

@spec delete_company_file(BambooHR.Client.t(), integer()) ::
  BambooHR.Client.response()

Permanently deletes a company file.

On success, returns nil (no response body).

Parameters

  • client - Client configuration created with BambooHR.Client.new/1
  • file_id - The ID of the company file to delete

Examples

iex> BambooHR.Files.delete_company_file(client, 123)
{:ok, nil}

delete_employee_file(client, employee_id, file_id)

@spec delete_employee_file(BambooHR.Client.t(), integer(), integer()) ::
  BambooHR.Client.response()

Permanently deletes an employee file.

Pass 0 as employee_id to use the employee associated with the API key. Idempotent — returns success even if the file was already deleted.

Parameters

  • client - Client configuration created with BambooHR.Client.new/1
  • employee_id - The ID of the employee whose file is being deleted
  • file_id - The ID of the employee file to delete

Examples

iex> BambooHR.Files.delete_employee_file(client, 123, 456)
{:ok, nil}

get_company_file(client, file_id)

@spec get_company_file(BambooHR.Client.t(), integer()) :: BambooHR.Client.response()

Downloads a company file by its ID.

Returns {:ok, %{body: binary_content, headers: headers}}. headers includes "content-type" and "content-disposition" (which carries the original filename) as BambooHR set them.

Parameters

  • client - Client configuration created with BambooHR.Client.new/1
  • file_id - The ID of the company file to download

Examples

iex> BambooHR.Files.get_company_file(client, 123)
{:ok, %{body: <<37, 80, 68, 70>>, headers: %{"content-type" => ["application/pdf"]}}}

get_employee_file(client, employee_id, file_id)

@spec get_employee_file(BambooHR.Client.t(), integer(), integer()) ::
  BambooHR.Client.response()

Downloads an employee file by its ID.

Pass 0 as employee_id to use the employee associated with the API key. Returns {:ok, %{body: binary_content, headers: headers}}. headers includes "content-type" and "content-disposition" (which carries the original filename) as BambooHR set them.

Parameters

  • client - Client configuration created with BambooHR.Client.new/1
  • employee_id - The ID of the employee whose file is being retrieved
  • file_id - The ID of the employee file to download

Examples

iex> BambooHR.Files.get_employee_file(client, 123, 456)
{:ok, %{body: <<37, 80, 68, 70>>, headers: %{"content-type" => ["application/pdf"]}}}

list_company_files(client)

@spec list_company_files(BambooHR.Client.t()) :: BambooHR.Client.response()

Retrieves all company file categories and the files within each category that the requesting user is permitted to see.

Parameters

Examples

iex> BambooHR.Files.list_company_files(client)
{:ok, %{"categories" => [%{"id" => 1, "name" => "Policies", "files" => []}]}}

list_employee_files(client, employee_id)

@spec list_employee_files(BambooHR.Client.t(), integer()) ::
  BambooHR.Client.response()

Lists the file categories and files visible to the caller for the specified employee.

This is a metadata listing (names, sizes, permissions); to download a file's content use get_employee_file/3.

Parameters

  • client - Client configuration created with BambooHR.Client.new/1
  • employee_id - The ID of the employee whose files are being listed

Examples

iex> BambooHR.Files.list_employee_files(client, 123)
{:ok, %{"employee" => %{"id" => 123}, "categories" => []}}

update_company_file(client, file_id, update_data)

@spec update_company_file(BambooHR.Client.t(), integer(), map()) ::
  BambooHR.Client.response()

Updates metadata for an existing company file.

Supports renaming the file, moving it to a different category, and toggling employee visibility. Only fields included in update_data are updated.

Parameters

  • client - Client configuration created with BambooHR.Client.new/1
  • file_id - The ID of the company file to update
  • update_data - Map with any of "name", "categoryId", "shareWithEmployee"

Examples

iex> BambooHR.Files.update_company_file(client, 123, %{"name" => "handbook-v2.pdf"})
{:ok, nil}

update_employee_file(client, employee_id, file_id, update_data)

@spec update_employee_file(BambooHR.Client.t(), integer(), integer(), map()) ::
  BambooHR.Client.response()

Updates metadata for an existing employee file.

Supports renaming the file, moving it to a different category, and toggling employee visibility. Only fields included in update_data are updated.

Parameters

  • client - Client configuration created with BambooHR.Client.new/1
  • employee_id - The ID of the employee whose file is being updated
  • file_id - The ID of the employee file to update
  • update_data - Map with any of "name", "categoryId", "shareWithEmployee"

Examples

iex> BambooHR.Files.update_employee_file(client, 123, 456, %{"name" => "resume-2024.pdf"})
{:ok, nil}

upload_company_file(client, file_name, category_id, file_content, opts \\ [])

@spec upload_company_file(
  BambooHR.Client.t(),
  String.t(),
  integer(),
  binary(),
  keyword()
) ::
  BambooHR.Client.response()

Uploads a file to a company file category.

On success, returns {:ok, %{"location" => url}}, where url points to the new file resource; {:ok, %{}} if no Location header is present.

Parameters

  • client - Client configuration created with BambooHR.Client.new/1
  • file_name - Display name for the uploaded file
  • category_id - ID of the file category (section) to upload into
  • file_content - Binary file content
  • opts - Optional keyword list: :share - whether to share the file with all employees (defaults to false)

Examples

iex> BambooHR.Files.upload_company_file(client, "handbook.pdf", 3, pdf_binary)
{:ok, %{"location" => "https://acme.bamboohr.com/files/123"}}

upload_employee_file(client, employee_id, file_name, category_id, file_content, opts \\ [])

@spec upload_employee_file(
  BambooHR.Client.t(),
  integer(),
  String.t(),
  integer(),
  binary(),
  keyword()
) ::
  BambooHR.Client.response()

Uploads a file to an employee's file section.

Pass 0 as employee_id to use the employee associated with the API key. On success, returns {:ok, %{"location" => url}}, where url points to the new file resource; {:ok, %{}} if no Location header is present.

Parameters

  • client - Client configuration created with BambooHR.Client.new/1
  • employee_id - The ID of the employee to upload the file for
  • file_name - Display name for the uploaded file
  • category_id - ID of the employee file section to upload into
  • file_content - Binary file content
  • opts - Optional keyword list: :share - whether to share the file with the employee (defaults to false)

Examples

iex> BambooHR.Files.upload_employee_file(client, 123, "resume.pdf", 5, pdf_binary)
{:ok, %{"location" => "https://acme.bamboohr.com/employees/files/456"}}