SmsUp (sms_up v1.4.1)
View SourceSmsUp is used to send sms throught SmsUP (other api may be integrated easily) by implementing the same behaviour. This module provides delegates to the internal modules for sending sms and the distributed One Time Password store. For the One Time Password functionality if you are part of a cluster the librairy uses mnesia to distibute the store accross the nodes.
Summary
Functions
Send a sms with the chosen Sender Module.
Configuration is available as :
config :sms_up, :deliver_module, MODULE
MODULE can be SmsUp.Delivery.LoggerDelivery (default) or SmsUp.Delivery.SmsUpDelivery.
Generate a pin code for the given id and store it in a mnesia database. Returns the generated pin code.
Validate a pin code along with the user id and tells if the provided pin is correct or not. Returns a tupple containing true or false regarding the result.
Functions
@spec send_sms(String.t(), String.t(), Keyword.t()) :: {:ok, %{body: String.t(), to: String.t(), options: Keyword.t()}} | {:error, String.t()}
Send a sms with the chosen Sender Module.
Configuration is available as :
config :sms_up, :deliver_module, MODULE
MODULE can be SmsUp.Delivery.LoggerDelivery (default) or SmsUp.Delivery.SmsUpDelivery.
Returns a ok tuple containing the message body and the number for which it was sent to or an error tuple with the reason.
Examples
iex> SmsUp.send_sms("+41765556677", "message")
{:ok, %{to: "+41765556677", body: "message"}}
Generate a pin code for the given id and store it in a mnesia database. Returns the generated pin code.
Examples
iex> SmsUp.store("user@email.ch")
{:ok, "123456"}
Validate a pin code along with the user id and tells if the provided pin is correct or not. Returns a tupple containing true or false regarding the result.
Examples
iex> SmsUp.validate("user@email.ch", "Good Pin")
{:ok, true}
iex> SmsUp.validate("user@email.ch", "Wrong Pin")
{:ok, false}