module TD.Data.ThumbnailFormat
  (ThumbnailFormat(..)) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I

-- | Describes format of a thumbnail
data ThumbnailFormat
  = ThumbnailFormatJpeg -- ^ The thumbnail is in JPEG format
  | ThumbnailFormatGif -- ^ The thumbnail is in static GIF format. It will be used only for some bot inline query results
  | ThumbnailFormatMpeg4 -- ^ The thumbnail is in MPEG4 format. It will be used only for some animations and videos
  | ThumbnailFormatPng -- ^ The thumbnail is in PNG format. It will be used only for background patterns
  | ThumbnailFormatTgs -- ^ The thumbnail is in TGS format. It will be used only for sticker sets
  | ThumbnailFormatWebm -- ^ The thumbnail is in WEBM format. It will be used only for sticker sets
  | ThumbnailFormatWebp -- ^ The thumbnail is in WEBP format. It will be used only for some stickers and sticker sets
  deriving (ThumbnailFormat -> ThumbnailFormat -> Bool
(ThumbnailFormat -> ThumbnailFormat -> Bool)
-> (ThumbnailFormat -> ThumbnailFormat -> Bool)
-> Eq ThumbnailFormat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ThumbnailFormat -> ThumbnailFormat -> Bool
== :: ThumbnailFormat -> ThumbnailFormat -> Bool
$c/= :: ThumbnailFormat -> ThumbnailFormat -> Bool
/= :: ThumbnailFormat -> ThumbnailFormat -> Bool
Eq, Int -> ThumbnailFormat -> ShowS
[ThumbnailFormat] -> ShowS
ThumbnailFormat -> String
(Int -> ThumbnailFormat -> ShowS)
-> (ThumbnailFormat -> String)
-> ([ThumbnailFormat] -> ShowS)
-> Show ThumbnailFormat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ThumbnailFormat -> ShowS
showsPrec :: Int -> ThumbnailFormat -> ShowS
$cshow :: ThumbnailFormat -> String
show :: ThumbnailFormat -> String
$cshowList :: [ThumbnailFormat] -> ShowS
showList :: [ThumbnailFormat] -> ShowS
Show)

instance I.ShortShow ThumbnailFormat where
  shortShow :: ThumbnailFormat -> String
shortShow ThumbnailFormat
ThumbnailFormatJpeg
      = String
"ThumbnailFormatJpeg"
  shortShow ThumbnailFormat
ThumbnailFormatGif
      = String
"ThumbnailFormatGif"
  shortShow ThumbnailFormat
ThumbnailFormatMpeg4
      = String
"ThumbnailFormatMpeg4"
  shortShow ThumbnailFormat
ThumbnailFormatPng
      = String
"ThumbnailFormatPng"
  shortShow ThumbnailFormat
ThumbnailFormatTgs
      = String
"ThumbnailFormatTgs"
  shortShow ThumbnailFormat
ThumbnailFormatWebm
      = String
"ThumbnailFormatWebm"
  shortShow ThumbnailFormat
ThumbnailFormatWebp
      = String
"ThumbnailFormatWebp"

instance AT.FromJSON ThumbnailFormat where
  parseJSON :: Value -> Parser ThumbnailFormat
parseJSON (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
"thumbnailFormatJpeg"  -> ThumbnailFormat -> Parser ThumbnailFormat
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ThumbnailFormat
ThumbnailFormatJpeg
      String
"thumbnailFormatGif"   -> ThumbnailFormat -> Parser ThumbnailFormat
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ThumbnailFormat
ThumbnailFormatGif
      String
"thumbnailFormatMpeg4" -> ThumbnailFormat -> Parser ThumbnailFormat
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ThumbnailFormat
ThumbnailFormatMpeg4
      String
"thumbnailFormatPng"   -> ThumbnailFormat -> Parser ThumbnailFormat
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ThumbnailFormat
ThumbnailFormatPng
      String
"thumbnailFormatTgs"   -> ThumbnailFormat -> Parser ThumbnailFormat
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ThumbnailFormat
ThumbnailFormatTgs
      String
"thumbnailFormatWebm"  -> ThumbnailFormat -> Parser ThumbnailFormat
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ThumbnailFormat
ThumbnailFormatWebm
      String
"thumbnailFormatWebp"  -> ThumbnailFormat -> Parser ThumbnailFormat
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ThumbnailFormat
ThumbnailFormatWebp
      String
_                      -> Parser ThumbnailFormat
forall a. Monoid a => a
mempty
    
  parseJSON Value
_ = Parser ThumbnailFormat
forall a. Monoid a => a
mempty