module TD.Data.StickerSetInfo
  (StickerSetInfo(..)) 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.ClosedVectorPath as ClosedVectorPath
import qualified TD.Data.StickerType as StickerType
import qualified TD.Data.Sticker as Sticker

data StickerSetInfo
  = StickerSetInfo -- ^ Represents short information about a sticker set
    { StickerSetInfo -> Maybe Int
_id                             :: Maybe Int                                 -- ^ Identifier of the sticker set
    , StickerSetInfo -> Maybe Text
title                           :: Maybe T.Text                              -- ^ Title of the sticker set
    , StickerSetInfo -> Maybe Text
name                            :: Maybe T.Text                              -- ^ Name of the sticker set
    , StickerSetInfo -> Maybe Thumbnail
thumbnail                       :: Maybe Thumbnail.Thumbnail                 -- ^ Sticker set thumbnail in WEBP, TGS, or WEBM format with width and height 100; may be null. The file can be downloaded only before the thumbnail is changed
    , StickerSetInfo -> Maybe [ClosedVectorPath]
thumbnail_outline               :: Maybe [ClosedVectorPath.ClosedVectorPath] -- ^ Sticker set thumbnail's outline represented as a list of closed vector paths; may be empty. The coordinate system origin is in the upper-left corner
    , StickerSetInfo -> Maybe Bool
is_owned                        :: Maybe Bool                                -- ^ True, if the sticker set is owned by the current user
    , StickerSetInfo -> Maybe Bool
is_installed                    :: Maybe Bool                                -- ^ True, if the sticker set has been installed by the current user
    , StickerSetInfo -> Maybe Bool
is_archived                     :: Maybe Bool                                -- ^ True, if the sticker set has been archived. A sticker set can't be installed and archived simultaneously
    , StickerSetInfo -> Maybe Bool
is_official                     :: Maybe Bool                                -- ^ True, if the sticker set is official
    , StickerSetInfo -> Maybe StickerType
sticker_type                    :: Maybe StickerType.StickerType             -- ^ Type of the stickers in the set
    , StickerSetInfo -> Maybe Bool
needs_repainting                :: Maybe Bool                                -- ^ True, if stickers in the sticker set are custom emoji that must be repainted; for custom emoji sticker sets only
    , StickerSetInfo -> Maybe Bool
is_allowed_as_chat_emoji_status :: Maybe Bool                                -- ^ True, if stickers in the sticker set are custom emoji that can be used as chat emoji status; for custom emoji sticker sets only
    , StickerSetInfo -> Maybe Bool
is_viewed                       :: Maybe Bool                                -- ^ True for already viewed trending sticker sets
    , StickerSetInfo -> Maybe Int
size                            :: Maybe Int                                 -- ^ Total number of stickers in the set
    , StickerSetInfo -> Maybe [Sticker]
covers                          :: Maybe [Sticker.Sticker]                   -- ^ Up to the first 5 stickers from the set, depending on the context. If the application needs more stickers the full sticker set needs to be requested
    }
  deriving (StickerSetInfo -> StickerSetInfo -> Bool
(StickerSetInfo -> StickerSetInfo -> Bool)
-> (StickerSetInfo -> StickerSetInfo -> Bool) -> Eq StickerSetInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: StickerSetInfo -> StickerSetInfo -> Bool
== :: StickerSetInfo -> StickerSetInfo -> Bool
$c/= :: StickerSetInfo -> StickerSetInfo -> Bool
/= :: StickerSetInfo -> StickerSetInfo -> Bool
Eq, Int -> StickerSetInfo -> ShowS
[StickerSetInfo] -> ShowS
StickerSetInfo -> String
(Int -> StickerSetInfo -> ShowS)
-> (StickerSetInfo -> String)
-> ([StickerSetInfo] -> ShowS)
-> Show StickerSetInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> StickerSetInfo -> ShowS
showsPrec :: Int -> StickerSetInfo -> ShowS
$cshow :: StickerSetInfo -> String
show :: StickerSetInfo -> String
$cshowList :: [StickerSetInfo] -> ShowS
showList :: [StickerSetInfo] -> ShowS
Show)

