module TD.Data.SessionType
  (SessionType(..)) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I

-- | Represents the type of session
data SessionType
  = SessionTypeAndroid -- ^ The session is running on an Android device
  | SessionTypeApple -- ^ The session is running on a generic Apple device
  | SessionTypeBrave -- ^ The session is running on the Brave browser
  | SessionTypeChrome -- ^ The session is running on the Chrome browser
  | SessionTypeEdge -- ^ The session is running on the Edge browser
  | SessionTypeFirefox -- ^ The session is running on the Firefox browser
  | SessionTypeIpad -- ^ The session is running on an iPad device
  | SessionTypeIphone -- ^ The session is running on an iPhone device
  | SessionTypeLinux -- ^ The session is running on a Linux device
  | SessionTypeMac -- ^ The session is running on a Mac device
  | SessionTypeOpera -- ^ The session is running on the Opera browser
  | SessionTypeSafari -- ^ The session is running on the Safari browser
  | SessionTypeUbuntu -- ^ The session is running on an Ubuntu device
  | SessionTypeUnknown -- ^ The session is running on an unknown type of device
  | SessionTypeVivaldi -- ^ The session is running on the Vivaldi browser
  | SessionTypeWindows -- ^ The session is running on a Windows device
  | SessionTypeXbox -- ^ The session is running on an Xbox console
  deriving (SessionType -> SessionType -> Bool
(SessionType -> SessionType -> Bool)
-> (SessionType -> SessionType -> Bool) -> Eq SessionType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SessionType -> SessionType -> Bool
== :: SessionType -> SessionType -> Bool
$c/= :: SessionType -> SessionType -> Bool
/= :: SessionType -> SessionType -> Bool
Eq, Int -> SessionType -> ShowS
[SessionType] -> ShowS
SessionType -> String
(Int -> SessionType -> ShowS)
-> (SessionType -> String)
-> ([SessionType] -> ShowS)
-> Show SessionType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SessionType -> ShowS
showsPrec :: Int -> SessionType -> ShowS
$cshow :: SessionType -> String
show :: SessionType -> String
$cshowList :: [SessionType] -> ShowS
showList :: [SessionType] -> ShowS
Show)

instance I.ShortShow SessionType where
  shortShow :: SessionType -> String
shortShow SessionType
SessionTypeAndroid
      = String
"SessionTypeAndroid"
  shortShow SessionType
SessionTypeApple
      = String
"SessionTypeApple"
  shortShow SessionType
SessionTypeBrave
      = String
"SessionTypeBrave"
  shortShow SessionType
SessionTypeChrome
      = String
"SessionTypeChrome"
  shortShow SessionType
SessionTypeEdge
      = String
"SessionTypeEdge"
  shortShow SessionType
SessionTypeFirefox
      = String
"SessionTypeFirefox"
  shortShow SessionType
SessionTypeIpad
      = String
"SessionTypeIpad"
  shortShow SessionType
SessionTypeIphone
      = String
"SessionTypeIphone"
  shortShow SessionType
SessionTypeLinux
      = String
"SessionTypeLinux"
  shortShow SessionType
SessionTypeMac
      = String
"SessionTypeMac"
  shortShow SessionType
SessionTypeOpera
      = String
"SessionTypeOpera"
  shortShow SessionType
SessionTypeSafari
      = String
"SessionTypeSafari"
  shortShow SessionType
SessionTypeUbuntu
      = String
"SessionTypeUbuntu"
  shortShow SessionType
SessionTypeUnknown
      = String
"SessionTypeUnknown"
  shortShow SessionType
SessionTypeVivaldi
      = String
"SessionTypeVivaldi"
  shortShow SessionType
SessionTypeWindows
      = String
"SessionTypeWindows"
  shortShow SessionType
SessionTypeXbox
      = String
"SessionTypeXbox"

instance AT.FromJSON SessionType where
  parseJSON :: Value -> Parser SessionType
parseJSON (AT.Object Object
obj) = do
    String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String

    case String
t of
      String
"sessionTypeAndroid" -> SessionType -> Parser SessionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SessionType
SessionTypeAndroid
      String
"sessionTypeApple"   -> SessionType -> Parser SessionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SessionType
SessionTypeApple
      String
"sessionTypeBrave"   -> SessionType -> Parser SessionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SessionType
SessionTypeBrave
      String
"sessionTypeChrome"  -> SessionType -> Parser SessionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SessionType
SessionTypeChrome
      String
"sessionTypeEdge"    -> SessionType -> Parser SessionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SessionType
SessionTypeEdge
      String
"sessionTypeFirefox" -> SessionType -> Parser SessionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SessionType
SessionTypeFirefox
      String
"sessionTypeIpad"    -> SessionType -> Parser SessionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SessionType
SessionTypeIpad
      String
"sessionTypeIphone"  -> SessionType -> Parser SessionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SessionType
SessionTypeIphone
      String
"sessionTypeLinux"   -> SessionType -> Parser SessionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SessionType
SessionTypeLinux
      String
"sessionTypeMac"     -> SessionType -> Parser SessionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SessionType
SessionTypeMac
      String
"sessionTypeOpera"   -> SessionType -> Parser SessionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SessionType
SessionTypeOpera
      String
"sessionTypeSafari"  -> SessionType -> Parser SessionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SessionType
SessionTypeSafari
      String
"sessionTypeUbuntu"  -> SessionType -> Parser SessionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SessionType
SessionTypeUbuntu
      String
"sessionTypeUnknown" -> SessionType -> Parser SessionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SessionType
SessionTypeUnknown
      String
"sessionTypeVivaldi" -> SessionType -> Parser SessionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SessionType
SessionTypeVivaldi
      String
"sessionTypeWindows" -> SessionType -> Parser SessionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SessionType
SessionTypeWindows
      String
"sessionTypeXbox"    -> SessionType -> Parser SessionType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SessionType
SessionTypeXbox
      String
_                    -> Parser SessionType
forall a. Monoid a => a
mempty
    
  parseJSON Value
_ = Parser SessionType
forall a. Monoid a => a
mempty