module Patrol.Type.User where

import qualified Data.Aeson as Aeson
import qualified Data.Map as Map
import qualified Data.Text as Text
import qualified Patrol.Extra.Aeson as Aeson
import qualified Patrol.Type.Geo as Geo

-- | <https://develop.sentry.dev/sdk/event-payloads/types/#user>
data User = User
  { User -> Map Text Value
data_ :: Map.Map Text.Text Aeson.Value,
    User -> Text
email :: Text.Text,
    User -> Maybe Geo
geo :: Maybe Geo.Geo,
    User -> Text
id :: Text.Text,
    User -> Text
ipAddress :: Text.Text,
    User -> Text
name :: Text.Text,
    User -> Text
segment :: Text.Text,
    User -> Text
username :: Text.Text
  }
  deriving (User -> User -> Bool
(User -> User -> Bool) -> (User -> User -> Bool) -> Eq User
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: User -> User -> Bool
== :: User -> User -> Bool
$c/= :: User -> User -> Bool
/= :: User -> User -> Bool
Eq, Int -> User -> ShowS
[User] -> ShowS
User -> String
(Int -> User -> ShowS)
-> (User -> String) -> ([User] -> ShowS) -> Show User
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> User -> ShowS
showsPrec :: Int -> User -> ShowS
$cshow :: User -> String
show :: User -> String
$cshowList :: [User] -> ShowS
showList :: [User] -> ShowS
Show)

instance Aeson.ToJSON User where
  toJSON :: User -> Value
toJSON User
user =
    [Pair] -> Value
Aeson.intoObject
      [ String -> Map Text Value -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"data" (Map Text Value -> Pair) -> Map Text Value -> Pair
forall a b. (a -> b) -> a -> b
$ User -> Map Text Value
data_ User
user,
        String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"email" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ User -> Text
email User
user,
        String -> Maybe Geo -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"geo" (Maybe Geo -> Pair) -> Maybe Geo -> Pair
forall a b. (a -> b) -> a -> b
$ User -> Maybe Geo
geo User
user,
        String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"id" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ User -> Text
Patrol.Type.User.id User
user,
        String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"ip_address" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ User -> Text
ipAddress User
user,
        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
$ User -> Text
name User
user,
        String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"segment" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ User -> Text
segment User
user,
        String -> Text -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"username" (Text -> Pair) -> Text -> Pair
forall a b. (a -> b) -> a -> b
$ User -> Text
username User
user
      ]

empty :: User
empty :: User
empty =
  User
    { data_ :: Map Text Value
data_ = Map Text Value
forall k a. Map k a
Map.empty,
      email :: Text
email = Text
Text.empty,
      geo :: Maybe Geo
geo = Maybe Geo
forall a. Maybe a
Nothing,
      id :: Text
Patrol.Type.User.id = Text
Text.empty,
      ipAddress :: Text
ipAddress = Text
Text.empty,
      name :: Text
name = Text
Text.empty,
      segment :: Text
segment = Text
Text.empty,
      username :: Text
username = Text
Text.empty
    }