textlocal-0.1.0.3: Haskell wrapper for textlocal SMS gateway

Safe HaskellNone
LanguageHaskell2010

Network.Api.TextLocal

Contents

Description

Haskell wrapper for sending SMS using textlocal SMS gateway.

Sending SMS

  1. Get an api key from textlocal.in
  2. 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})

Synopsis

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.

createApiKey Source #

Arguments

:: ByteString

Api key

-> Credential 

Create Credential for textLocal using api key.

createUserHash Source #

Arguments

:: ByteString

Email address

-> ByteString

Secure hash that is found within the messenger.

-> Credential 

Create Credential for textLocal using email and secure hash.

Settings

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

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.

Send SMS

sendSMS Source #

Arguments

:: ByteString

Text to send

-> [ByteString]

Destination numbers

-> Credential 
-> IO (Either JSONException TLResponse)