Handwrite v1.0.0 Handwrite.Model.Recipient View Source

Represents the name and address of the person receiving the card.

Example

%Handwrite.Model.Recipient{
  first_name: "First",
  last_name: "Last",
  street1: "543 Market St",
  city: "San Francisco",
  state: "CA",
  zip: "54321"
}

Link to this section Summary

Functions

Encoding, in this case, means converting a %Recipient{} struct into a simple map, but providing validation feedback in the process.

Link to this section Types

Specs

t() :: %Handwrite.Model.Recipient{
  city: String.t(),
  first_name: String.t(),
  last_name: String.t(),
  state: String.t(),
  street1: String.t(),
  zip: String.t()
}

Link to this section Functions

Specs

encode([Handwrite.Model.Recipient.t()]) :: [] | {:error, any()} | {:ok, list()}

Encoding, in this case, means converting a %Recipient{} struct into a simple map, but providing validation feedback in the process.

Typically, you shouldn't need to call encode directly, as it is handled inside of the send_letter function.

Example

iex> recipient = %Handwrite.Model.Recipient{...}
iex> Handwrite.Model.Recipient.encode(recipient)

Returns one of the following:

{:ok, %{...}}
{:error, "A recipient's first name is required"}
{:error, "A recipient's last name is required"}
{:error, "A recipient's address requires a street"}
{:error, "A recipient's address requires a city"}
{:error, "A recipient's address requires a state"}
{:error, "A recipient's address requires a zip"}