Handwrite v1.0.0 Handwrite View Source
An Elixir wrapper for the Handwrite API.
Installation
The package can be installed by adding handwrite to your list of dependencies in mix.exs:
def deps do
[
{:handwrite, "~> 1.0.0"}
]
endConfiguration
To make API calls, it is necessary to configure your Handwrite API key. Add the following line to your config.exs file.
config :my_app, :handwrite, api_key: "test_HW_asdfasdfasdf"Usage
handwrite_config = Application.get_env(:my_app, :handwrite)
client = Handwrite.client(handwrite_config) Link to this section Summary
Functions
Gets an order by id.
Gets a list of handwritings.
Gets a list of stationeries (aka cards).
Sends a letter, which creates and order.
Link to this section Functions
Specs
client(keyword()) :: Tesla.Client.t()
Specs
get_order(Tesla.Client.t(), String.t()) :: {:error, String.t()} | {:error, %Handwrite.Response{body: term(), status: term()}} | {:ok, %Handwrite.Response{body: term(), status: term()}}
Gets an order by id.
Example
order_id = "5f6b5c09c77c9a00171c5304"
Handwrite.get_order(client, order_id)Returns one of the following:
{:error, "Error message"}
{:error, %Handwrite.Response{}}
{:ok, %Handwrite.Response{}} Specs
list_handwritings(Tesla.Client.t()) :: {:error, String.t()} | {:error, %Handwrite.Response{body: term(), status: term()}} | {:ok, %Handwrite.Response{body: term(), status: term()}}
Gets a list of handwritings.
Example
Handwrite.list_handwritings(client)Returns one of the following:
{:error, "Error message"}
{:error, %Handwrite.Response{}}
{:ok, %Handwrite.Response{}} Specs
list_stationeries(Tesla.Client.t()) :: {:error, String.t()} | {:error, %Handwrite.Response{body: term(), status: term()}} | {:ok, %Handwrite.Response{body: term(), status: term()}}
Gets a list of stationeries (aka cards).
Example
Handwrite.list_stationeries(client)Returns one of the following:
{:error, "Error message"}
{:error, %Handwrite.Response{}}
{:ok, %Handwrite.Response{}} Specs
send_letter(Tesla.Client.t(), Handwrite.Model.Letter.t()) :: {:error, String.t()} | {:error, %Handwrite.Response{body: term(), status: term()}} | {:ok, %Handwrite.Response{body: term(), status: term()}}
Sends a letter, which creates and order.
Example
letter = %Handwrite.Model.Letter{
card: "5dc304cfbc08d20016f1ec2f",
from: %Handwrite.Model.Sender{
city: "Detroit",
first_name: "First",
last_name: "Last",
state: "MI",
street1: "123 6 Mile",
street2: nil,
zip: "12345"
},
handwriting: "5dc306b0bc08d20016f1ec34",
message: "Hey! Thanks for being awesome.",
recipients: [
%Handwrite.Model.Recipient{
city: "San Francisco",
first_name: "First",
last_name: "Last",
state: "CA",
street1: "543 Market St",
zip: "54321"
}
]
}
Handwrite.send_letter(client, letter)Returns one of the following:
{:error, "Error message"}
{:error, %Handwrite.Response{}}
{:ok, %Handwrite.Response{}}