module Patrol.Type.DeviceContext where

import qualified Data.Aeson as Aeson
import qualified Data.Text as Text
import qualified Data.Time as Time
import qualified Patrol.Extra.Aeson as Aeson

-- | <https://develop.sentry.dev/sdk/event-payloads/types/#devicecontext>
data DeviceContext = DeviceContext
  { DeviceContext -> Text
arch :: Text.Text,
    DeviceContext -> Maybe Double
batteryLevel :: Maybe Double,
    DeviceContext -> Text
batteryStatus :: Text.Text,
    DeviceContext -> Maybe UTCTime
bootTime :: Maybe Time.UTCTime,
    DeviceContext -> Text
brand :: Text.Text,
    DeviceContext -> Maybe Bool
charging :: Maybe Bool,
    DeviceContext -> Text
cpuDescription :: Text.Text,
    DeviceContext -> Text
deviceType :: Text.Text,
    DeviceContext -> Text
deviceUniqueIdentifier :: Text.Text,
    DeviceContext -> Maybe Int
externalFreeStorage :: Maybe Int,
    DeviceContext -> Maybe Int
externalStorageSize :: Maybe Int,
    DeviceContext -> Text
family :: Text.Text,
    DeviceContext -> Maybe Int
freeMemory :: Maybe Int,
    DeviceContext -> Maybe Int
freeStorage :: Maybe Int,
    DeviceContext -> Maybe Bool
lowMemory :: Maybe Bool,
    DeviceContext -> Text
manufacturer :: Text.Text,
    DeviceContext -> Maybe Int
memorySize :: Maybe Int,
    DeviceContext -> Text
model :: Text.Text,
    DeviceContext -> Text
modelId :: Text.Text,
    DeviceContext -> Text
name :: Text.Text,
    DeviceContext -> Maybe Bool
online :: Maybe Bool,
    DeviceContext -> Text
orientation :: Text.Text,
    DeviceContext -> Maybe Int
processorCount :: Maybe Int,
    DeviceContext -> Maybe Double
processorFrequency :: Maybe Double,
    DeviceContext -> Maybe Double
screenDensity :: Maybe Double,
    DeviceContext -> Maybe Double
screenDpi :: Maybe Double,
    DeviceContext -> Text
screenResolution :: Text.Text,
    DeviceContext -> Maybe Bool
simulator :: Maybe Bool,
    DeviceContext -> Maybe Int
storageSize :: Maybe Int,
    DeviceContext -> Maybe Bool
supportsAccelerometer :: Maybe Bool,
    DeviceContext -> Maybe Bool
supportsAudio :: Maybe Bool,
    DeviceContext -> Maybe Bool
supportsGyroscope :: Maybe Bool,
    DeviceContext -> Maybe Bool
supportsLocationService :: Maybe Bool,
    DeviceContext -> Maybe Bool
supportsVibration :: Maybe Bool,
    DeviceContext -> Text
timezone :: Text.Text,
    DeviceContext -> Maybe Int
usableMemory :: Maybe Int
  }
  deriving (DeviceContext -> DeviceContext -> Bool
(DeviceContext -> DeviceContext -> Bool)
-> (DeviceContext -> DeviceContext -> Bool) -> Eq DeviceContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DeviceContext -> DeviceContext -> Bool
== :: DeviceContext -> DeviceContext -> Bool
$c/= :: DeviceContext -> DeviceContext -> Bool
/= :: DeviceContext -> DeviceContext -> Bool
Eq, Int -> DeviceContext -> ShowS
[DeviceContext] -> ShowS
DeviceContext -> String
(Int -> DeviceContext -> ShowS)
-> (DeviceContext -> String)
-> ([DeviceContext] -> ShowS)
-> Show DeviceContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DeviceContext -> ShowS
showsPrec :: Int -> DeviceContext -> ShowS
$cshow :: DeviceContext -> String
show :: DeviceContext -> String
$cshowList :: [DeviceContext] -> ShowS
showList :: [DeviceContext] -> ShowS
Show)

instance Aeson.ToJSON DeviceContext where
  toJSON :: DeviceContext -> Value
toJSON DeviceContext
deviceContext =
    [Pair] -> Value
