Copyright | (C) 2017- Mark Andrus Roberts |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Mark Andrus Roberts <markandrusroberts@gmail.com> |
Stability | provisional |
Safe Haskell | None |
Language | Haskell98 |
Control.Monad.Twilio
Description
- type Twilio = TwilioT IO
- runTwilio :: Credentials -> Twilio a -> IO a
- runTwilio' :: IO String -> IO String -> Twilio a -> IO a
- newtype TwilioT m a = TwilioT (Monad m => (Credentials, AccountSID) -> RequestT m a)
- runTwilioT :: MonadIO m => Credentials -> TwilioT m a -> m a
- runTwilioT' :: (MonadThrow m, MonadIO m) => m String -> m String -> TwilioT m a -> m a
- type Credentials = (AccountSID, AuthToken)
- data TwilioException
- = InvalidSID !Text
- | InvalidAuthToken !Text
- | InvalidCredentials
- | UnexpectedResponse !(Response ByteString)
The Twilio monad
This monad allows you to make authenticated REST API requests to Twilio
using your AccountSID
and AuthToken
.
runTwilio :: Credentials -> Twilio a -> IO a #
Run zero or more REST API requests to Twilio.
Parse an AccountSID
and AuthToken
before running zero or more REST API
requests to Twilio.
For example, you can fetch the Calls
resource in the IO
monad as follows:
module Main where import Control.Monad.IO.Class (liftIO) import System.Environment (getEnv) import Twilio.Calls as Calls import Twilio.Types -- | Print calls. main :: IO () main = runTwilio' (getEnv "ACCOUNT_SID") (getEnv "AUTH_TOKEN") $ Calls.get >>= liftIO . print
The Twilio monad transformer
This monad transformer allows you to make authenticated REST API requests
to Twilio using your AccountSID
and AuthToken
.
Constructors
TwilioT (Monad m => (Credentials, AccountSID) -> RequestT m a) |
Instances
MonadTrans TwilioT # | |
Monad m => Monad (TwilioT m) # | |
Functor (TwilioT m) # | |
Applicative m => Applicative (TwilioT m) # | |
MonadIO m => MonadIO (TwilioT m) # | |
MonadThrow m => MonadThrow (TwilioT m) # | |
Monad m => MonadRequest (TwilioT m) # | |
(MonadThrow m, Delete1 a) => Delete (a -> TwilioT m ()) # | |
(MonadThrow m, Post3 a b c r) => Post (a -> b -> c -> TwilioT m r) # | |
(MonadThrow m, Post2 a b r) => Post (a -> b -> TwilioT m r) # | |
(MonadThrow m, Post1 a r) => Post (a -> TwilioT m r) # | |
(MonadThrow m, Post0 r) => Post (TwilioT m r) # | |
(MonadThrow m, Get2 a b r) => Get (a -> b -> TwilioT m r) # | |
(MonadThrow m, Get1 a r) => Get (a -> TwilioT m r) # | |
(MonadThrow m, Get0 r) => Get (TwilioT m r) # | |
Monad m => MonadReader (Credentials, AccountSID) (TwilioT m) # | |
runTwilioT :: MonadIO m => Credentials -> TwilioT m a -> m a #
Run zero or more REST API requests to Twilio, unwrapping the inner monad
m
.
Arguments
:: (MonadThrow m, MonadIO m) | |
=> m String | Account SID |
-> m String | Authentication Token |
-> TwilioT m a | |
-> m a |
Parse an AccountSID
and AuthToken
before running zero or more REST API
requests to Twilio, unwrapping the inner monad m
.
Types
type Credentials = (AccountSID, AuthToken) #
Your AccountSID
and AuthToken
are used to make authenticated REST API
requests to Twilio.
data TwilioException #
The set of Exception
s that may be thrown when attempting to make
requests against Twilio's REST API.
Constructors
InvalidSID !Text | |
InvalidAuthToken !Text | |
InvalidCredentials | |
UnexpectedResponse !(Response ByteString) |
Instances