module Network.Pushbullet.Types(
Title
, Body
, FileName
, FileType
, FileUrl
, DeviceId(..)
, PushBullet(..)
, pushSecret
) where
import Control.Applicative
import Control.Monad
import Data.Aeson
import Data.ByteString
import Data.String
import Data.Text
import Network.Pushbullet.Internal
import Network.Wreq
newtype DeviceId = DeviceId {
unDeviceId :: Text
} deriving (Eq, Show, IsString)
type Title = Text
type Body = Text
type FileName = Text
type FileType = Text
type FileUrl = Text
data PushBullet =
PushNote Title Body
| PushLink Title Body Text
| PushFile Body FileName FileType FileUrl
instance ToJSON PushBullet where
toJSON (PushNote title body) =
object [
"type" .= ("note" :: Text)
, "title" .= title, "body" .= body
]
toJSON (PushLink title body url) =
object [
"type" .= ("link" :: Text)
, "title" .= title
, "body" .= body
, "url" .= url
]
toJSON (PushFile body fileName fileType fileUrl) =
object [
"type" .= ("file" :: Text)
, "body" .= body
, "file_name" .= fileName
, "file_type" .= fileType
, "file_url" .= fileUrl
]
pushSecret :: ByteString
-> PushSecret
pushSecret = PushSecret . oauth2Bearer