instance I.ShortShow StickerSetInfo where
  shortShow :: StickerSetInfo -> String
shortShow StickerSetInfo
    { _id :: StickerSetInfo -> Maybe Int
_id                             = Maybe Int
_id_
    , title :: StickerSetInfo -> Maybe Text
title                           = Maybe Text
title_
    , name :: StickerSetInfo -> Maybe Text
name                            = Maybe Text
name_
    , thumbnail :: StickerSetInfo -> Maybe Thumbnail
thumbnail                       = Maybe Thumbnail
thumbnail_
    , thumbnail_outline :: StickerSetInfo -> Maybe [ClosedVectorPath]
thumbnail_outline               = Maybe [ClosedVectorPath]
thumbnail_outline_
    , is_owned :: StickerSetInfo -> Maybe Bool
is_owned                        = Maybe Bool
is_owned_
    , is_installed :: StickerSetInfo -> Maybe Bool
is_installed                    = Maybe Bool
is_installed_
    , is_archived :: StickerSetInfo -> Maybe Bool
is_archived                     = Maybe Bool
is_archived_
    , is_official :: StickerSetInfo -> Maybe Bool
is_official                     = Maybe Bool
is_official_
    , sticker_type :: StickerSetInfo -> Maybe StickerType
sticker_type                    = Maybe StickerType
sticker_type_
    , needs_repainting :: StickerSetInfo -> Maybe Bool
needs_repainting                = Maybe Bool
needs_repainting_
    , is_allowed_as_chat_emoji_status :: StickerSetInfo -> Maybe Bool
is_allowed_as_chat_emoji_status = Maybe Bool
is_allowed_as_chat_emoji_status_
    , is_viewed :: StickerSetInfo -> Maybe Bool
is_viewed                       = Maybe Bool
is_viewed_
    , size :: StickerSetInfo -> Maybe Int
size                            = Maybe Int
size_
    , covers :: StickerSetInfo -> Maybe [Sticker]
covers                          = Maybe [Sticker]
covers_
    }
      = String
"StickerSetInfo"
        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 [ClosedVectorPath] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [ClosedVectorPath]
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
"size"                            String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
size_
        , String
"covers"                          String -> Maybe [Sticker] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Sticker]
covers_
        ]

instance AT.FromJSON StickerSetInfo where
  parseJSON :: Value -> Parser StickerSetInfo
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
"stickerSetInfo" -> Value -> Parser StickerSetInfo
parseStickerSetInfo Value
v
      String
_                -> Parser StickerSetInfo
forall a. Monoid a => a
mempty
    
    where
      parseStickerSetInfo :: A.Value -> AT.Parser StickerSetInfo
      parseStickerSetInfo :: Value -> Parser StickerSetInfo
parseStickerSetInfo = String
-> (Object -> Parser StickerSetInfo)
-> Value
-> Parser StickerSetInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"StickerSetInfo" ((Object -> Parser StickerSetInfo)
 -> Value -> Parser StickerSetInfo)
-> (Object -> Parser StickerSetInfo)
-> Value
-> Parser StickerSetInfo
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 [ClosedVectorPath]
thumbnail_outline_               <- Object
o Object -> Key -> Parser (Maybe [ClosedVectorPath])
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 Int
size_                            <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"size"
        Maybe [Sticker]
covers_                          <- Object
o Object -> Key -> Parser (Maybe [Sticker])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?                       Key
"covers"
        StickerSetInfo -> Parser StickerSetInfo
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (StickerSetInfo -> Parser StickerSetInfo)
-> StickerSetInfo -> Parser StickerSetInfo
forall a b. (a -> b) -> a -> b
$ StickerSetInfo
          { _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 [ClosedVectorPath]
thumbnail_outline               = Maybe [ClosedVectorPath]
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_
          , size :: Maybe Int
size                            = Maybe Int
size_
          , covers :: Maybe [Sticker]
covers                          = Maybe [Sticker]
covers_
          }
  parseJSON Value
_ = Parser StickerSetInfo
forall a. Monoid a => a
mempty