module TD.Data.CheckStickerSetNameResult
  (CheckStickerSetNameResult(..)) where

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

-- | Represents result of checking whether a name can be used for a new sticker set
data CheckStickerSetNameResult
  = CheckStickerSetNameResultOk -- ^ The name can be set
  | CheckStickerSetNameResultNameInvalid -- ^ The name is invalid
  | CheckStickerSetNameResultNameOccupied -- ^ The name is occupied
  deriving (CheckStickerSetNameResult -> CheckStickerSetNameResult -> Bool
(CheckStickerSetNameResult -> CheckStickerSetNameResult -> Bool)
-> (CheckStickerSetNameResult -> CheckStickerSetNameResult -> Bool)
-> Eq CheckStickerSetNameResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CheckStickerSetNameResult -> CheckStickerSetNameResult -> Bool
== :: CheckStickerSetNameResult -> CheckStickerSetNameResult -> Bool
$c/= :: CheckStickerSetNameResult -> CheckStickerSetNameResult -> Bool
/= :: CheckStickerSetNameResult -> CheckStickerSetNameResult -> Bool
Eq, Int -> CheckStickerSetNameResult -> ShowS
[CheckStickerSetNameResult] -> ShowS
CheckStickerSetNameResult -> String
(Int -> CheckStickerSetNameResult -> ShowS)
-> (CheckStickerSetNameResult -> String)
-> ([CheckStickerSetNameResult] -> ShowS)
-> Show CheckStickerSetNameResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CheckStickerSetNameResult -> ShowS
showsPrec :: Int -> CheckStickerSetNameResult -> ShowS
$cshow :: CheckStickerSetNameResult -> String
show :: CheckStickerSetNameResult -> String
$cshowList :: [CheckStickerSetNameResult] -> ShowS
showList :: [CheckStickerSetNameResult] -> ShowS
Show)

instance I.ShortShow CheckStickerSetNameResult where
  shortShow :: CheckStickerSetNameResult -> String
shortShow CheckStickerSetNameResult
CheckStickerSetNameResultOk
      = String
"CheckStickerSetNameResultOk"
  shortShow CheckStickerSetNameResult
CheckStickerSetNameResultNameInvalid
      = String
"CheckStickerSetNameResultNameInvalid"
  shortShow CheckStickerSetNameResult
CheckStickerSetNameResultNameOccupied
      = String
"CheckStickerSetNameResultNameOccupied"

instance AT.FromJSON CheckStickerSetNameResult where
  parseJSON :: Value -> Parser CheckStickerSetNameResult
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
"checkStickerSetNameResultOk"           -> CheckStickerSetNameResult -> Parser CheckStickerSetNameResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure CheckStickerSetNameResult
CheckStickerSetNameResultOk
      String
"checkStickerSetNameResultNameInvalid"  -> CheckStickerSetNameResult -> Parser CheckStickerSetNameResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure CheckStickerSetNameResult
CheckStickerSetNameResultNameInvalid
      String
"checkStickerSetNameResultNameOccupied" -> CheckStickerSetNameResult -> Parser CheckStickerSetNameResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure CheckStickerSetNameResult
CheckStickerSetNameResultNameOccupied
      String
_                                       -> Parser CheckStickerSetNameResult
forall a. Monoid a => a
mempty
    
  parseJSON Value
_ = Parser CheckStickerSetNameResult
forall a. Monoid a => a
mempty