module TD.Data.Story
(Story(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.MessageSender as MessageSender
import qualified TD.Data.StoryRepostInfo as StoryRepostInfo
import qualified TD.Data.StoryInteractionInfo as StoryInteractionInfo
import qualified TD.Data.ReactionType as ReactionType
import qualified TD.Data.StoryPrivacySettings as StoryPrivacySettings
import qualified TD.Data.StoryContent as StoryContent
import qualified TD.Data.StoryArea as StoryArea
import qualified TD.Data.FormattedText as FormattedText
data Story
= Story
{ Story -> Maybe Int
_id :: Maybe Int
, Story -> Maybe Int
sender_chat_id :: Maybe Int
, Story -> Maybe MessageSender
sender_id :: Maybe MessageSender.MessageSender
, Story -> Maybe Int
date :: Maybe Int
, Story -> Maybe Bool
is_being_sent :: Maybe Bool
, Story -> Maybe Bool
is_being_edited :: Maybe Bool
, Story -> Maybe Bool
is_edited :: Maybe Bool
, Story -> Maybe Bool
is_posted_to_chat_page :: Maybe Bool
, Story -> Maybe Bool
is_visible_only_for_self :: Maybe Bool
, Story -> Maybe Bool
can_be_deleted :: Maybe Bool
, Story -> Maybe Bool
can_be_edited :: Maybe Bool
, Story -> Maybe Bool
can_be_forwarded :: Maybe Bool
, Story -> Maybe Bool
can_be_replied :: Maybe Bool
, Story -> Maybe Bool
can_toggle_is_posted_to_chat_page :: Maybe Bool
, Story -> Maybe Bool
can_get_statistics :: Maybe Bool
, Story -> Maybe Bool
can_get_interactions :: Maybe Bool
, Story -> Maybe Bool
has_expired_viewers :: Maybe Bool
, Story -> Maybe StoryRepostInfo
repost_info :: Maybe StoryRepostInfo.StoryRepostInfo
, Story -> Maybe StoryInteractionInfo
interaction_info :: Maybe StoryInteractionInfo.StoryInteractionInfo
, Story -> Maybe ReactionType
chosen_reaction_type :: Maybe ReactionType.ReactionType
, Story -> Maybe StoryPrivacySettings
privacy_settings :: Maybe StoryPrivacySettings.StoryPrivacySettings
, Story -> Maybe StoryContent
content :: Maybe StoryContent.StoryContent
, Story -> Maybe [StoryArea]
areas :: Maybe [StoryArea.StoryArea]
, Story -> Maybe FormattedText
caption :: Maybe FormattedText.FormattedText
}
deriving (Story -> Story -> Bool
(Story -> Story -> Bool) -> (Story -> Story -> Bool) -> Eq Story
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Story -> Story -> Bool
== :: Story -> Story -> Bool
$c/= :: Story -> Story -> Bool
/= :: Story -> Story -> Bool
Eq, Int -> Story -> ShowS
[Story] -> ShowS
Story -> String
(Int -> Story -> ShowS)
-> (Story -> String) -> ([Story] -> ShowS) -> Show Story
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Story -> ShowS
showsPrec :: Int -> Story -> ShowS
$cshow :: Story -> String
show :: Story -> String
$cshowList :: [Story] -> ShowS
showList :: [Story] -> ShowS
Show)
instance I.ShortShow Story where
shortShow :: Story -> String
shortShow Story
{ _id :: Story -> Maybe Int
_id = Maybe Int
_id_
, sender_chat_id :: Story -> Maybe Int
sender_chat_id = Maybe Int
sender_chat_id_
, sender_id :: Story -> Maybe MessageSender
sender_id = Maybe MessageSender
sender_id_
, date :: Story -> Maybe Int
date = Maybe Int
date_
, is_being_sent :: Story -> Maybe Bool
is_being_sent = Maybe Bool
is_being_sent_
, is_being_edited :: Story -> Maybe Bool
is_being_edited = Maybe Bool
is_being_edited_
, is_edited :: Story -> Maybe Bool
is_edited = Maybe Bool
is_edited_
, is_posted_to_chat_page :: Story -> Maybe Bool
is_posted_to_chat_page = Maybe Bool
is_posted_to_chat_page_
, is_visible_only_for_self :: Story -> Maybe Bool
is_visible_only_for_self = Maybe Bool
is_visible_only_for_self_
, can_be_deleted :: Story -> Maybe Bool
can_be_deleted = Maybe Bool
can_be_deleted_
, can_be_edited :: Story -> Maybe Bool
can_be_edited = Maybe Bool
can_be_edited_
, can_be_forwarded :: Story -> Maybe Bool
can_be_forwarded = Maybe Bool
can_be_forwarded_
, can_be_replied :: Story -> Maybe Bool
can_be_replied = Maybe Bool
can_be_replied_
, can_toggle_is_posted_to_chat_page :: Story -> Maybe Bool
can_toggle_is_posted_to_chat_page = Maybe Bool
can_toggle_is_posted_to_chat_page_
, can_get_statistics :: Story -> Maybe Bool
can_get_statistics = Maybe Bool
can_get_statistics_
, can_get_interactions :: Story -> Maybe Bool
can_get_interactions = Maybe Bool
can_get_interactions_
, has_expired_viewers :: Story -> Maybe Bool
has_expired_viewers = Maybe Bool
has_expired_viewers_
, repost_info :: Story -> Maybe StoryRepostInfo
repost_info = Maybe StoryRepostInfo
repost_info_
, interaction_info :: Story -> Maybe StoryInteractionInfo
interaction_info = Maybe StoryInteractionInfo
interaction_info_
, chosen_reaction_type :: Story -> Maybe ReactionType
chosen_reaction_type = Maybe ReactionType
chosen_reaction_type_
, privacy_settings :: Story -> Maybe StoryPrivacySettings
privacy_settings = Maybe StoryPrivacySettings
privacy_settings_
, content :: Story -> Maybe StoryContent
content = Maybe StoryContent
content_
, areas :: Story -> Maybe [StoryArea]
areas = Maybe [StoryArea]
areas_
, caption :: Story -> Maybe FormattedText
caption = Maybe FormattedText
caption_
}
= String
"Story"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
_id_
, String
"sender_chat_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
sender_chat_id_
, String
"sender_id" String -> Maybe MessageSender -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe MessageSender
sender_id_
, String
"date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
date_
, String
"is_being_sent" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_being_sent_
, String
"is_being_edited" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_being_edited_
, String
"is_edited" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_edited_
, String
"is_posted_to_chat_page" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_posted_to_chat_page_
, String
"is_visible_only_for_self" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_visible_only_for_self_
, String
"can_be_deleted" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_be_deleted_
, String
"can_be_edited" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_be_edited_
, String
"can_be_forwarded" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_be_forwarded_
, String
"can_be_replied" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_be_replied_
, String
"can_toggle_is_posted_to_chat_page" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_toggle_is_posted_to_chat_page_
, String
"can_get_statistics" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_get_statistics_
, String
"can_get_interactions" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_get_interactions_
, String
"has_expired_viewers" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_expired_viewers_
, String
"repost_info" String -> Maybe StoryRepostInfo -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StoryRepostInfo
repost_info_
, String
"interaction_info" String -> Maybe StoryInteractionInfo -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StoryInteractionInfo
interaction_info_
, String
"chosen_reaction_type" String -> Maybe ReactionType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ReactionType
chosen_reaction_type_
, String
"privacy_settings" String -> Maybe StoryPrivacySettings -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StoryPrivacySettings
privacy_settings_
, String
"content" String -> Maybe StoryContent -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StoryContent
content_
, String
"areas" String -> Maybe [StoryArea] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [StoryArea]
areas_
, String
"caption" String -> Maybe FormattedText -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe FormattedText
caption_
]
instance AT.FromJSON Story where
parseJSON :: Value -> Parser Story
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
"story" -> Value -> Parser Story
parseStory Value
v
String
_ -> Parser Story
forall a. Monoid a => a
mempty
where
parseStory :: A.Value -> AT.Parser Story
parseStory :: Value -> Parser Story
parseStory = String -> (Object -> Parser Story) -> Value -> Parser Story
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"Story" ((Object -> Parser Story) -> Value -> Parser Story)
-> (Object -> Parser Story) -> Value -> Parser Story
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"id"
Maybe Int
sender_chat_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"sender_chat_id"
Maybe MessageSender
sender_id_ <- Object
o Object -> Key -> Parser (Maybe MessageSender)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"sender_id"
Maybe Int
date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"date"
Maybe Bool
is_being_sent_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_being_sent"
Maybe Bool
is_being_edited_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_being_edited"
Maybe Bool
is_edited_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_edited"
Maybe Bool
is_posted_to_chat_page_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_posted_to_chat_page"
Maybe Bool
is_visible_only_for_self_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_visible_only_for_self"
Maybe Bool
can_be_deleted_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_be_deleted"
Maybe Bool
can_be_edited_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_be_edited"
Maybe Bool
can_be_forwarded_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_be_forwarded"
Maybe Bool
can_be_replied_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_be_replied"
Maybe Bool
can_toggle_is_posted_to_chat_page_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_toggle_is_posted_to_chat_page"
Maybe Bool
can_get_statistics_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_get_statistics"
Maybe Bool
can_get_interactions_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_get_interactions"
Maybe Bool
has_expired_viewers_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"has_expired_viewers"
Maybe StoryRepostInfo
repost_info_ <- Object
o Object -> Key -> Parser (Maybe StoryRepostInfo)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"repost_info"
Maybe StoryInteractionInfo
interaction_info_ <- Object
o Object -> Key -> Parser (Maybe StoryInteractionInfo)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"interaction_info"
Maybe ReactionType
chosen_reaction_type_ <- Object
o Object -> Key -> Parser (Maybe ReactionType)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"chosen_reaction_type"
Maybe StoryPrivacySettings
privacy_settings_ <- Object
o Object -> Key -> Parser (Maybe StoryPrivacySettings)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"privacy_settings"
Maybe StoryContent
content_ <- Object
o Object -> Key -> Parser (Maybe StoryContent)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"content"
Maybe [StoryArea]
areas_ <- Object
o Object -> Key -> Parser (Maybe [StoryArea])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"areas"
Maybe FormattedText
caption_ <- Object
o Object -> Key -> Parser (Maybe FormattedText)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"caption"
Story -> Parser Story
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Story -> Parser Story) -> Story -> Parser Story
forall a b. (a -> b) -> a -> b
$ Story
{ _id :: Maybe Int
_id = Maybe Int
_id_
, sender_chat_id :: Maybe Int
sender_chat_id = Maybe Int
sender_chat_id_
, sender_id :: Maybe MessageSender
sender_id = Maybe MessageSender
sender_id_
, date :: Maybe Int
date = Maybe Int
date_
, is_being_sent :: Maybe Bool
is_being_sent = Maybe Bool
is_being_sent_
, is_being_edited :: Maybe Bool
is_being_edited = Maybe Bool
is_being_edited_
, is_edited :: Maybe Bool
is_edited = Maybe Bool
is_edited_
, is_posted_to_chat_page :: Maybe Bool
is_posted_to_chat_page = Maybe Bool
is_posted_to_chat_page_
, is_visible_only_for_self :: Maybe Bool
is_visible_only_for_self = Maybe Bool
is_visible_only_for_self_
, can_be_deleted :: Maybe Bool
can_be_deleted = Maybe Bool
can_be_deleted_
, can_be_edited :: Maybe Bool
can_be_edited = Maybe Bool
can_be_edited_
, can_be_forwarded :: Maybe Bool
can_be_forwarded = Maybe Bool
can_be_forwarded_
, can_be_replied :: Maybe Bool
can_be_replied = Maybe Bool
can_be_replied_
, can_toggle_is_posted_to_chat_page :: Maybe Bool
can_toggle_is_posted_to_chat_page = Maybe Bool
can_toggle_is_posted_to_chat_page_
, can_get_statistics :: Maybe Bool
can_get_statistics = Maybe Bool
can_get_statistics_
, can_get_interactions :: Maybe Bool
can_get_interactions = Maybe Bool
can_get_interactions_
, has_expired_viewers :: Maybe Bool
has_expired_viewers = Maybe Bool
has_expired_viewers_
, repost_info :: Maybe StoryRepostInfo
repost_info = Maybe StoryRepostInfo
repost_info_
, interaction_info :: Maybe StoryInteractionInfo
interaction_info = Maybe StoryInteractionInfo
interaction_info_
, chosen_reaction_type :: Maybe ReactionType
chosen_reaction_type = Maybe ReactionType
chosen_reaction_type_
, privacy_settings :: Maybe StoryPrivacySettings
privacy_settings = Maybe StoryPrivacySettings
privacy_settings_
, content :: Maybe StoryContent
content = Maybe StoryContent
content_
, areas :: Maybe [StoryArea]
areas = Maybe [StoryArea]
areas_
, caption :: Maybe FormattedText
caption = Maybe FormattedText
caption_
}
parseJSON Value
_ = Parser Story
forall a. Monoid a => a
mempty