https://github.com/infinitered/ups
Address validation/normalization against UPS API
https://github.com/infinitered/ups
Last synced: 9 months ago
JSON representation
Address validation/normalization against UPS API
- Host: GitHub
- URL: https://github.com/infinitered/ups
- Owner: infinitered
- License: mit
- Created: 2017-07-05T18:49:59.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-11T15:47:30.000Z (over 8 years ago)
- Last Synced: 2025-04-13T08:58:36.316Z (9 months ago)
- Language: Elixir
- Size: 22.5 KB
- Stars: 3
- Watchers: 10
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://semaphoreci.com/ir/ups)
# 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](https://www.ups.com/upsdeveloperkit?loc=en_US)
## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `ups` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:ups, "~> 0.2.0"}]
end
```
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/ups](https://hexdocs.pm/ups).
## Configuration
Add the following to your `config.exs` file:
```elixir
config :ups,
access_key: {:system, "UPS_ACCESS_KEY"},
username: {:system, "UPS_USERNAME"},
password: {:system, "UPS_PASSWORD"}
```
## Usage
#### Address Validation
```elixir
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" => ""
}
}}}}
```