module TD.Data.FileType
  (FileType(..)) where

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

-- | Represents the type of file
data FileType
  = FileTypeNone -- ^ The data is not a file
  | FileTypeAnimation -- ^ The file is an animation
  | FileTypeAudio -- ^ The file is an audio file
  | FileTypeDocument -- ^ The file is a document
  | FileTypeNotificationSound -- ^ The file is a notification sound
  | FileTypePhoto -- ^ The file is a photo
  | FileTypePhotoStory -- ^ The file is a photo published as a story
  | FileTypeProfilePhoto -- ^ The file is a profile photo
  | FileTypeSecret -- ^ The file was sent to a secret chat (the file type is not known to the server)
  | FileTypeSecretThumbnail -- ^ The file is a thumbnail of a file from a secret chat
  | FileTypeSecure -- ^ The file is a file from Secure storage used for storing Telegram Passport files
  | FileTypeSticker -- ^ The file is a sticker
  | FileTypeThumbnail -- ^ The file is a thumbnail of another file
  | FileTypeUnknown -- ^ The file type is not yet known
  | FileTypeVideo -- ^ The file is a video
  | FileTypeVideoNote -- ^ The file is a video note
  | FileTypeVideoStory -- ^ The file is a video published as a story
  | FileTypeVoiceNote -- ^ The file is a voice note
  | FileTypeWallpaper -- ^ The file is a wallpaper or a background pattern
  deriving (FileType -> FileType -> Bool
(FileType -> FileType -> Bool)
-> (FileType -> FileType -> Bool) -> Eq FileType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FileType -> FileType -> Bool
== :: FileType -> FileType -> Bool
$c/= :: FileType -> FileType -> Bool
/= :: FileType -> FileType -> Bool
Eq, Int -> FileType -> ShowS
[FileType] -> ShowS
FileType -> String
(Int -> FileType -> ShowS)
-> (FileType -> String) -> ([FileType] -> ShowS) -> Show FileType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FileType -> ShowS
showsPrec :: Int -> FileType -> ShowS
$cshow :: FileType -> String
show :: FileType -> String
$cshowList :: [FileType] -> ShowS
showList :: [FileType] -> ShowS
Show)

instance I.ShortShow FileType where
  shortShow :: FileType -> String
shortShow FileType
FileTypeNone
      = String
"FileTypeNone"
  shortShow FileType
FileTypeAnimation
      = String
"FileTypeAnimation"
  shortShow FileType
FileTypeAudio
      = String
"FileTypeAudio"
  shortShow FileType
FileTypeDocument
      = String
"FileTypeDocument"
  shortShow FileType
FileTypeNotificationSound
      = String
"FileTypeNotificationSound"
  shortShow FileType
FileTypePhoto
      = String
"FileTypePhoto"
  shortShow FileType
FileTypePhotoStory
      = String
"FileTypePhotoStory"
  shortShow FileType
FileTypeProfilePhoto
      = String
"FileTypeProfilePhoto"
  shortShow FileType
FileTypeSecret
      = String
"FileTypeSecret"
  shortShow FileType
FileTypeSecretThumbnail
      = String
"FileTypeSecretThumbnail"
  shortShow FileType
FileTypeSecure
      = String
"FileTypeSecure"
  shortShow FileType
FileTypeSticker
      = String
"FileTypeSticker"
  shortShow FileType
FileTypeThumbnail
      = String
"FileTypeThumbnail"
  shortShow FileType
FileTypeUnknown
      = String
"FileTypeUnknown"
  shortShow FileType
FileTypeVideo
      = String
"FileTypeVideo"
  shortShow FileType
FileTypeVideoNote
      = String
"FileTypeVideoNote"
  shortShow FileType
FileTypeVideoStory
      = String
"FileTypeVideoStory"
  shortShow FileType
FileTypeVoiceNote
      = String
"FileTypeVoiceNote"
  shortShow FileType
FileTypeWallpaper
      = String
"FileTypeWallpaper"

instance AT.FromJSON FileType where
  parseJSON :: Value -> Parser FileType
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
"fileTypeNone"              -> FileType -> Parser FileType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FileType
FileTypeNone
      String
