Skip to content

An Elixir client for sending SMS with txtLocal APIs

License

Notifications You must be signed in to change notification settings

scripbox/txt_local_ex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TxtLocalEx

An Elixir client for sending SMS with txtLocal APIs

Install

  1. Add txt_local_ex to your list of dependencies in mix.exs:
def deps do
  [{:txt_local_ex, "~> 0.1.0"}]
end
  1. Ensure txt_local_ex is started before your application:
def application do
  [applications: [:txt_local_ex]]
end

Configure

Add the following to your config.exs file:

config :txt_local_ex,
  rate_limit_scale: "RATE_LIMIT_SCALE", # in milli seconds
  rate_limit_count: "RATE_LIMIT_COUNT" # number of api calls allowed within the time scale
  http_client: TxtLocalEx.HTTPClient.HTTPoison
  • For Development/Test environments

Add the following to your config/dev.exs/config/test.exs file:

config :your_app, :txt_local_ex_api, TxtLocalEx.InMemoryMessenger
  • For Staging/Production environments

Add the following to your config/staging.exs/config/production.exs file:

config :your_app, :txt_local_ex_api, TxtLocalEx.HttpMessenger

Usage

  1. Set the messenger to use at the top level
  @txt_local_api_client Application.get_env(:your_app, :txt_local_ex_api)
  1. Send SMS
  • The send_sms/6 function sends an sms to a given phone number from a given phone number.
# @txt_local_api_client.send_sms("YOUR_API_KEY", "from_number", "to_number", "body_text")
iex(1)> @txt_local_api_client.send_sms("15005550001", "15005550002", "message text")

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages