module TD.Data.UserPrivacySetting
  (UserPrivacySetting(..)) where

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

-- | Describes available user privacy settings
data UserPrivacySetting
  = UserPrivacySettingShowStatus -- ^ A privacy setting for managing whether the user's online status is visible
  | UserPrivacySettingShowProfilePhoto -- ^ A privacy setting for managing whether the user's profile photo is visible
  | UserPrivacySettingShowLinkInForwardedMessages -- ^ A privacy setting for managing whether a link to the user's account is included in forwarded messages
  | UserPrivacySettingShowPhoneNumber -- ^ A privacy setting for managing whether the user's phone number is visible
  | UserPrivacySettingShowBio -- ^ A privacy setting for managing whether the user's bio is visible
  | UserPrivacySettingShowBirthdate -- ^ A privacy setting for managing whether the user's birthdate is visible
  | UserPrivacySettingAllowChatInvites -- ^ A privacy setting for managing whether the user can be invited to chats
  | UserPrivacySettingAllowCalls -- ^ A privacy setting for managing whether the user can be called
  | UserPrivacySettingAllowPeerToPeerCalls -- ^ A privacy setting for managing whether peer-to-peer connections can be used for calls
  | UserPrivacySettingAllowFindingByPhoneNumber -- ^ A privacy setting for managing whether the user can be found by their phone number. Checked only if the phone number is not known to the other user. Can be set only to "Allow contacts" or "Allow all"
  | UserPrivacySettingAllowPrivateVoiceAndVideoNoteMessages -- ^ A privacy setting for managing whether the user can receive voice and video messages in private chats; for Telegram Premium users only
  deriving (UserPrivacySetting -> UserPrivacySetting -> Bool
(UserPrivacySetting -> UserPrivacySetting -> Bool)
-> (UserPrivacySetting -> UserPrivacySetting -> Bool)
-> Eq UserPrivacySetting
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UserPrivacySetting -> UserPrivacySetting -> Bool
== :: UserPrivacySetting -> UserPrivacySetting -> Bool
$c/= :: UserPrivacySetting -> UserPrivacySetting -> Bool
/= :: UserPrivacySetting -> UserPrivacySetting -> Bool
Eq, Int -> UserPrivacySetting -> ShowS
[UserPrivacySetting] -> ShowS
UserPrivacySetting -> String
(Int -> UserPrivacySetting -> ShowS)
-> (UserPrivacySetting -> String)
-> ([UserPrivacySetting] -> ShowS)
-> Show UserPrivacySetting
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UserPrivacySetting -> ShowS
showsPrec :: Int -> UserPrivacySetting -> ShowS
$cshow :: UserPrivacySetting -> String
show :: UserPrivacySetting -> String
$cshowList :: [UserPrivacySetting] -> ShowS
showList :: [UserPrivacySetting] -> ShowS
Show)

instance I.ShortShow UserPrivacySetting where
  shortShow :: UserPrivacySetting -> String
shortShow UserPrivacySetting
UserPrivacySettingShowStatus
      = String
"UserPrivacySettingShowStatus"
  shortShow UserPrivacySetting
UserPrivacySettingShowProfilePhoto
      = String
"UserPrivacySettingShowProfilePhoto"
  shortShow UserPrivacySetting
UserPrivacySettingShowLinkInForwardedMessages
      = String
"UserPrivacySettingShowLinkInForwardedMessages"
  shortShow UserPrivacySetting
UserPrivacySettingShowPhoneNumber
      = String
"UserPrivacySettingShowPhoneNumber"
  shortShow UserPrivacySetting
UserPrivacySettingShowBio
      = String
"UserPrivacySettingShowBio"
  shortShow UserPrivacySetting
UserPrivacySettingShowBirthdate
      = String
"UserPrivacySettingShowBirthdate"
  shortShow UserPrivacySetting
UserPrivacySettingAllowChatInvites
      = String
"UserPrivacySettingAllowChatInvites"
  shortShow UserPrivacySetting
UserPrivacySettingAllowCalls
      = String
"UserPrivacySettingAllowCalls"
  shortShow UserPrivacySetting
UserPrivacySettingAllowPeerToPeerCalls
      = String
"UserPrivacySettingAllowPeerToPeerCalls"
  shortShow UserPrivacySetting
UserPrivacySettingAllowFindingByPhoneNumber
      = String
"UserPrivacySettingAllowFindingByPhoneNumber"
  shortShow UserPrivacySetting
