Humaans.DocumentTypes (Humaans v0.6.0)

Copy Markdown View Source

This module provides functions for managing document type resources in the Humaans API. Note that document types do not support deletion.

Summary

Functions

Creates a new document_type.

Lists all document_types.

Retrieves a specific document_type by ID.

Updates a specific document_type by ID.

Types

list_response()

@type list_response() ::
  {:ok,
   [
     %Humaans.Resources.DocumentType{
       company_id: term(),
       created_at: term(),
       id: term(),
       name: term(),
       updated_at: term()
     }
   ]}
  | {:error, Humaans.Error.t()}

response()

@type response() ::
  {:ok,
   %Humaans.Resources.DocumentType{
     company_id: term(),
     created_at: term(),
     id: term(),
     name: term(),
     updated_at: term()
   }}
  | {:error, Humaans.Error.t()}

Functions

create(client, params)

@spec create(client :: map(), params :: map() | keyword()) ::
  {:ok, Humaans.Resources.DocumentType.t()} | {:error, Humaans.Error.t()}

Creates a new document_type.

Parameters

  • client - Client created with Humaans.new/1
  • params - Map of attributes for the new document_type

Examples

client = Humaans.new(access_token: "your_access_token")
params = %{name: "Passport"}
{:ok, document_type} = Humaans.DocumentTypes.create(client, params)

list(client, params \\ %{})

@spec list(client :: map(), params :: map() | keyword() | [{String.t(), term()}]) ::
  {:ok, [Humaans.Resources.DocumentType.t()]} | {:error, Humaans.Error.t()}

Lists all document_types.

Returns a list of document_types matching the optional filter params.

Parameters

  • client - Client created with Humaans.new/1
  • params - Optional map of filter parameters (default: %{})

Examples

client = Humaans.new(access_token: "your_access_token")
{:ok, document_types} = Humaans.DocumentTypes.list(client)
{:ok, document_types} = Humaans.DocumentTypes.list(client, %{})

retrieve(client, id)

@spec retrieve(client :: map(), id :: String.t()) ::
  {:ok, Humaans.Resources.DocumentType.t()} | {:error, Humaans.Error.t()}

Retrieves a specific document_type by ID.

Parameters

  • client - Client created with Humaans.new/1
  • id - String ID of the document_type to retrieve

Examples

client = Humaans.new(access_token: "your_access_token")
{:ok, document_type} = Humaans.DocumentTypes.retrieve(client, "document_type_id")

update(client, id, params)

@spec update(client :: map(), id :: String.t(), params :: map() | keyword()) ::
  {:ok, Humaans.Resources.DocumentType.t()} | {:error, Humaans.Error.t()}

Updates a specific document_type by ID.

Parameters

  • client - Client created with Humaans.new/1
  • id - String ID of the document_type to update
  • params - Map of attributes to update

Examples

client = Humaans.new(access_token: "your_access_token")
params = %{name: "Identity Document"}
{:ok, document_type} = Humaans.DocumentTypes.update(client, "document_type_id", params)