pushover-0.1.0.1: A Haskell Pushover API library

Safe HaskellNone
LanguageHaskell2010

Network.Pushover.Token

Contents

Description

This module contains functionality and types concerning tokens used to authenticate and direct communications with the Pushover API.

The API requires that an API token be sent with every request for authentication purposes, and a user key be sent with every request for the purpose of identifying the recipient of the message. Both types of token/key are of the same format, and the makeToken functions work for constructing both types of token/key.

Synopsis

Token type

data PushoverToken Source #

Define a type to represent the different types of token or key Pushover requires.

Pushover requires API token and user keys to be send with requests. This is intended to represent these tokens. It is intended that the makeToken function is used to construct validated tokens.

Aliases

type UserKey = PushoverToken Source #

User key for the user receiving a notification.

Constructing a token

makeToken :: Text -> Either PushoverException PushoverToken Source #

Construct a PushoverToken value.

A PushoverToken consists of exactly 30 alphanumeric characters (both uppercase and lowercase). The input key text is validated to ensure it is the correct length and contains valid characters.

A descriptive error is returned where validation fails.

makeTokenM :: (Error e, MonadError e m) => Text -> m PushoverToken Source #

Construct a PushoverToken value.

This is similar to the makeToken function, except that it is generalised over the MonadError monad.

makeTokenOrError :: Text -> PushoverToken Source #

Construct a PushoverToken value.

This is a version of makeToken in which an invalid token will raise an error. It should generally not be used, with makeToken the preferred means to create a token.

Encoding for use in HTTP request

encodeToken :: PushoverToken -> ByteString Source #

Encode a PushoverToken into a bytestring for sending within an HTTP request.