{-# LANGUAGE DeriveGeneric #-}
module Rollbar.Item.Level
    ( Level(..)
    ) where
import Data.Aeson
    ( FromJSON
    , ToJSON
    , defaultOptions
    , genericParseJSON
    , genericToEncoding
    , genericToJSON
    , parseJSON
    , toEncoding
    , toJSON
    )
import Data.Aeson.Types (Options, constructorTagModifier)
import Data.Char        (toLower)
import GHC.Generics (Generic)
data Level
    = Debug
    | Info
    | Warning
    | Error
    | Critical
    deriving (Bounded, Enum, Eq, Generic, Ord, Show)
instance FromJSON Level where
    parseJSON = genericParseJSON options
instance ToJSON Level where
    toJSON = genericToJSON options
    toEncoding = genericToEncoding options
options :: Options
options = defaultOptions
    { constructorTagModifier = fmap toLower
    }