textlocal 0.1.0.2 → 0.1.0.3
raw patch · 2 files changed
+61/−16 lines, 2 files
Files
- src/Network/Api/TextLocal.hs +60/−15
- textlocal.cabal +1/−1
src/Network/Api/TextLocal.hs view
@@ -1,18 +1,55 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} +-- | Haskell wrapper for sending SMS using textlocal SMS gateway.+--+-- Sending SMS+--+-- 1. Get an api key from <http://textlocal.in 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})+-- @+-- module Network.Api.TextLocal- (Credential+ (+ -- * Credential+ Credential ,createApiKey ,createUserHash- ,SMSSettings+ ,+ -- * Settings+ SMSSettings ,defaultSMSSettings- ,setManager+ ,+ -- ** Setters+ setManager ,setDestinationNumber ,setMessage ,setAuth- ,runSettings- ,sendSMS)+ ,setTest+ ,+ -- * Send SMS+ runSettings+ ,sendSMS+ ,Command(..)) where import Data.Text (Text)@@ -26,8 +63,9 @@ import Data.Monoid ((<>)) import Network.Api.Types --- |--- Credential for making request to textLocal server.+-- | 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. data Credential = ApiKey ByteString | UserHash ByteString -- Email address@@ -36,13 +74,17 @@ baseUrl :: String baseUrl = "https://api.textlocal.in/" --- | Create 'Credential' for textLocal.+-- | Create 'Credential' for textLocal using api key. createApiKey- :: ByteString -- Api key+ :: ByteString -- ^ Api key -> Credential createApiKey apiKey = ApiKey apiKey -createUserHash :: ByteString -> ByteString -> Credential+-- | Create 'Credential' for textLocal using email and secure hash.+createUserHash+ :: ByteString -- ^ Email address+ -> ByteString -- ^ Secure hash that is found within the messenger.+ -> Credential createUserHash email hash = UserHash email hash formCred (ApiKey apikey) = [partBS "apiKey" apikey]@@ -74,10 +116,10 @@ } -- | 'defaultSMSSettings' has the default settings, duh! The--- 'settingsSender' has a value of "TXTLCL". The accessors--- 'settingsMessage', 'settingsAuth', 'settingsNumber' contains a--- value of bottom. They have to be initialized to a proper value--- before sending SMS.+-- '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. defaultSMSSettings = SMSSettings { settingsSender = "TXTLCL"@@ -121,7 +163,10 @@ { settingsManager = Just mgr } -setTest :: Bool -> SMSSettings -> SMSSettings+-- | 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.+setTest+ :: Bool -> SMSSettings -> SMSSettings setTest test set = set { settingsTest = Just test
textlocal.cabal view
@@ -1,5 +1,5 @@ name: textlocal-version: 0.1.0.2+version: 0.1.0.3 synopsis: Haskell wrapper for textlocal SMS gateway description: Please see README.md homepage: https://github.com/just-chow/textlocal