This module provides functions for managing custom field resources in the Humaans API.
Summary
Functions
Creates a new custom_field.
Deletes a specific custom_field by ID.
Lists all custom_fields.
Retrieves a specific custom_field by ID.
Updates a specific custom_field by ID.
Types
Functions
@spec create(client :: map(), params :: map() | keyword()) :: {:ok, Humaans.Resources.CustomField.t()} | {:error, Humaans.Error.t()}
Creates a new custom_field.
Parameters
client- Client created withHumaans.new/1params- Map of attributes for the new custom_field
Examples
client = Humaans.new(access_token: "your_access_token")
params = %{name: "T-shirt size", section: "basics", type: "select", config: %{choices: ["S", "M", "L"]}}
{:ok, custom_field} = Humaans.CustomFields.create(client, params)
@spec delete(client :: map(), id :: String.t()) :: {:ok, %{id: String.t(), deleted: boolean()}} | {:error, Humaans.Error.t()}
Deletes a specific custom_field by ID.
Parameters
client- Client created withHumaans.new/1id- String ID of the custom_field to delete
Examples
client = Humaans.new(access_token: "your_access_token")
{:ok, %{id: "custom_field_id", deleted: true}} = Humaans.CustomFields.delete(client, "custom_field_id")
@spec list(client :: map(), params :: map() | keyword() | [{String.t(), term()}]) :: {:ok, [Humaans.Resources.CustomField.t()]} | {:error, Humaans.Error.t()}
Lists all custom_fields.
Returns a list of custom_fields 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, custom_fields} = Humaans.CustomFields.list(client)
{:ok, custom_fields} = Humaans.CustomFields.list(client, %{})
@spec retrieve(client :: map(), id :: String.t()) :: {:ok, Humaans.Resources.CustomField.t()} | {:error, Humaans.Error.t()}
Retrieves a specific custom_field by ID.
Parameters
client- Client created withHumaans.new/1id- String ID of the custom_field to retrieve
Examples
client = Humaans.new(access_token: "your_access_token")
{:ok, custom_field} = Humaans.CustomFields.retrieve(client, "custom_field_id")
@spec update(client :: map(), id :: String.t(), params :: map() | keyword()) :: {:ok, Humaans.Resources.CustomField.t()} | {:error, Humaans.Error.t()}
Updates a specific custom_field by ID.
Parameters
client- Client created withHumaans.new/1id- String ID of the custom_field to updateparams- Map of attributes to update
Examples
client = Humaans.new(access_token: "your_access_token")
params = %{name: "Shirt size"}
{:ok, custom_field} = Humaans.CustomFields.update(client, "custom_field_id", params)