| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Network.Api.TextLocal
Description
Haskell wrapper for sending SMS using textlocal SMS gateway.
Sending SMS
- Get an api key from textlocal.in
- Quick way to send:
>> import Network.Api.TextLocal
>> let cred = createUserHash "myemail@email.in" "my-secret-hash"
>> res <- sendSMS "hello world" ["911234567890"] cred
>> res
Right (TLResponse {status = Success, warnings = Nothing, errors = Nothing})
Or in a more configurable way:
>> import Network.Api.TextLocal
>> let cred = createUserHash "myemail@email.in" "my-secret-hash"
>> let destNums = ["911234567890"]
>> let mySettings = setDestinationNumber destNums $ setAuth cred $ setTest True defaultSMSSettings
>> res <- runSettings SendSMS (setMessage "hello world" mySettings)
>> res
Right (TLResponse {status = Success, warnings = Nothing, errors = Nothing})
- data Credential
- createApiKey :: ByteString -> Credential
- createUserHash :: ByteString -> ByteString -> Credential
- data SMSSettings
- defaultSMSSettings :: SMSSettings
- setManager :: Manager -> SMSSettings -> SMSSettings
- setDestinationNumber :: [ByteString] -> SMSSettings -> SMSSettings
- setMessage :: ByteString -> SMSSettings -> SMSSettings
- setAuth :: Credential -> SMSSettings -> SMSSettings
- setTest :: Bool -> SMSSettings -> SMSSettings
- setSender :: ByteString -> SMSSettings -> SMSSettings
- runSettings :: Command -> SMSSettings -> IO (Either JSONException TLResponse)
- sendSMS :: ByteString -> [ByteString] -> Credential -> IO (Either JSONException TLResponse)
- data Command = SendSMS
Credential
data Credential Source #
Credential for making request to textLocal server. There are
multiple ways for creating it. You can either use createApiKey or
createUserHash to create this type.
Arguments
| :: ByteString | Api key |
| -> Credential |
Create Credential for textLocal using api key.
Arguments
| :: ByteString | Email address |
| -> ByteString | Secure hash that is found within the messenger. |
| -> Credential |
Create Credential for textLocal using email and secure hash.
Settings
data SMSSettings Source #
defaultSMSSettings :: SMSSettings Source #
defaultSMSSettings has the default settings, duh! The
settingsSender has a value of TXTLCL. Using the accessors
setMessage, setAuth, setDestinationNumber you should properly
initialize their respective values. By default, these fields contain a
value of bottom.
Setters
setManager :: Manager -> SMSSettings -> SMSSettings Source #
Use an existing manager instead of creating a new one
setDestinationNumber :: [ByteString] -> SMSSettings -> SMSSettings Source #
setMessage :: ByteString -> SMSSettings -> SMSSettings Source #
setAuth :: Credential -> SMSSettings -> SMSSettings Source #
setTest :: Bool -> SMSSettings -> SMSSettings Source #
Set this field to true to enable test mode, no messages will be sent and your credit balance will be unaffected. It defaults to false.
setSender :: ByteString -> SMSSettings -> SMSSettings Source #
Send SMS
runSettings :: Command -> SMSSettings -> IO (Either JSONException TLResponse) Source #
Arguments
| :: ByteString | Text to send |
| -> [ByteString] | Destination numbers |
| -> Credential | |
| -> IO (Either JSONException TLResponse) |