module LaunchDarkly.Server.User
( User
, makeUser
, userSetKey
, userSetSecondary
, userSetIP
, userSetCountry
, userSetEmail
, userSetFirstName
, userSetLastName
, userSetAvatar
, userSetName
, userSetAnonymous
, userSetCustom
, userSetPrivateAttributeNames
) where
import Data.Aeson (Value)
import Data.Generics.Product (setField)
import Data.HashMap.Strict (HashMap)
import Data.Set (Set)
import Data.Text (Text)
import LaunchDarkly.Server.User.Internal (User(..), mapUser, UserI(..))
makeUser :: Text -> User
makeUser key = User $ UserI
{ key = pure key
, secondary = mempty
, ip = mempty
, country = mempty
, email = mempty
, firstName = mempty
, lastName = mempty
, avatar = mempty
, name = mempty
, anonymous = False
, custom = mempty
, privateAttributeNames = mempty
}
userSetKey :: (Maybe Text) -> User -> User
userSetKey = mapUser . setField @"key"
userSetSecondary :: Maybe Text -> User -> User
userSetSecondary = mapUser . setField @"secondary"
userSetIP :: Maybe Text -> User -> User
userSetIP = mapUser . setField @"ip"
userSetCountry :: Maybe Text -> User -> User
userSetCountry = mapUser . setField @"country"
userSetEmail :: Maybe Text -> User -> User
userSetEmail = mapUser . setField @"email"
userSetFirstName :: Maybe Text -> User -> User
userSetFirstName = mapUser . setField @"firstName"
userSetLastName :: Maybe Text -> User -> User
userSetLastName = mapUser . setField @"lastName"
userSetAvatar :: Maybe Text -> User -> User
userSetAvatar = mapUser . setField @"avatar"
userSetName :: Maybe Text -> User -> User
userSetName = mapUser . setField @"name"
userSetAnonymous :: Bool -> User -> User
userSetAnonymous = mapUser . setField @"anonymous"
userSetCustom :: HashMap Text Value -> User -> User
userSetCustom = mapUser . setField @"custom"
userSetPrivateAttributeNames :: Set Text -> User -> User
userSetPrivateAttributeNames = mapUser . setField @"privateAttributeNames"