https://github.com/smartlogic/augur
Augur deals with sending SMS.
https://github.com/smartlogic/augur
elixir
Last synced: 9 months ago
JSON representation
Augur deals with sending SMS.
- Host: GitHub
- URL: https://github.com/smartlogic/augur
- Owner: smartlogic
- License: mit
- Created: 2021-08-26T17:43:20.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-08-27T15:18:31.000Z (over 4 years ago)
- Last Synced: 2025-04-20T13:11:40.639Z (9 months ago)
- Topics: elixir
- Language: Elixir
- Homepage:
- Size: 20.5 KB
- Stars: 32
- Watchers: 7
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Augur
Augur deals with sending SMS.
## Installation
Add Augur to your deps:
```elixir
def deps do
[
{:augur, "~> 0.1.0"}
]
end
```
Initialize `Augur` in your supervision tree with the service config
that you wish to boot with.
For example, if you're using [Vapor](https://github.com/keathley/vapor) you
can do something similar to:
```elixir
def start(_type, _args) do
children = [
# ...
{Augur, augur_config()},
# ...
]
# ...
end
def augur_config() do
config = MyApp.Config.sms()
case config.provider do
"development" ->
%Augur.Development{}
"twilio" ->
%Augur.Twilio{
account_sid: config.twilio_account_sid,
auth_token: config.twilio_auth_token
}
end
end
```
## Using Augur
Using Augur is simple. Load the current configuration from `Augur.Config` and then send a text.
An example [Oban Worker](https://github.com/sorentwo/oban) is provided below. You should strongly consider
sending texts only in an out of band worker and not in a web request.
```elixir
defmodule MyApp.SMSWorker do
use Oban, queue: :sms
def perform(%Oban.Job{args: text_message}) do
config = Augur.Config.get()
from = text_message["from"]
to = text_message["to"]
message = text_message["message"]
case Augur.Service.send_text(config, from, to, message) do
:ok ->
:ok
{:error, exception} ->
raise exception
end
end
end
```