module TD.Data.SuggestedAction
(SuggestedAction(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified Data.Text as T
data SuggestedAction
= SuggestedActionEnableArchiveAndMuteNewChats
| SuggestedActionCheckPassword
| SuggestedActionCheckPhoneNumber
| SuggestedActionViewChecksHint
| SuggestedActionConvertToBroadcastGroup
{ SuggestedAction -> Maybe Int
supergroup_id :: Maybe Int
}
| SuggestedActionSetPassword
{ SuggestedAction -> Maybe Int
authorization_delay :: Maybe Int
}
| SuggestedActionUpgradePremium
| SuggestedActionRestorePremium
| SuggestedActionSubscribeToAnnualPremium
| SuggestedActionGiftPremiumForChristmas
| SuggestedActionSetBirthdate
| SuggestedActionSetProfilePhoto
| SuggestedActionExtendPremium
{ SuggestedAction -> Maybe Text
manage_premium_subscription_url :: Maybe T.Text
}
| SuggestedActionExtendStarSubscriptions
deriving (SuggestedAction -> SuggestedAction -> Bool
(SuggestedAction -> SuggestedAction -> Bool)
-> (SuggestedAction -> SuggestedAction -> Bool)
-> Eq SuggestedAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SuggestedAction -> SuggestedAction -> Bool
== :: SuggestedAction -> SuggestedAction -> Bool
$c/= :: SuggestedAction -> SuggestedAction -> Bool
/= :: SuggestedAction -> SuggestedAction -> Bool
Eq, Int -> SuggestedAction -> ShowS
[SuggestedAction] -> ShowS
SuggestedAction -> String
(Int -> SuggestedAction -> ShowS)
-> (SuggestedAction -> String)
-> ([SuggestedAction] -> ShowS)
-> Show SuggestedAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SuggestedAction -> ShowS
showsPrec :: Int -> SuggestedAction -> ShowS
$cshow :: SuggestedAction -> String
show :: SuggestedAction -> String
$cshowList :: [SuggestedAction] -> ShowS
showList :: [SuggestedAction] -> ShowS
Show)
instance I.ShortShow SuggestedAction where
shortShow :: SuggestedAction -> String
shortShow SuggestedAction
SuggestedActionEnableArchiveAndMuteNewChats
= String
"SuggestedActionEnableArchiveAndMuteNewChats"
shortShow SuggestedAction
SuggestedActionCheckPassword
= String
"SuggestedActionCheckPassword"
shortShow SuggestedAction
SuggestedActionCheckPhoneNumber
= String
"SuggestedActionCheckPhoneNumber"
shortShow SuggestedAction
SuggestedActionViewChecksHint
= String
"SuggestedActionViewChecksHint"
shortShow SuggestedActionConvertToBroadcastGroup
{ supergroup_id :: SuggestedAction -> Maybe Int
supergroup_id = Maybe Int
supergroup_id_
}
= String
"SuggestedActionConvertToBroadcastGroup"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"supergroup_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
supergroup_id_
]
shortShow SuggestedActionSetPassword
{ authorization_delay :: SuggestedAction -> Maybe Int
authorization_delay = Maybe Int
authorization_delay_
}
= String
"SuggestedActionSetPassword"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"authorization_delay" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
authorization_delay_
]
shortShow SuggestedAction
SuggestedActionUpgradePremium
= String
"SuggestedActionUpgradePremium"
shortShow SuggestedAction
SuggestedActionRestorePremium
= String
"SuggestedActionRestorePremium"
shortShow SuggestedAction
SuggestedActionSubscribeToAnnualPremium
= String
"SuggestedActionSubscribeToAnnualPremium"
shortShow SuggestedAction
SuggestedActionGiftPremiumForChristmas
= String
"SuggestedActionGiftPremiumForChristmas"
shortShow SuggestedAction
SuggestedActionSetBirthdate
= String
"SuggestedActionSetBirthdate"
shortShow SuggestedAction
SuggestedActionSetProfilePhoto
= String
"SuggestedActionSetProfilePhoto"
shortShow SuggestedActionExtendPremium
{ manage_premium_subscription_url :: SuggestedAction -> Maybe Text
manage_premium_subscription_url = Maybe Text
manage_premium_subscription_url_
}
= String
"SuggestedActionExtendPremium"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"manage_premium_subscription_url" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
manage_premium_subscription_url_
]
shortShow SuggestedAction
SuggestedActionExtendStarSubscriptions
= String
"SuggestedActionExtendStarSubscriptions"
instance AT.FromJSON SuggestedAction where
parseJSON :: Value -> Parser SuggestedAction
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
"suggestedActionEnableArchiveAndMuteNewChats" -> SuggestedAction -> Parser SuggestedAction
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SuggestedAction
SuggestedActionEnableArchiveAndMuteNewChats
String
"suggestedActionCheckPassword" -> SuggestedAction -> Parser SuggestedAction
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SuggestedAction
SuggestedActionCheckPassword
String
"suggestedActionCheckPhoneNumber" -> SuggestedAction -> Parser SuggestedAction
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SuggestedAction
SuggestedActionCheckPhoneNumber
String
"suggestedActionViewChecksHint" -> SuggestedAction -> Parser SuggestedAction
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SuggestedAction
SuggestedActionViewChecksHint
String
"suggestedActionConvertToBroadcastGroup" -> Value -> Parser SuggestedAction
parseSuggestedActionConvertToBroadcastGroup Value
v
String
"suggestedActionSetPassword" -> Value -> Parser SuggestedAction
parseSuggestedActionSetPassword Value
v
String
"suggestedActionUpgradePremium" -> SuggestedAction -> Parser SuggestedAction
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SuggestedAction
SuggestedActionUpgradePremium
String
"suggestedActionRestorePremium" -> SuggestedAction -> Parser SuggestedAction
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SuggestedAction
SuggestedActionRestorePremium
String
"suggestedActionSubscribeToAnnualPremium" -> SuggestedAction -> Parser SuggestedAction
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SuggestedAction
SuggestedActionSubscribeToAnnualPremium
String
"suggestedActionGiftPremiumForChristmas" -> SuggestedAction -> Parser SuggestedAction
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SuggestedAction
SuggestedActionGiftPremiumForChristmas
String
"suggestedActionSetBirthdate" -> SuggestedAction -> Parser SuggestedAction
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SuggestedAction
SuggestedActionSetBirthdate
String
"suggestedActionSetProfilePhoto" -> SuggestedAction -> Parser SuggestedAction
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SuggestedAction
SuggestedActionSetProfilePhoto
String
"suggestedActionExtendPremium" -> Value -> Parser SuggestedAction
parseSuggestedActionExtendPremium Value
v
String
"suggestedActionExtendStarSubscriptions" -> SuggestedAction -> Parser SuggestedAction
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure SuggestedAction
SuggestedActionExtendStarSubscriptions
String
_ -> Parser SuggestedAction
forall a. Monoid a => a
mempty
where
parseSuggestedActionConvertToBroadcastGroup :: A.Value -> AT.Parser SuggestedAction
parseSuggestedActionConvertToBroadcastGroup :: Value -> Parser SuggestedAction
parseSuggestedActionConvertToBroadcastGroup = String
-> (Object -> Parser SuggestedAction)
-> Value
-> Parser SuggestedAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"SuggestedActionConvertToBroadcastGroup" ((Object -> Parser SuggestedAction)
-> Value -> Parser SuggestedAction)
-> (Object -> Parser SuggestedAction)
-> Value
-> Parser SuggestedAction
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
supergroup_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"supergroup_id"
SuggestedAction -> Parser SuggestedAction
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SuggestedAction -> Parser SuggestedAction)
-> SuggestedAction -> Parser SuggestedAction
forall a b. (a -> b) -> a -> b
$ SuggestedActionConvertToBroadcastGroup
{ supergroup_id :: Maybe Int
supergroup_id = Maybe Int
supergroup_id_
}
parseSuggestedActionSetPassword :: A.Value -> AT.Parser SuggestedAction
parseSuggestedActionSetPassword :: Value -> Parser SuggestedAction
parseSuggestedActionSetPassword = String
-> (Object -> Parser SuggestedAction)
-> Value
-> Parser SuggestedAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"SuggestedActionSetPassword" ((Object -> Parser SuggestedAction)
-> Value -> Parser SuggestedAction)
-> (Object -> Parser SuggestedAction)
-> Value
-> Parser SuggestedAction
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
authorization_delay_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"authorization_delay"
SuggestedAction -> Parser SuggestedAction
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SuggestedAction -> Parser SuggestedAction)
-> SuggestedAction -> Parser SuggestedAction
forall a b. (a -> b) -> a -> b
$ SuggestedActionSetPassword
{ authorization_delay :: Maybe Int
authorization_delay = Maybe Int
authorization_delay_
}
parseSuggestedActionExtendPremium :: A.Value -> AT.Parser SuggestedAction
parseSuggestedActionExtendPremium :: Value -> Parser SuggestedAction
parseSuggestedActionExtendPremium = String
-> (Object -> Parser SuggestedAction)
-> Value
-> Parser SuggestedAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"SuggestedActionExtendPremium" ((Object -> Parser SuggestedAction)
-> Value -> Parser SuggestedAction)
-> (Object -> Parser SuggestedAction)
-> Value
-> Parser SuggestedAction
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
manage_premium_subscription_url_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"manage_premium_subscription_url"
SuggestedAction -> Parser SuggestedAction
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SuggestedAction -> Parser SuggestedAction)
-> SuggestedAction -> Parser SuggestedAction
forall a b. (a -> b) -> a -> b
$ SuggestedActionExtendPremium
{ manage_premium_subscription_url :: Maybe Text
manage_premium_subscription_url = Maybe Text
manage_premium_subscription_url_
}
parseJSON Value
_ = Parser SuggestedAction
forall a. Monoid a => a
mempty
instance AT.ToJSON SuggestedAction where
toJSON :: SuggestedAction -> Value
toJSON SuggestedAction
SuggestedActionEnableArchiveAndMuteNewChats
= [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
"suggestedActionEnableArchiveAndMuteNewChats"
]
toJSON SuggestedAction
SuggestedActionCheckPassword
= [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
"suggestedActionCheckPassword"
]
toJSON SuggestedAction
SuggestedActionCheckPhoneNumber
= [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
"suggestedActionCheckPhoneNumber"
]
toJSON SuggestedAction
SuggestedActionViewChecksHint
= [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
"suggestedActionViewChecksHint"
]
toJSON SuggestedActionConvertToBroadcastGroup
{ supergroup_id :: SuggestedAction -> Maybe Int
supergroup_id = Maybe Int
supergroup_id_
}
= [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
"suggestedActionConvertToBroadcastGroup"
, Key
"supergroup_id" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
supergroup_id_
]
toJSON SuggestedActionSetPassword
{ authorization_delay :: SuggestedAction -> Maybe Int
authorization_delay = Maybe Int
authorization_delay_
}
= [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
"suggestedActionSetPassword"
, Key
"authorization_delay" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
authorization_delay_
]
toJSON SuggestedAction
SuggestedActionUpgradePremium
= [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
"suggestedActionUpgradePremium"
]
toJSON SuggestedAction
SuggestedActionRestorePremium
= [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
"suggestedActionRestorePremium"
]
toJSON SuggestedAction
SuggestedActionSubscribeToAnnualPremium
= [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
"suggestedActionSubscribeToAnnualPremium"
]
toJSON SuggestedAction
SuggestedActionGiftPremiumForChristmas
= [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
"suggestedActionGiftPremiumForChristmas"
]
toJSON SuggestedAction
SuggestedActionSetBirthdate
= [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
"suggestedActionSetBirthdate"
]
toJSON SuggestedAction
SuggestedActionSetProfilePhoto
= [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
"suggestedActionSetProfilePhoto"
]
toJSON SuggestedActionExtendPremium
{ manage_premium_subscription_url :: SuggestedAction -> Maybe Text
manage_premium_subscription_url = Maybe Text
manage_premium_subscription_url_
}
= [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
"suggestedActionExtendPremium"
, Key
"manage_premium_subscription_url" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
manage_premium_subscription_url_
]
toJSON SuggestedAction
SuggestedActionExtendStarSubscriptions
= [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
"suggestedActionExtendStarSubscriptions"
]