View Source UspsEx.Package (usps_ex v2023.1.27)
Defines the struct for storing a Package
, which is then passed along with
an origin and destination address for shipping estimates. A description
is
optional, as it may or may not be used with various carriers.
For USPS, a package has a container
string which can be one of the
pre-defined USPS containers.
Do not pass a weight
parameter. Instead, pass in a list of :items
with a
weight parameter on each of these. The weight on the package will be the sum
of the weights of each of these. Same for :monetary_value
.
:description
can optionally be passed in. Otherwise, it will be generated
by joining the descriptions of each of the items.
UspsEx.Package.package(%{length: 8,
width: 8,
height: 8,
items: [
%{weight: 1, monetary_value: 100, description: "A"},
%{weight: 2, monetary_value: 200, description: "B"}
]})
# => %Package{weight: 3, monetary_value: 300, description: "A, B", ...}
Link to this section Summary
Functions
Builds and returns a Package
. Use this instead of directly initializing
the struct.
Link to this section Types
@type t() :: %UspsEx.Package{ container: nil | atom() | String.t(), description: nil | String.t(), distance_unit: atom(), extra: nil | String.t(), girth: nil | number(), height: number(), insurance: nil | Map.t(), items: [UspsEx.Item.t()], length: number(), mass_unit: atom(), meta: nil | String.t(), monetary_value: number(), pricing_and_availability: term(), weight: number(), width: number() }
Link to this section Functions
Builds and returns a Package
. Use this instead of directly initializing
the struct.