This module provides functions for managing document resources in the Humaans API.
Summary
Functions
Creates a new document.
Deletes a specific document by ID.
Lists all documents.
Retrieves a specific document by ID.
Updates a specific document by ID.
Types
@type delete_response() :: {:ok, %{id: String.t(), deleted: bool()}} | {:error, Humaans.Error.t()}
@type list_response() :: {:ok, [ %Humaans.Resources.Document{ company_id: term(), created_at: term(), created_by: term(), document_type_id: term(), file: term(), file_id: term(), folder_id: term(), id: term(), issue_date: term(), link: term(), name: term(), person_id: term(), source: term(), source_id: term(), updated_at: term() } ]} | {:error, Humaans.Error.t()}
@type response() :: {:ok, %Humaans.Resources.Document{ company_id: term(), created_at: term(), created_by: term(), document_type_id: term(), file: term(), file_id: term(), folder_id: term(), id: term(), issue_date: term(), link: term(), name: term(), person_id: term(), source: term(), source_id: term(), updated_at: term() }} | {:error, Humaans.Error.t()}
Functions
@spec create(client :: map(), params :: map() | keyword()) :: {:ok, Humaans.Resources.Document.t()} | {:error, Humaans.Error.t()}
Creates a new document.
Parameters
client- Client created withHumaans.new/1params- Map of attributes for the new document
Examples
client = Humaans.new(access_token: "your_access_token")
params = %{personId: "person_abc", documentTypeId: "type_abc", name: "Passport", link: "https://example.com/passport.pdf"}
{:ok, document} = Humaans.Documents.create(client, params)
@spec delete(client :: map(), id :: String.t()) :: {:ok, %{id: String.t(), deleted: boolean()}} | {:error, Humaans.Error.t()}
Deletes a specific document by ID.
Parameters
client- Client created withHumaans.new/1id- String ID of the document to delete
Examples
client = Humaans.new(access_token: "your_access_token")
{:ok, %{id: "document_id", deleted: true}} = Humaans.Documents.delete(client, "document_id")
@spec list(client :: map(), params :: map() | keyword() | [{String.t(), term()}]) :: {:ok, [Humaans.Resources.Document.t()]} | {:error, Humaans.Error.t()}
Lists all documents.
Returns a list of documents matching the optional filter params.
Parameters
client- Client created withHumaans.new/1params- Optional map of filter parameters (default:%{})
Examples
client = Humaans.new(access_token: "your_access_token")
{:ok, documents} = Humaans.Documents.list(client)
{:ok, documents} = Humaans.Documents.list(client, %{})
@spec retrieve(client :: map(), id :: String.t()) :: {:ok, Humaans.Resources.Document.t()} | {:error, Humaans.Error.t()}
Retrieves a specific document by ID.
Parameters
client- Client created withHumaans.new/1id- String ID of the document to retrieve
Examples
client = Humaans.new(access_token: "your_access_token")
{:ok, document} = Humaans.Documents.retrieve(client, "document_id")
@spec update(client :: map(), id :: String.t(), params :: map() | keyword()) :: {:ok, Humaans.Resources.Document.t()} | {:error, Humaans.Error.t()}
Updates a specific document by ID.
Parameters
client- Client created withHumaans.new/1id- String ID of the document to updateparams- Map of attributes to update
Examples
client = Humaans.new(access_token: "your_access_token")
params = %{name: "Passport (renewed)"}
{:ok, document} = Humaans.Documents.update(client, "document_id", params)