UserPrivacySettingAllowPrivateVoiceAndVideoNoteMessages
      = String
"UserPrivacySettingAllowPrivateVoiceAndVideoNoteMessages"

instance AT.FromJSON UserPrivacySetting where
  parseJSON :: Value -> Parser UserPrivacySetting
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
"userPrivacySettingShowStatus"                            -> UserPrivacySetting -> Parser UserPrivacySetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UserPrivacySetting
UserPrivacySettingShowStatus
      String
"userPrivacySettingShowProfilePhoto"                      -> UserPrivacySetting -> Parser UserPrivacySetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UserPrivacySetting
UserPrivacySettingShowProfilePhoto
      String
"userPrivacySettingShowLinkInForwardedMessages"           -> UserPrivacySetting -> Parser UserPrivacySetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UserPrivacySetting
UserPrivacySettingShowLinkInForwardedMessages
      String
"userPrivacySettingShowPhoneNumber"                       -> UserPrivacySetting -> Parser UserPrivacySetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UserPrivacySetting
UserPrivacySettingShowPhoneNumber
      String
"userPrivacySettingShowBio"                               -> UserPrivacySetting -> Parser UserPrivacySetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UserPrivacySetting
UserPrivacySettingShowBio
      String
"userPrivacySettingShowBirthdate"                         -> UserPrivacySetting -> Parser UserPrivacySetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UserPrivacySetting
UserPrivacySettingShowBirthdate
      String
"userPrivacySettingAllowChatInvites"                      -> UserPrivacySetting -> Parser UserPrivacySetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UserPrivacySetting
UserPrivacySettingAllowChatInvites
      String
"userPrivacySettingAllowCalls"                            -> UserPrivacySetting -> Parser UserPrivacySetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UserPrivacySetting
UserPrivacySettingAllowCalls
      String
"userPrivacySettingAllowPeerToPeerCalls"                  -> UserPrivacySetting -> Parser UserPrivacySetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UserPrivacySetting
UserPrivacySettingAllowPeerToPeerCalls
      String
"userPrivacySettingAllowFindingByPhoneNumber"             -> UserPrivacySetting -> Parser UserPrivacySetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UserPrivacySetting
UserPrivacySettingAllowFindingByPhoneNumber
      String
"userPrivacySettingAllowPrivateVoiceAndVideoNoteMessages" -> UserPrivacySetting -> Parser UserPrivacySetting
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UserPrivacySetting
UserPrivacySettingAllowPrivateVoiceAndVideoNoteMessages
      String
_                                                         -> Parser UserPrivacySetting
forall a. Monoid a => a
mempty
    
  parseJSON Value
_ = Parser UserPrivacySetting
forall a. Monoid a => a
mempty

instance AT.ToJSON UserPrivacySetting where
  toJSON :: UserPrivacySetting -> Value
toJSON UserPrivacySetting
UserPrivacySettingShowStatus
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"userPrivacySettingShowStatus"
        ]
  toJSON UserPrivacySetting
UserPrivacySettingShowProfilePhoto
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"userPrivacySettingShowProfilePhoto"
        ]
  toJSON UserPrivacySetting
UserPrivacySettingShowLinkInForwardedMessages
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"userPrivacySettingShowLinkInForwardedMessages"
        ]
  toJSON UserPrivacySetting
UserPrivacySettingShowPhoneNumber
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"userPrivacySettingShowPhoneNumber"
        ]
  toJSON UserPrivacySetting
UserPrivacySettingShowBio
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"userPrivacySettingShowBio"
        ]
  toJSON UserPrivacySetting
UserPrivacySettingShowBirthdate
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"userPrivacySettingShowBirthdate"
        ]
  toJSON UserPrivacySetting
UserPrivacySettingAllowChatInvites
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"userPrivacySettingAllowChatInvites"
        ]
  toJSON UserPrivacySetting
UserPrivacySettingAllowCalls
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"userPrivacySettingAllowCalls"
        ]
  toJSON UserPrivacySetting
UserPrivacySettingAllowPeerToPeerCalls
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"userPrivacySettingAllowPeerToPeerCalls"
        ]
  toJSON UserPrivacySetting
UserPrivacySettingAllowFindingByPhoneNumber
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"userPrivacySettingAllowFindingByPhoneNumber"
        ]
  toJSON UserPrivacySetting
UserPrivacySettingAllowPrivateVoiceAndVideoNoteMessages
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"userPrivacySettingAllowPrivateVoiceAndVideoNoteMessages"
        ]