Humaans.EmergencyContacts (Humaans v0.6.0)

Copy Markdown View Source

This module provides functions for managing emergency contact resources in the Humaans API.

Summary

Functions

Creates a new emergency_contact.

Deletes a specific emergency_contact by ID.

Lists all emergency_contacts.

Retrieves a specific emergency_contact by ID.

Updates a specific emergency_contact by ID.

Types

delete_response()

@type delete_response() ::
  {:ok, %{id: String.t(), deleted: bool()}} | {:error, Humaans.Error.t()}

list_response()

@type list_response() ::
  {:ok,
   [
     %Humaans.Resources.EmergencyContact{
       created_at: term(),
       email: term(),
       id: term(),
       name: term(),
       person_id: term(),
       phone_number: term(),
       relationship: term(),
       updated_at: term()
     }
   ]}
  | {:error, Humaans.Error.t()}

response()

@type response() ::
  {:ok,
   %Humaans.Resources.EmergencyContact{
     created_at: term(),
     email: term(),
     id: term(),
     name: term(),
     person_id: term(),
     phone_number: term(),
     relationship: term(),
     updated_at: term()
   }}
  | {:error, Humaans.Error.t()}

Functions

create(client, params)

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

Creates a new emergency_contact.

Parameters

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

Examples

client = Humaans.new(access_token: "your_access_token")
params = %{personId: "person_abc", name: "Jane Doe", relationship: "Sibling", phoneNumber: "+44 7700 900000"}
{:ok, emergency_contact} = Humaans.EmergencyContacts.create(client, params)

delete(client, id)

@spec delete(client :: map(), id :: String.t()) ::
  {:ok, %{id: String.t(), deleted: boolean()}} | {:error, Humaans.Error.t()}

Deletes a specific emergency_contact by ID.

Parameters

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

Examples

client = Humaans.new(access_token: "your_access_token")
{:ok, %{id: "emergency_contact_id", deleted: true}} = Humaans.EmergencyContacts.delete(client, "emergency_contact_id")

list(client, params \\ %{})

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

Lists all emergency_contacts.

Returns a list of emergency_contacts 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, emergency_contacts} = Humaans.EmergencyContacts.list(client)
{:ok, emergency_contacts} = Humaans.EmergencyContacts.list(client, %{})

retrieve(client, id)

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

Retrieves a specific emergency_contact by ID.

Parameters

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

Examples

client = Humaans.new(access_token: "your_access_token")
{:ok, emergency_contact} = Humaans.EmergencyContacts.retrieve(client, "emergency_contact_id")

update(client, id, params)

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

Updates a specific emergency_contact by ID.

Parameters

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

Examples

client = Humaans.new(access_token: "your_access_token")
params = %{phoneNumber: "+44 7700 900001"}
{:ok, emergency_contact} = Humaans.EmergencyContacts.update(client, "emergency_contact_id", params)