pushover-0.1.0.1: A Haskell Pushover API library

Safe HaskellSafe
LanguageHaskell2010

Network.Pushover.Message

Contents

Description

This module provides functions for creating and encoding messages for use within Pushover requests.

Pushover messages contain a very limited subset of HTML. Users can insert bold, italic, underlined, and colored text, and URLs within messages. The Message type represents all of these possible formatting options.

Constructing a Message is done through the use of the message, bold, italic, underline, color, link, and text functions. The message function takes a list of parts created using the other functions, and concatenates these into a single message. Different types of formatting can be nested within each other by simply calling the functions on the results of other function calls. For example:-

  bold
    [ italic
        [ text "This is bold & italic"
        ]
    , text "This is bold"
    , underline
        [ text "This is bold & underlined"
        ]
    ]

will create a message with the text values formatted as described.

Synopsis

Creating a Message

data Message Source #

Represents a message sent to the Pushover API.

A Pushover message can be constructed with a very small subset of HTML. This type represents the available HTML formatting for a message.

message :: [Message] -> Message Source #

Make a message from a list of message parts.

bold :: [Message] -> Message Source #

Make a bold message.

italic :: [Message] -> Message Source #

Make an italic message.

underline :: [Message] -> Message Source #

Make an underlined message.

color :: Integer -> Integer -> Integer -> [Message] -> Message Source #

Make a message with colored text.

Accepts three integer arguments for red, green and blue color elements, respectively.

link :: Url -> [Message] -> Message Source #

Make a url message.

text :: Text -> Message Source #

Make a textual message.

Encoding for inclusion in request

encodeMessage :: Message -> ByteString Source #

Encode a Message into a bytestring.

This function is intended to convert a Message into a form useable within a Request. It generates a bytestring containing the HTML for the message.

Attributes

data ColorCode Source #

Represents an HTML color code.

A ColorCode consists of a red, a green and a blue element, each of which must have a value of between 0 and 255. This type cannot enforce this constraint, but see makeColorCode which does.

makeColorCode :: Integer -> Integer -> Integer -> ColorCode Source #

Construct a ColorCode value.

A ColorCode requires a red, a green and a blue value for construction. This function takes these as arguments and returns a constructed ColorCode.

This function checks that each element is within the required 0-255 range. Any element which is not is rounded to the nearest extrema (0 for negative values; 255 for values larger than that number).

type Url = Text Source #