module TD.Data.UserPrivacySettingRule
(UserPrivacySettingRule(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data UserPrivacySettingRule
= UserPrivacySettingRuleAllowAll
| UserPrivacySettingRuleAllowContacts
| UserPrivacySettingRuleAllowBots
| UserPrivacySettingRuleAllowPremiumUsers
| UserPrivacySettingRuleAllowUsers
{ UserPrivacySettingRule -> Maybe [Int]
user_ids :: Maybe [Int]
}
| UserPrivacySettingRuleAllowChatMembers
{ UserPrivacySettingRule -> Maybe [Int]
chat_ids :: Maybe [Int]
}
| UserPrivacySettingRuleRestrictAll
| UserPrivacySettingRuleRestrictContacts
| UserPrivacySettingRuleRestrictBots
| UserPrivacySettingRuleRestrictUsers
{ user_ids :: Maybe [Int]
}
| UserPrivacySettingRuleRestrictChatMembers
{ chat_ids :: Maybe [Int]
}
deriving (UserPrivacySettingRule -> UserPrivacySettingRule -> Bool
(UserPrivacySettingRule -> UserPrivacySettingRule -> Bool)
-> (UserPrivacySettingRule -> UserPrivacySettingRule -> Bool)
-> Eq UserPrivacySettingRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UserPrivacySettingRule -> UserPrivacySettingRule -> Bool
== :: UserPrivacySettingRule -> UserPrivacySettingRule -> Bool
$c/= :: UserPrivacySettingRule -> UserPrivacySettingRule -> Bool
/= :: UserPrivacySettingRule -> UserPrivacySettingRule -> Bool
Eq, Int -> UserPrivacySettingRule -> ShowS
[UserPrivacySettingRule] -> ShowS
UserPrivacySettingRule -> String
(Int -> UserPrivacySettingRule -> ShowS)
-> (UserPrivacySettingRule -> String)
-> ([UserPrivacySettingRule] -> ShowS)
-> Show UserPrivacySettingRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UserPrivacySettingRule -> ShowS
showsPrec :: Int -> UserPrivacySettingRule -> ShowS
$cshow :: UserPrivacySettingRule -> String
show :: UserPrivacySettingRule -> String
$cshowList :: [UserPrivacySettingRule] -> ShowS
showList :: [UserPrivacySettingRule] -> ShowS
Show)
instance I.ShortShow UserPrivacySettingRule where
shortShow :: UserPrivacySettingRule -> String
shortShow UserPrivacySettingRule
UserPrivacySettingRuleAllowAll
= String
"UserPrivacySettingRuleAllowAll"
shortShow UserPrivacySettingRule
UserPrivacySettingRuleAllowContacts
= String
"UserPrivacySettingRuleAllowContacts"
shortShow UserPrivacySettingRule
UserPrivacySettingRuleAllowBots
= String
"UserPrivacySettingRuleAllowBots"
shortShow UserPrivacySettingRule
UserPrivacySettingRuleAllowPremiumUsers
= String
"UserPrivacySettingRuleAllowPremiumUsers"
shortShow UserPrivacySettingRuleAllowUsers
{ user_ids :: UserPrivacySettingRule -> Maybe [Int]
user_ids = Maybe [Int]
user_ids_
}
= String
"UserPrivacySettingRuleAllowUsers"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"user_ids" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
user_ids_
]
shortShow UserPrivacySettingRuleAllowChatMembers
{ chat_ids :: UserPrivacySettingRule -> Maybe [Int]
chat_ids = Maybe [Int]
chat_ids_
}
= String
"UserPrivacySettingRuleAllowChatMembers"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"chat_ids" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
chat_ids_
]
shortShow UserPrivacySettingRule
UserPrivacySettingRuleRestrictAll
= String
"UserPrivacySettingRuleRestrictAll"
shortShow UserPrivacySettingRule
UserPrivacySettingRuleRestrictContacts
= String
"UserPrivacySettingRuleRestrictContacts"
shortShow UserPrivacySettingRule
UserPrivacySettingRuleRestrictBots
= String
"UserPrivacySettingRuleRestrictBots"
shortShow UserPrivacySettingRuleRestrictUsers
{ user_ids :: UserPrivacySettingRule -> Maybe [Int]
user_ids = Maybe [Int]
user_ids_
}
= String
"UserPrivacySettingRuleRestrictUsers"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"user_ids" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
user_ids_
]
shortShow UserPrivacySettingRuleRestrictChatMembers
{ chat_ids :: UserPrivacySettingRule -> Maybe [Int]
chat_ids = Maybe [Int]
chat_ids_
}
= String
"UserPrivacySettingRuleRestrictChatMembers"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"chat_ids" String -> Maybe [Int] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Int]
chat_ids_
]
instance AT.FromJSON UserPrivacySettingRule where
parseJSON :: Value -> Parser UserPrivacySettingRule
parseJSON v :: Value
v@(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
"userPrivacySettingRuleAllowAll" -> UserPrivacySettingRule -> Parser UserPrivacySettingRule
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UserPrivacySettingRule
UserPrivacySettingRuleAllowAll
String
"userPrivacySettingRuleAllowContacts" -> UserPrivacySettingRule -> Parser UserPrivacySettingRule
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UserPrivacySettingRule
UserPrivacySettingRuleAllowContacts
String
"userPrivacySettingRuleAllowBots" -> UserPrivacySettingRule -> Parser UserPrivacySettingRule
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UserPrivacySettingRule
UserPrivacySettingRuleAllowBots
String
"userPrivacySettingRuleAllowPremiumUsers" -> UserPrivacySettingRule -> Parser UserPrivacySettingRule
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UserPrivacySettingRule
UserPrivacySettingRuleAllowPremiumUsers
String
"userPrivacySettingRuleAllowUsers" -> Value -> Parser UserPrivacySettingRule
parseUserPrivacySettingRuleAllowUsers Value
v
String
"userPrivacySettingRuleAllowChatMembers" -> Value -> Parser UserPrivacySettingRule
parseUserPrivacySettingRuleAllowChatMembers Value
v
String
"userPrivacySettingRuleRestrictAll" -> UserPrivacySettingRule -> Parser UserPrivacySettingRule
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UserPrivacySettingRule
UserPrivacySettingRuleRestrictAll
String
"userPrivacySettingRuleRestrictContacts" -> UserPrivacySettingRule -> Parser UserPrivacySettingRule
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UserPrivacySettingRule
UserPrivacySettingRuleRestrictContacts
String
"userPrivacySettingRuleRestrictBots" -> UserPrivacySettingRule -> Parser UserPrivacySettingRule
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UserPrivacySettingRule
UserPrivacySettingRuleRestrictBots
String
"userPrivacySettingRuleRestrictUsers" -> Value -> Parser UserPrivacySettingRule
parseUserPrivacySettingRuleRestrictUsers Value
v
String
"userPrivacySettingRuleRestrictChatMembers" -> Value -> Parser UserPrivacySettingRule
parseUserPrivacySettingRuleRestrictChatMembers Value
v
String
_ -> Parser UserPrivacySettingRule
forall a. Monoid a => a
mempty
where
parseUserPrivacySettingRuleAllowUsers :: A.Value -> AT.Parser UserPrivacySettingRule
parseUserPrivacySettingRuleAllowUsers :: Value -> Parser UserPrivacySettingRule
parseUserPrivacySettingRuleAllowUsers = String
-> (Object -> Parser UserPrivacySettingRule)
-> Value
-> Parser UserPrivacySettingRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"UserPrivacySettingRuleAllowUsers" ((Object -> Parser UserPrivacySettingRule)
-> Value -> Parser UserPrivacySettingRule)
-> (Object -> Parser UserPrivacySettingRule)
-> Value
-> Parser UserPrivacySettingRule
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe [Int]
user_ids_ <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"user_ids"
UserPrivacySettingRule -> Parser UserPrivacySettingRule
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (UserPrivacySettingRule -> Parser UserPrivacySettingRule)
-> UserPrivacySettingRule -> Parser UserPrivacySettingRule
forall a b. (a -> b) -> a -> b
$ UserPrivacySettingRuleAllowUsers
{ user_ids :: Maybe [Int]
user_ids = Maybe [Int]
user_ids_
}
parseUserPrivacySettingRuleAllowChatMembers :: A.Value -> AT.Parser UserPrivacySettingRule
parseUserPrivacySettingRuleAllowChatMembers :: Value -> Parser UserPrivacySettingRule
parseUserPrivacySettingRuleAllowChatMembers = String
-> (Object -> Parser UserPrivacySettingRule)
-> Value
-> Parser UserPrivacySettingRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"UserPrivacySettingRuleAllowChatMembers" ((Object -> Parser UserPrivacySettingRule)
-> Value -> Parser UserPrivacySettingRule)
-> (Object -> Parser UserPrivacySettingRule)
-> Value
-> Parser UserPrivacySettingRule
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe [Int]
chat_ids_ <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"chat_ids"
UserPrivacySettingRule -> Parser UserPrivacySettingRule
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (UserPrivacySettingRule -> Parser UserPrivacySettingRule)
-> UserPrivacySettingRule -> Parser UserPrivacySettingRule
forall a b. (a -> b) -> a -> b
$ UserPrivacySettingRuleAllowChatMembers
{ chat_ids :: Maybe [Int]
chat_ids = Maybe [Int]
chat_ids_
}
parseUserPrivacySettingRuleRestrictUsers :: A.Value -> AT.Parser UserPrivacySettingRule
parseUserPrivacySettingRuleRestrictUsers :: Value -> Parser UserPrivacySettingRule
parseUserPrivacySettingRuleRestrictUsers = String
-> (Object -> Parser UserPrivacySettingRule)
-> Value
-> Parser UserPrivacySettingRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"UserPrivacySettingRuleRestrictUsers" ((Object -> Parser UserPrivacySettingRule)
-> Value -> Parser UserPrivacySettingRule)
-> (Object -> Parser UserPrivacySettingRule)
-> Value
-> Parser UserPrivacySettingRule
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe [Int]
user_ids_ <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"user_ids"
UserPrivacySettingRule -> Parser UserPrivacySettingRule
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (UserPrivacySettingRule -> Parser UserPrivacySettingRule)
-> UserPrivacySettingRule -> Parser UserPrivacySettingRule
forall a b. (a -> b) -> a -> b
$ UserPrivacySettingRuleRestrictUsers
{ user_ids :: Maybe [Int]
user_ids = Maybe [Int]
user_ids_
}
parseUserPrivacySettingRuleRestrictChatMembers :: A.Value -> AT.Parser UserPrivacySettingRule
parseUserPrivacySettingRuleRestrictChatMembers :: Value -> Parser UserPrivacySettingRule
parseUserPrivacySettingRuleRestrictChatMembers = String
-> (Object -> Parser UserPrivacySettingRule)
-> Value
-> Parser UserPrivacySettingRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"UserPrivacySettingRuleRestrictChatMembers" ((Object -> Parser UserPrivacySettingRule)
-> Value -> Parser UserPrivacySettingRule)
-> (Object -> Parser UserPrivacySettingRule)
-> Value
-> Parser UserPrivacySettingRule
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe [Int]
chat_ids_ <- Object
o Object -> Key -> Parser (Maybe [Int])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"chat_ids"
UserPrivacySettingRule -> Parser UserPrivacySettingRule
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (UserPrivacySettingRule -> Parser UserPrivacySettingRule)
-> UserPrivacySettingRule -> Parser UserPrivacySettingRule
forall a b. (a -> b) -> a -> b
$ UserPrivacySettingRuleRestrictChatMembers
{ chat_ids :: Maybe [Int]
chat_ids = Maybe [Int]
chat_ids_
}
parseJSON Value
_ = Parser UserPrivacySettingRule
forall a. Monoid a => a
mempty
instance AT.ToJSON UserPrivacySettingRule where
toJSON :: UserPrivacySettingRule -> Value
toJSON UserPrivacySettingRule
UserPrivacySettingRuleAllowAll
= [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
"userPrivacySettingRuleAllowAll"
]
toJSON UserPrivacySettingRule
UserPrivacySettingRuleAllowContacts
= [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
"userPrivacySettingRuleAllowContacts"
]
toJSON UserPrivacySettingRule
UserPrivacySettingRuleAllowBots
= [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
"userPrivacySettingRuleAllowBots"
]
toJSON UserPrivacySettingRule
UserPrivacySettingRuleAllowPremiumUsers
= [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
"userPrivacySettingRuleAllowPremiumUsers"
]
toJSON UserPrivacySettingRuleAllowUsers
{ user_ids :: UserPrivacySettingRule -> Maybe [Int]
user_ids = Maybe [Int]
user_ids_
}
= [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
"userPrivacySettingRuleAllowUsers"
, Key
"user_ids" Key -> Maybe [Int] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [Int]
user_ids_
]
toJSON UserPrivacySettingRuleAllowChatMembers
{ chat_ids :: UserPrivacySettingRule -> Maybe [Int]
chat_ids = Maybe [Int]
chat_ids_
}
= [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
"userPrivacySettingRuleAllowChatMembers"
, Key
"chat_ids" Key -> Maybe [Int] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [Int]
chat_ids_
]
toJSON UserPrivacySettingRule
UserPrivacySettingRuleRestrictAll
= [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
"userPrivacySettingRuleRestrictAll"
]
toJSON UserPrivacySettingRule
UserPrivacySettingRuleRestrictContacts
= [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
"userPrivacySettingRuleRestrictContacts"
]
toJSON UserPrivacySettingRule
UserPrivacySettingRuleRestrictBots
= [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
"userPrivacySettingRuleRestrictBots"
]
toJSON UserPrivacySettingRuleRestrictUsers
{ user_ids :: UserPrivacySettingRule -> Maybe [Int]
user_ids = Maybe [Int]
user_ids_
}
= [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
"userPrivacySettingRuleRestrictUsers"
, Key
"user_ids" Key -> Maybe [Int] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [Int]
user_ids_
]
toJSON UserPrivacySettingRuleRestrictChatMembers
{ chat_ids :: UserPrivacySettingRule -> Maybe [Int]
chat_ids = Maybe [Int]
chat_ids_
}
= [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
"userPrivacySettingRuleRestrictChatMembers"
, Key
"chat_ids" Key -> Maybe [Int] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [Int]
chat_ids_
]