Carrier
This is an unofficial Elixir client for the excellent Smarty address verification service.
It's fairly bare-bones because all we need it for is verifying and standardizing addresses, however it might get beefed up in the future. There's a ton of data provided by Smarty in addition to the verification process, and some of it might be pretty useful to have (such as geo-coding, timezone data, etc.).
It is essentially just a GenServer that handles the minutiae of communicating
with the Smarty API.
Installation
Add carrier to your list of dependencies in mix.exs:
def deps do
[{:carrier, "~> 2.0"}]
endConfiguration
Carrier supports environment-specific configuration for working with the Smarty API. You can configure it in different ways depending on your environment:
Production
In production, use environment variables for sensitive data:
# config/prod.exs
config :carrier, Carrier,
auth_id: System.get_env("SMARTY_AUTH_ID"),
auth_token: System.get_env("SMARTY_AUTH_TOKEN")Development
For local development, you can either:
Set environment variables:
export SMARTY_AUTH_ID=your_auth_id_here export SMARTY_AUTH_TOKEN=your_auth_token_hereOr create a
.envfile based on the provided.env.exampleand use a library like Dotenv to load it.
Testing and CI
For testing and CI environments, you can:
- Set environment variables in your CI platform
-
Use the default test values provided in
config/test.exs
# config/test.exs
config :carrier, Carrier,
auth_id: System.get_env("SMARTY_AUTH_ID") || "test_auth_id",
auth_token: System.get_env("SMARTY_AUTH_TOKEN") || "test_auth_token"Continuous Integration
Carrier uses GitHub Actions for continuous integration. The CI pipeline automatically:
-
Runs on every push to the
mainbranch and on all pull requests -
Tests across multiple Elixir and OTP versions using a build matrix:
- Elixir: 1.17, 1.18
- OTP: 26, 27
- Verifies that the codebase compiles successfully
- Ensures all tests pass
- Checks code formatting
You can see the CI configuration in .github/workflows/ci.yml.
Usage
TBD