Aeson.intoObject
      [ String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"arch" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Text
arch DeviceContext
deviceContext,
        String -> Maybe Double -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"battery_level" (Maybe Double -> Pair) -> Maybe Double -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Double
batteryLevel DeviceContext
deviceContext,
        String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"battery_status" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Text
batteryStatus DeviceContext
deviceContext,
        String -> Maybe UTCTime -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"boot_time" (Maybe UTCTime -> Pair) -> Maybe UTCTime -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe UTCTime
bootTime DeviceContext
deviceContext,
        String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"brand" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Text
brand DeviceContext
deviceContext,
        String -> Maybe Bool -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"charging" (Maybe Bool -> Pair) -> Maybe Bool -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Bool
charging DeviceContext
deviceContext,
        String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"cpu_description" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Text
cpuDescription DeviceContext
deviceContext,
        String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"device_type" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Text
deviceType DeviceContext
deviceContext,
        String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"device_unique_identifier" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Text
deviceUniqueIdentifier DeviceContext
deviceContext,
        String -> Maybe Int -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"external_free_storage" (Maybe Int -> Pair) -> Maybe Int -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Int
externalFreeStorage DeviceContext
deviceContext,
        String -> Maybe Int -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"external_storage_size" (Maybe Int -> Pair) -> Maybe Int -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Int
externalStorageSize DeviceContext
deviceContext,
        String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"family" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Text
family DeviceContext
deviceContext,
        String -> Maybe Int -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"free_memory" (Maybe Int -> Pair) -> Maybe Int -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Int
freeMemory DeviceContext
deviceContext,
        String -> Maybe Int -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"free_storage" (Maybe Int -> Pair) -> Maybe Int -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Int
freeStorage DeviceContext
deviceContext,
        String -> Maybe Bool -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"low_memory" (Maybe Bool -> Pair) -> Maybe Bool -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Bool
lowMemory DeviceContext
deviceContext,
        String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"manufacturer" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Text
manufacturer DeviceContext
deviceContext,
        String -> Maybe Int -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"memory_size" (Maybe Int -> Pair) -> Maybe Int -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Int
memorySize DeviceContext
deviceContext,
        String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"model" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Text
model DeviceContext
deviceContext,
        String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"model_id" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Text
modelId DeviceContext
deviceContext,
        String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"name" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Text
name DeviceContext
deviceContext,
        String -> Maybe Bool -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"online" (Maybe Bool -> Pair) -> Maybe Bool -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Bool
online DeviceContext
deviceContext,
        String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"orientation" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Text
orientation DeviceContext
deviceContext,
        String -> Maybe Int -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"processor_count" (Maybe Int -> Pair) -> Maybe Int -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Int
processorCount DeviceContext
deviceContext,
        String -> Maybe Double -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"processor_frequency" (Maybe Double -> Pair) -> Maybe Double -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Double
processorFrequency DeviceContext
deviceContext,
        String -> Maybe Double -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"screen_density" (Maybe Double -> Pair) -> Maybe Double -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Double
screenDensity DeviceContext
deviceContext,
        String -> Maybe Double -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"screen_dpi" (Maybe Double -> Pair) -> Maybe Double -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Double
screenDpi DeviceContext
deviceContext,
        String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"screen_resolution" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Text
screenResolution DeviceContext
deviceContext,
        String -> Maybe Bool -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"simulator" (Maybe Bool -> Pair) -> Maybe Bool -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Bool
simulator DeviceContext
deviceContext,
        String -> Maybe Int -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"storage_size" (Maybe Int -> Pair) -> Maybe Int -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Int
storageSize DeviceContext
deviceContext,
        String -> Maybe Bool -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"supports_accelerometer" (Maybe Bool -> Pair) -> Maybe Bool -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Bool
supportsAccelerometer DeviceContext
deviceContext,
        String -> Maybe Bool -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"supports_audio" (Maybe Bool -> Pair) -> Maybe Bool -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Bool
supportsAudio DeviceContext
deviceContext,
        String -> Maybe Bool -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"supports_gyroscope" (Maybe Bool -> Pair) -> Maybe Bool -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Bool
supportsGyroscope DeviceContext
deviceContext,
        String -> Maybe Bool -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"supports_location_service" (Maybe Bool -> Pair) -> Maybe Bool -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Bool
supportsLocationService DeviceContext
deviceContext,
        String -> Maybe Bool -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"supports_vibration" (Maybe Bool -> Pair) -> Maybe Bool -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Bool
supportsVibration DeviceContext
deviceContext,
        String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"timezone" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Text
timezone DeviceContext
deviceContext,
        String -> Maybe Int -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"usable_memory" (Maybe Int -> Pair) -> Maybe Int -> Pair
forall a b. (a -> b) -> a -> b
$ DeviceContext -> Maybe Int
usableMemory DeviceContext
deviceContext
      ]

