module TD.Data.StickerType
  (StickerType(..)) where

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

-- | Describes type of sticker
data StickerType
  = StickerTypeRegular -- ^ The sticker is a regular sticker
  | StickerTypeMask -- ^ The sticker is a mask in WEBP format to be placed on photos or videos
  | StickerTypeCustomEmoji -- ^ The sticker is a custom emoji to be used inside message text and caption
  deriving (StickerType -> StickerType -> Bool
(StickerType -> StickerType -> Bool)
-> (StickerType -> StickerType -> Bool) -> Eq StickerType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: StickerType -> StickerType -> Bool
== :: StickerType -> StickerType -> Bool
$c/= :: StickerType -> StickerType -> Bool
/= :: StickerType -> StickerType -> Bool
Eq, Int -> StickerType -> ShowS
[StickerType] -> ShowS
StickerType -> String
(Int -> StickerType -> ShowS)
-> (StickerType -> String)
-> ([StickerType] -> ShowS)
-> Show StickerType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> StickerType -> ShowS
showsPrec :: Int -> StickerType -> ShowS
$cshow :: StickerType -> String
show :: StickerType -> String
$cshowList :: [StickerType] -> ShowS
showList :: [StickerType] -> ShowS
Show)

instance I.ShortShow StickerType where
  shortShow :: StickerType -> String
shortShow StickerType
StickerTypeRegular
      = String
"StickerTypeRegular"
  shortShow StickerType
StickerTypeMask
      = String
"StickerTypeMask"
  shortShow StickerType
StickerTypeCustomEmoji
      = String
"StickerTypeCustomEmoji"

instance AT.FromJSON StickerType where
  parseJSON :: Value -> Parser StickerType
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
"stickerTypeRegular"     -> StickerType -> Parser StickerType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure StickerType
StickerTypeRegular
      String
"stickerTypeMask"        -> StickerType -> Parser StickerType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure StickerType
StickerTypeMask
      String
"stickerTypeCustomEmoji" -> StickerType -> Parser StickerType
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure StickerType
StickerTypeCustomEmoji
      String
_                        -> Parser StickerType
forall a. Monoid a => a
mempty
    
  parseJSON Value
_ = Parser StickerType
forall a. Monoid a => a
mempty

instance AT.ToJSON StickerType where
  toJSON :: StickerType -> Value
toJSON StickerType
StickerTypeRegular
      = [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
"stickerTypeRegular"
        ]
  toJSON StickerType
StickerTypeMask
      = [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
"stickerTypeMask"
        ]
  toJSON StickerType
StickerTypeCustomEmoji
      = [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
"stickerTypeCustomEmoji"
        ]