Handwrite v1.0.0 Handwrite.Model.Sender View Source
Represents the name and address of the person sending the card.
Example
%Handwrite.Model.Sender{
first_name: "First",
last_name: "Last",
street1: "123 6 Mile",
street2: nil,
city: "Detroit",
state: "MI",
zip: "12345"
} Link to this section Summary
Functions
Encoding, in this case, means converting a %Sender{} struct into a simple map, but providing validation feedback in the process.
Link to this section Types
Specs
Link to this section Functions
Specs
encode(Handwrite.Model.Sender.t()) :: {:error, String.t()} | {:ok, map()}
Encoding, in this case, means converting a %Sender{} 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> sender = %Handwrite.Model.Sender{...}
iex> Handwrite.Model.Sender.encode(sender)Returns one of the following:
{:ok, %{...}}
{:error, "A sender's first name is required"}
{:error, "A sender's last name is required"}
{:error, "A sender's address requires a street"}
{:error, "A sender's address requires a city"}
{:error, "A sender's address requires a state"}
{:error, "A sender's address requires a zip"}