empty :: DeviceContext
empty :: DeviceContext
empty =
  DeviceContext
    { arch :: Text
arch = Text
Text.empty,
      batteryLevel :: Maybe Double
batteryLevel = Maybe Double
forall a. Maybe a
Nothing,
      batteryStatus :: Text
batteryStatus = Text
Text.empty,
      bootTime :: Maybe UTCTime
bootTime = Maybe UTCTime
forall a. Maybe a
Nothing,
      brand :: Text
brand = Text
Text.empty,
      charging :: Maybe Bool
charging = Maybe Bool
forall a. Maybe a
Nothing,
      cpuDescription :: Text
cpuDescription = Text
Text.empty,
      deviceType :: Text
deviceType = Text
Text.empty,
      deviceUniqueIdentifier :: Text
deviceUniqueIdentifier = Text
Text.empty,
      externalFreeStorage :: Maybe Int
externalFreeStorage = Maybe Int
forall a. Maybe a
Nothing,
      externalStorageSize :: Maybe Int
externalStorageSize = Maybe Int
forall a. Maybe a
Nothing,
      family :: Text
family = Text
Text.empty,
      freeMemory :: Maybe Int
freeMemory = Maybe Int
forall a. Maybe a
Nothing,
      freeStorage :: Maybe Int
freeStorage = Maybe Int
forall a. Maybe a
Nothing,
      lowMemory :: Maybe Bool
lowMemory = Maybe Bool
forall a. Maybe a
Nothing,
      manufacturer :: Text
manufacturer = Text
Text.empty,
      memorySize :: Maybe Int
memorySize = Maybe Int
forall a. Maybe a
Nothing,
      model :: Text
model = Text
Text.empty,
      modelId :: Text
modelId = Text
Text.empty,
      name :: Text
name = Text
Text.empty,
      online :: Maybe Bool
online = Maybe Bool
forall a. Maybe a
Nothing,
      orientation :: Text
orientation = Text
Text.empty,
      processorCount :: Maybe Int
processorCount = Maybe Int
forall a. Maybe a
Nothing,
      processorFrequency :: Maybe Double
processorFrequency = Maybe Double
forall a. Maybe a
Nothing,
      screenDensity :: Maybe Double
screenDensity = Maybe Double
forall a. Maybe a
Nothing,
      screenDpi :: Maybe Double
screenDpi = Maybe Double
forall a. Maybe a
Nothing,
      screenResolution :: Text
screenResolution = Text
Text.empty,
      simulator :: Maybe Bool
simulator = Maybe Bool
forall a. Maybe a
Nothing,
      storageSize :: Maybe Int
storageSize = Maybe Int
forall a. Maybe a
Nothing,
      supportsAccelerometer :: Maybe Bool
supportsAccelerometer = Maybe Bool
forall a. Maybe a
Nothing,
      supportsAudio :: Maybe Bool
supportsAudio = Maybe Bool
forall a. Maybe a
Nothing,
      supportsGyroscope :: Maybe Bool
supportsGyroscope = Maybe Bool
forall a. Maybe a
Nothing,
      supportsLocationService :: Maybe Bool
supportsLocationService = Maybe Bool
forall a. Maybe a
Nothing,
      supportsVibration :: Maybe Bool
supportsVibration = Maybe Bool
forall a. Maybe a
Nothing,
      timezone :: Text
timezone = Text
Text.empty,
      usableMemory :: Maybe Int
usableMemory = Maybe Int
forall a. Maybe a
Nothing
    }