ExCorreios v1.1.4 ExCorreios.Calculator.Shipping.Package View Source

This module provides a package struct

Link to this section Summary

Functions

Build a package with one or more items to calculate shipping

Link to this section Types

Link to this type

t()

View Source
t() :: %ExCorreios.Calculator.Shipping.Package{
  diameter: float(),
  format: integer(),
  height: float(),
  length: float(),
  weight: float(),
  width: float()
}

Link to this section Functions

Link to this function

build(format, items)

View Source
build(atom(), [map()]) :: map()

Build a package with one or more items to calculate shipping

Examples

iex> dimensions = [%{diameter: 40, height: 2.0, length: 16.0, weight: 0.9, width: 11.0}] iex> ExCorreios.Shipping.Packages.Package.build(:package_box, dimensions) %ExCorreios.Shipping.Packages.Package{

diameter: 40,
format: 1,
height: 2.0,
length: 16.0,
weight: 0.9,
width: 11.0

}

# it's possible to pass only the weight to build a package iex> ExCorreios.Shipping.Packages.Package.build(:package_box, [%{weight: 0.3}]) %ExCorreios.Shipping.Packages.Package{

diameter: 0.0,
format: 1,
height: 2.0,
length: 16.0,
weight: 0.3,
width: 11.0

}