"fileTypeAnimation"         -> FileType -> Parser FileType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FileType
FileTypeAnimation
      String
"fileTypeAudio"             -> FileType -> Parser FileType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FileType
FileTypeAudio
      String
"fileTypeDocument"          -> FileType -> Parser FileType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FileType
FileTypeDocument
      String
"fileTypeNotificationSound" -> FileType -> Parser FileType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FileType
FileTypeNotificationSound
      String
"fileTypePhoto"             -> FileType -> Parser FileType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FileType
FileTypePhoto
      String
"fileTypePhotoStory"        -> FileType -> Parser FileType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FileType
FileTypePhotoStory
      String
"fileTypeProfilePhoto"      -> FileType -> Parser FileType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FileType
FileTypeProfilePhoto
      String
"fileTypeSecret"            -> FileType -> Parser FileType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FileType
FileTypeSecret
      String
"fileTypeSecretThumbnail"   -> FileType -> Parser FileType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FileType
FileTypeSecretThumbnail
      String
"fileTypeSecure"            -> FileType -> Parser FileType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FileType
FileTypeSecure
      String
"fileTypeSticker"           -> FileType -> Parser FileType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FileType
FileTypeSticker
      String
"fileTypeThumbnail"         -> FileType -> Parser FileType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FileType
FileTypeThumbnail
      String
"fileTypeUnknown"           -> FileType -> Parser FileType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FileType
FileTypeUnknown
      String
"fileTypeVideo"             -> FileType -> Parser FileType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FileType
FileTypeVideo
      String
"fileTypeVideoNote"         -> FileType -> Parser FileType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FileType
FileTypeVideoNote
      String
"fileTypeVideoStory"        -> FileType -> Parser FileType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FileType
FileTypeVideoStory
      String
"fileTypeVoiceNote"         -> FileType -> Parser FileType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FileType
FileTypeVoiceNote
      String
"fileTypeWallpaper"         -> FileType -> Parser FileType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FileType
FileTypeWallpaper
      String
_                           -> Parser FileType
forall a. Monoid a => a
mempty
    
  parseJSON Value
_ = Parser FileType
forall a. Monoid a => a
mempty

instance AT.ToJSON FileType where
  toJSON :: FileType -> Value
toJSON FileType
FileTypeNone
      = [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
"fileTypeNone"
        ]
  toJSON FileType
FileTypeAnimation
      = [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
"fileTypeAnimation"
        ]
  toJSON FileType
FileTypeAudio
      = [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
"fileTypeAudio"
        ]
  toJSON FileType
FileTypeDocument
      = [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
"fileTypeDocument"
        ]
  toJSON FileType
FileTypeNotificationSound
      = [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
"fileTypeNotificationSound"
        ]
  toJSON FileType
FileTypePhoto
      = [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
"fileTypePhoto"
        ]
  toJSON FileType
FileTypePhotoStory
      = [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
"fileTypePhotoStory"
        ]
  toJSON FileType
FileTypeProfilePhoto
      = [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
"fileTypeProfilePhoto"
        ]
  toJSON FileType
FileTypeSecret
      = [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
"fileTypeSecret"
        ]
  toJSON FileType
FileTypeSecretThumbnail
      = [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
"fileTypeSecretThumbnail"
        ]
  toJSON FileType
FileTypeSecure
      = [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
"fileTypeSecure"
        ]
  toJSON FileType
FileTypeSticker
      = [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
"fileTypeSticker"
        ]
  toJSON FileType
FileTypeThumbnail
      = [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
"fileTypeThumbnail"
        ]
  toJSON FileType
FileTypeUnknown
      = [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
"fileTypeUnknown"
        ]
  toJSON FileType
FileTypeVideo
      = [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
"fileTypeVideo"
        ]
  toJSON FileType
FileTypeVideoNote
      = [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
"fileTypeVideoNote"
        ]
  toJSON FileType
FileTypeVideoStory
      = [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
"fileTypeVideoStory"
        ]
  toJSON FileType
FileTypeVoiceNote
      = [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
"fileTypeVoiceNote"
        ]
  toJSON FileType
FileTypeWallpaper
      = [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
"fileTypeWallpaper"
        ]