Skip to content

Latest commit

 

History

History
82 lines (69 loc) · 2.08 KB

README.md

File metadata and controls

82 lines (69 loc) · 2.08 KB

Build Status

UPS

Basic Elixir HTTPoison wrapper around the UPS street level validation API. This wrapper could easily be extended to include more of UPS's offered APIs listed here

Installation

If available in Hex, the package can be installed by adding ups to your list of dependencies in mix.exs:

def deps do
  [{:ups, "~> 0.2.0"}]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/ups.

Configuration

Add the following to your config.exs file:

config :ups,
  access_key: {:system, "UPS_ACCESS_KEY"},
  username: {:system, "UPS_USERNAME"},
  password: {:system, "UPS_PASSWORD"}

Usage

Address Validation

iex> address = %{
  line1: "11815 NE 113th Street",
  line2: "Ste 104",
  city: "Vancouver",
  state: "Washington",
  zip: "98662",
  country: "US"
}

iex> UPS.validate_address(address)
{:ok, %{body: %{
  success: true,
  address: %{
    city: "VANCOUVER",
    country: "US",
    line1: "11815 NE 113TH ST",
    line2: "STE 104", state: "WA",
    zip: "986621640"
  },
  message: "Address is valid.",
  raw_body: %{
    "XAVResponse" => %{
      "Candidate" => %{
        "AddressKeyFormat" => %{
          "AddressLine" => ["11815 NE 113TH ST", "STE 104"],
          "CountryCode" => "US", "PoliticalDivision1" => "WA",
          "PoliticalDivision2" => "VANCOUVER", "PostcodeExtendedLow" => "1640",
          "PostcodePrimaryLow" => "98662",
          "Region" => "VANCOUVER WA 98662-1640"
        }
      },
      "Response" => %{
        "ResponseStatus" => %{
          "Code" => "1",
          "Description" => "Success"
        },
        "TransactionReference" => %{
          "CustomerContext" => "Customer Context"
        }
      },
      "ValidAddressIndicator" => ""
    }
  }}}}