module TD.Data.StickerSet
(StickerSet(..)) 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
import qualified TD.Data.Thumbnail as Thumbnail
import qualified TD.Data.Outline as Outline
import qualified TD.Data.StickerType as StickerType
import qualified TD.Data.Sticker as Sticker
import qualified TD.Data.Emojis as Emojis
data StickerSet
= StickerSet
{ StickerSet -> Maybe Int
_id :: Maybe Int
, StickerSet -> Maybe Text
title :: Maybe T.Text
, StickerSet -> Maybe Text
name :: Maybe T.Text
, StickerSet -> Maybe Thumbnail
thumbnail :: Maybe Thumbnail.Thumbnail
, StickerSet -> Maybe Outline
thumbnail_outline :: Maybe Outline.Outline
, StickerSet -> Maybe Bool
is_owned :: Maybe Bool
, StickerSet -> Maybe Bool
is_installed :: Maybe Bool
, StickerSet -> Maybe Bool
is_archived :: Maybe Bool
, StickerSet -> Maybe Bool
is_official :: Maybe Bool
, StickerSet -> Maybe StickerType
sticker_type :: Maybe StickerType.StickerType
, StickerSet -> Maybe Bool
needs_repainting :: Maybe Bool
, StickerSet -> Maybe Bool
is_allowed_as_chat_emoji_status :: Maybe Bool
, StickerSet -> Maybe Bool
is_viewed :: Maybe Bool
, StickerSet -> Maybe [Sticker]
stickers :: Maybe [Sticker.Sticker]
, StickerSet -> Maybe [Emojis]
emojis :: Maybe [Emojis.Emojis]
}
deriving (StickerSet -> StickerSet -> Bool
(StickerSet -> StickerSet -> Bool)
-> (StickerSet -> StickerSet -> Bool) -> Eq StickerSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: StickerSet -> StickerSet -> Bool
== :: StickerSet -> StickerSet -> Bool
$c/= :: StickerSet -> StickerSet -> Bool
/= :: StickerSet -> StickerSet -> Bool
Eq, Int -> StickerSet -> ShowS
[StickerSet] -> ShowS
StickerSet -> String
(Int -> StickerSet -> ShowS)
-> (StickerSet -> String)
-> ([StickerSet] -> ShowS)
-> Show StickerSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> StickerSet -> ShowS
showsPrec :: Int -> StickerSet -> ShowS
$cshow :: StickerSet -> String
show :: StickerSet -> String
$cshowList :: [StickerSet] -> ShowS
showList :: [StickerSet] -> ShowS
Show)
instance I.ShortShow StickerSet where
shortShow :: StickerSet -> String
shortShow StickerSet
{ _id :: StickerSet -> Maybe Int
_id = Maybe Int
_id_
, title :: StickerSet -> Maybe Text
title = Maybe Text
title_
, name :: StickerSet -> Maybe Text
name = Maybe Text
name_
, thumbnail :: StickerSet -> Maybe Thumbnail
thumbnail = Maybe Thumbnail
thumbnail_
, thumbnail_outline :: StickerSet -> Maybe Outline
thumbnail_outline = Maybe Outline
thumbnail_outline_
, is_owned :: StickerSet -> Maybe Bool
is_owned = Maybe Bool
is_owned_
, is_installed :: StickerSet -> Maybe Bool
is_installed = Maybe Bool
is_installed_
, is_archived :: StickerSet -> Maybe Bool
is_archived = Maybe Bool
is_archived_
, is_official :: StickerSet -> Maybe Bool
is_official = Maybe Bool
is_official_
, sticker_type :: StickerSet -> Maybe StickerType
sticker_type = Maybe StickerType
sticker_type_
, needs_repainting :: StickerSet -> Maybe Bool
needs_repainting = Maybe Bool
needs_repainting_
, is_allowed_as_chat_emoji_status :: StickerSet -> Maybe Bool
is_allowed_as_chat_emoji_status = Maybe Bool
is_allowed_as_chat_emoji_status_
, is_viewed :: StickerSet -> Maybe Bool
is_viewed = Maybe Bool
is_viewed_
, stickers :: StickerSet -> Maybe [Sticker]
stickers = Maybe [Sticker]
stickers_
, emojis :: StickerSet -> Maybe [Emojis]
emojis = Maybe [Emojis]
emojis_
}
= String
"StickerSet"
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
"title" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
title_
, String
"name" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
name_
, String
"thumbnail" String -> Maybe Thumbnail -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Thumbnail
thumbnail_
, String
"thumbnail_outline" String -> Maybe Outline -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Outline
thumbnail_outline_
, String
"is_owned" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_owned_
, String
"is_installed" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_installed_
, String
"is_archived" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_archived_
, String
"is_official" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_official_
, String
"sticker_type" String -> Maybe StickerType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StickerType
sticker_type_
, String
"needs_repainting" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
needs_repainting_
, String
"is_allowed_as_chat_emoji_status" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_allowed_as_chat_emoji_status_
, String
"is_viewed" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_viewed_
, String
"stickers" String -> Maybe [Sticker] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Sticker]
stickers_
, String
"emojis" String -> Maybe [Emojis] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Emojis]
emojis_
]
instance AT.FromJSON StickerSet where
parseJSON :: Value -> Parser StickerSet
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
"stickerSet" -> Value -> Parser StickerSet
parseStickerSet Value
v
String
_ -> Parser StickerSet
forall a. Monoid a => a
mempty
where
parseStickerSet :: A.Value -> AT.Parser StickerSet
parseStickerSet :: Value -> Parser StickerSet
parseStickerSet = String
-> (Object -> Parser StickerSet) -> Value -> Parser StickerSet
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"StickerSet" ((Object -> Parser StickerSet) -> Value -> Parser StickerSet)
-> (Object -> Parser StickerSet) -> Value -> Parser StickerSet
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
_id_ <- (String -> Int) -> Maybe String -> Maybe Int
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Int
I.readInt64 (Maybe String -> Maybe Int)
-> Parser (Maybe String) -> Parser (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Maybe String)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"id"
Maybe Text
title_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"title"
Maybe Text
name_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"name"
Maybe Thumbnail
thumbnail_ <- Object
o Object -> Key -> Parser (Maybe Thumbnail)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"thumbnail"
Maybe Outline
thumbnail_outline_ <- Object
o Object -> Key -> Parser (Maybe Outline)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"thumbnail_outline"
Maybe Bool
is_owned_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_owned"
Maybe Bool
is_installed_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_installed"
Maybe Bool
is_archived_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_archived"
Maybe Bool
is_official_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_official"
Maybe StickerType
sticker_type_ <- Object
o Object -> Key -> Parser (Maybe StickerType)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"sticker_type"
Maybe Bool
needs_repainting_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"needs_repainting"
Maybe Bool
is_allowed_as_chat_emoji_status_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_allowed_as_chat_emoji_status"
Maybe Bool
is_viewed_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_viewed"
Maybe [Sticker]
stickers_ <- Object
o Object -> Key -> Parser (Maybe [Sticker])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"stickers"
Maybe [Emojis]
emojis_ <- Object
o Object -> Key -> Parser (Maybe [Emojis])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"emojis"
StickerSet -> Parser StickerSet
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (StickerSet -> Parser StickerSet)
-> StickerSet -> Parser StickerSet
forall a b. (a -> b) -> a -> b
$ StickerSet
{ _id :: Maybe Int
_id = Maybe Int
_id_
, title :: Maybe Text
title = Maybe Text
title_
, name :: Maybe Text
name = Maybe Text
name_
, thumbnail :: Maybe Thumbnail
thumbnail = Maybe Thumbnail
thumbnail_
, thumbnail_outline :: Maybe Outline
thumbnail_outline = Maybe Outline
thumbnail_outline_
, is_owned :: Maybe Bool
is_owned = Maybe Bool
is_owned_
, is_installed :: Maybe Bool
is_installed = Maybe Bool
is_installed_
, is_archived :: Maybe Bool
is_archived = Maybe Bool
is_archived_
, is_official :: Maybe Bool
is_official = Maybe Bool
is_official_
, sticker_type :: Maybe StickerType
sticker_type = Maybe StickerType
sticker_type_
, needs_repainting :: Maybe Bool
needs_repainting = Maybe Bool
needs_repainting_
, is_allowed_as_chat_emoji_status :: Maybe Bool
is_allowed_as_chat_emoji_status = Maybe Bool
is_allowed_as_chat_emoji_status_
, is_viewed :: Maybe Bool
is_viewed = Maybe Bool
is_viewed_
, stickers :: Maybe [Sticker]
stickers = Maybe [Sticker]
stickers_
, emojis :: Maybe [Emojis]
emojis = Maybe [Emojis]
emojis_
}
parseJSON Value
_ = Parser StickerSet
forall a. Monoid a => a
mempty