module TD.Data.EmojiCategoryType
  (EmojiCategoryType(..)) where

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

-- | Describes type of emoji category
data EmojiCategoryType
  = EmojiCategoryTypeDefault -- ^ The category must be used by default (e.g., for custom emoji or animation search)
  | EmojiCategoryTypeRegularStickers -- ^ The category must be used by default for regular sticker selection. It may contain greeting emoji category and premium stickers
  | EmojiCategoryTypeEmojiStatus -- ^ The category must be used for emoji status selection
  | EmojiCategoryTypeChatPhoto -- ^ The category must be used for chat photo emoji selection
  deriving (EmojiCategoryType -> EmojiCategoryType -> Bool
(EmojiCategoryType -> EmojiCategoryType -> Bool)
-> (EmojiCategoryType -> EmojiCategoryType -> Bool)
-> Eq EmojiCategoryType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EmojiCategoryType -> EmojiCategoryType -> Bool
== :: EmojiCategoryType -> EmojiCategoryType -> Bool
$c/= :: EmojiCategoryType -> EmojiCategoryType -> Bool
/= :: EmojiCategoryType -> EmojiCategoryType -> Bool
Eq, Int -> EmojiCategoryType -> ShowS
[EmojiCategoryType] -> ShowS
EmojiCategoryType -> String
(Int -> EmojiCategoryType -> ShowS)
-> (EmojiCategoryType -> String)
-> ([EmojiCategoryType] -> ShowS)
-> Show EmojiCategoryType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EmojiCategoryType -> ShowS
showsPrec :: Int -> EmojiCategoryType -> ShowS
$cshow :: EmojiCategoryType -> String
show :: EmojiCategoryType -> String
$cshowList :: [EmojiCategoryType] -> ShowS
showList :: [EmojiCategoryType] -> ShowS
Show)

instance I.ShortShow EmojiCategoryType where
  shortShow :: EmojiCategoryType -> String
shortShow EmojiCategoryType
EmojiCategoryTypeDefault
      = String
"EmojiCategoryTypeDefault"
  shortShow EmojiCategoryType
EmojiCategoryTypeRegularStickers
      = String
"EmojiCategoryTypeRegularStickers"
  shortShow EmojiCategoryType
EmojiCategoryTypeEmojiStatus
      = String
"EmojiCategoryTypeEmojiStatus"
  shortShow EmojiCategoryType
EmojiCategoryTypeChatPhoto
      = String
"EmojiCategoryTypeChatPhoto"

instance AT.FromJSON EmojiCategoryType where
  parseJSON :: Value -> Parser EmojiCategoryType
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
"emojiCategoryTypeDefault"         -> EmojiCategoryType -> Parser EmojiCategoryType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure EmojiCategoryType
EmojiCategoryTypeDefault
      String
"emojiCategoryTypeRegularStickers" -> EmojiCategoryType -> Parser EmojiCategoryType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure EmojiCategoryType
EmojiCategoryTypeRegularStickers
      String
"emojiCategoryTypeEmojiStatus"     -> EmojiCategoryType -> Parser EmojiCategoryType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure EmojiCategoryType
EmojiCategoryTypeEmojiStatus
      String
"emojiCategoryTypeChatPhoto"       -> EmojiCategoryType -> Parser EmojiCategoryType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure EmojiCategoryType
EmojiCategoryTypeChatPhoto
      String
_                                  -> Parser EmojiCategoryType
forall a. Monoid a => a
mempty
    
  parseJSON Value
_ = Parser EmojiCategoryType
forall a. Monoid a => a
mempty

instance AT.ToJSON EmojiCategoryType where
  toJSON :: EmojiCategoryType -> Value
toJSON EmojiCategoryType
EmojiCategoryTypeDefault
      = [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
"emojiCategoryTypeDefault"
        ]
  toJSON EmojiCategoryType
EmojiCategoryTypeRegularStickers
      = [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
"emojiCategoryTypeRegularStickers"
        ]
  toJSON EmojiCategoryType
EmojiCategoryTypeEmojiStatus
      = [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
"emojiCategoryTypeEmojiStatus"
        ]
  toJSON EmojiCategoryType
EmojiCategoryTypeChatPhoto
      = [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
"emojiCategoryTypeChatPhoto"
        ]