servant-smsc-ru-0.1.0.0: Servant client for smsc.ru service for sending SMS to cell phones

Copyright(c) Anton Gushcha, 2016
LicenseMIT
Maintainerncrashed@gmail.com
Stabilityexperimental
PortabilityPortable
Safe HaskellNone
LanguageHaskell2010

Servant.API.SMSC.RU

Contents

Description

The module contains general and simplified functions to call smsc.ru service for sending SMS/MMS messages.

The general API is provided by genericSmsSend function, but it is too overengineered to be used as is. Thats why several simplified wrappers are presented.

First, you need to provide SmscConfig value:

cfg <- defaultSmscConfig
let testSmscConfig = cfg {
        smscLogin = "mylogin"
      , smscPassword = "mypass"
      }

After that you can send a SMS:

res <- simpleSmsSend testSmscConfig testPhone "Test message"
case res of 
  Left er -> printLn $ "message sending: " ++ show er
  Right _ -> return ()

Or check how much it would cost to you:

res <- getSimpleSmsCost testSmscConfig testPhone "Test message"
case res of 
  Left er -> assertFailure $ "message costing: " <> show er
  Right v -> putStrLn $ "message cost: " <> show v

Synopsis

API

type SMSCAPI = SendEndpoint Source

All supported API of smsc.ru service

Endpoints

data SendResponse Source

Response for SendEndpoint

Constructors

SendError

Server returned error payload

Fields

sendError :: !Text

Desciption of error

sendErrorCode :: !SendErrorCode

Error code

sendErrorId :: !(Maybe Text)

ID of failed message

SendSuccess

Server retunred success payload

Fields

sendSuccId :: !(Maybe Word)

ID of sended message

sendSuccCnt :: !Word

Count of messages sended (huge payloads are splitted)

sendSuccCost :: !(Maybe Text)

Cost of sending

sendSuccBalance :: !(Maybe Text)

Funds of the account left after the call

sendSuccPhones :: !(Maybe [PhoneResp])

Additional info by phone number

data PhoneResp Source

Additional info about phone number

Constructors

PhoneResp 

type SendEndpoint = "sys" :> ("send.php" :> (QueryParam "login" Text :> (QueryParam "psw" Text :> (QueryParam "phones" Text :> (QueryParam "mes" Text :> (QueryParam "id" Text :> (QueryParam "sender" Text :> (QueryParam "translit" Text :> (QueryParam "tinyurl" Text :> (QueryParam "time" Text :> (QueryParam "tz" Text :> (QueryParam "period" Double :> (QueryParam "freq" Word :> (QueryParam "flash" Word :> (QueryParam "bin" Text :> (QueryParam "push" Word :> (QueryParam "hlr" Word :> (QueryParam "ping" Word :> (QueryParam "mms" Word :> (QueryParam "mail" Word :> (QueryParam "call" Word :> (QueryParam "voice" Text :> (QueryParam "param" Text :> (QueryParam "subj" Text :> (QueryParam "charset" Text :> (QueryParam "cost" Word :> (QueryParam "fmt" Word :> (QueryParam "list" Text :> (QueryParam "valid" Text :> (QueryParam "maxsms" Word :> (QueryParam "imgcode" Text :> (QueryParam "userip" Text :> (QueryParam "err" Word :> (QueryParam "op" Word :> (QueryParam "pp" Text :> (ReqBody `[OctetStream]` ByteString :> Post `[JSON]` SendResponse)))))))))))))))))))))))))))))))))))) Source

Endpoint for sending sms, this is low-level most general API that is used to build small helper functions.

Client

genericSmsSend Source

Arguments

:: Maybe Text

login

-> Maybe Text

psw

-> Maybe Text

phones

-> Maybe Text

mes

-> Maybe Text

id

-> Maybe Text

sender

-> Maybe Text

translit

-> Maybe Text

tinyurl

-> Maybe Text

time

-> Maybe Text

tz

-> Maybe Double

period

-> Maybe Word

freq

-> Maybe Word

flash

-> Maybe Text

bin

-> Maybe Word

push

-> Maybe Word

hlr

-> Maybe Word

ping

-> Maybe Word

mms

-> Maybe Word

mail

-> Maybe Word

call

-> Maybe Text

voice

-> Maybe Text

param

-> Maybe Text

subj

-> Maybe Text

charset

-> Maybe Word

cost

-> Maybe Word

fmt, should be always 3

-> Maybe Text

list

-> Maybe Text

valid

-> Maybe Word

maxsms

-> Maybe Text

imgcode

-> Maybe Text

userip

-> Maybe Word

err

-> Maybe Word

op

-> Maybe Text

pp

-> ByteString

Request body (voice messages and etc)

-> Manager 
-> BaseUrl 
-> ClientM SendResponse 

The most generic call to the send endpoint

Simplified

data SmscConfig Source

Required common info for smsc API

Constructors

SmscConfig 

Fields

smscLogin :: !Text

Account login

smscPassword :: !Text

Account password

smscManager :: !Manager

Connection manager (use http-)

smscBaseUrl :: !BaseUrl
 

simpleSmsSend Source

Arguments

:: MonadIO m 
=> SmscConfig

Authorisation and other general config

-> Text

Phone

-> Text

Message

-> m (Either Text SendResponse) 

Simple send message to given phone

getSimpleSmsCost Source

Arguments

:: MonadIO m 
=> SmscConfig

Authorisation and other general config

-> Text

Phone

-> Text

Message

-> m (Either Text Text) 

Getting cost of message without sending