module TD.Data.CanSendStoryResult
(CanSendStoryResult(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data CanSendStoryResult
= CanSendStoryResultOk
| CanSendStoryResultPremiumNeeded
| CanSendStoryResultBoostNeeded
| CanSendStoryResultActiveStoryLimitExceeded
| CanSendStoryResultWeeklyLimitExceeded
{ CanSendStoryResult -> Maybe Int
retry_after :: Maybe Int
}
| CanSendStoryResultMonthlyLimitExceeded
{ retry_after :: Maybe Int
}
deriving (CanSendStoryResult -> CanSendStoryResult -> Bool
(CanSendStoryResult -> CanSendStoryResult -> Bool)
-> (CanSendStoryResult -> CanSendStoryResult -> Bool)
-> Eq CanSendStoryResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CanSendStoryResult -> CanSendStoryResult -> Bool
== :: CanSendStoryResult -> CanSendStoryResult -> Bool
$c/= :: CanSendStoryResult -> CanSendStoryResult -> Bool
/= :: CanSendStoryResult -> CanSendStoryResult -> Bool
Eq, Int -> CanSendStoryResult -> ShowS
[CanSendStoryResult] -> ShowS
CanSendStoryResult -> String
(Int -> CanSendStoryResult -> ShowS)
-> (CanSendStoryResult -> String)
-> ([CanSendStoryResult] -> ShowS)
-> Show CanSendStoryResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CanSendStoryResult -> ShowS
showsPrec :: Int -> CanSendStoryResult -> ShowS
$cshow :: CanSendStoryResult -> String
show :: CanSendStoryResult -> String
$cshowList :: [CanSendStoryResult] -> ShowS
showList :: [CanSendStoryResult] -> ShowS
Show)
instance I.ShortShow CanSendStoryResult where
shortShow :: CanSendStoryResult -> String
shortShow CanSendStoryResult
CanSendStoryResultOk
= String
"CanSendStoryResultOk"
shortShow CanSendStoryResult
CanSendStoryResultPremiumNeeded
= String
"CanSendStoryResultPremiumNeeded"
shortShow CanSendStoryResult
CanSendStoryResultBoostNeeded
= String
"CanSendStoryResultBoostNeeded"
shortShow CanSendStoryResult
CanSendStoryResultActiveStoryLimitExceeded
= String
"CanSendStoryResultActiveStoryLimitExceeded"
shortShow CanSendStoryResultWeeklyLimitExceeded
{ retry_after :: CanSendStoryResult -> Maybe Int
retry_after = Maybe Int
retry_after_
}
= String
"CanSendStoryResultWeeklyLimitExceeded"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"retry_after" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
retry_after_
]
shortShow CanSendStoryResultMonthlyLimitExceeded
{ retry_after :: CanSendStoryResult -> Maybe Int
retry_after = Maybe Int
retry_after_
}
= String
"CanSendStoryResultMonthlyLimitExceeded"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"retry_after" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
retry_after_
]
instance AT.FromJSON CanSendStoryResult where
parseJSON :: Value -> Parser CanSendStoryResult
parseJSON v :: Value
v@(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
"canSendStoryResultOk" -> CanSendStoryResult -> Parser CanSendStoryResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure CanSendStoryResult
CanSendStoryResultOk
String
"canSendStoryResultPremiumNeeded" -> CanSendStoryResult -> Parser CanSendStoryResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure CanSendStoryResult
CanSendStoryResultPremiumNeeded
String
"canSendStoryResultBoostNeeded" -> CanSendStoryResult -> Parser CanSendStoryResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure CanSendStoryResult
CanSendStoryResultBoostNeeded
String
"canSendStoryResultActiveStoryLimitExceeded" -> CanSendStoryResult -> Parser CanSendStoryResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure CanSendStoryResult
CanSendStoryResultActiveStoryLimitExceeded
String
"canSendStoryResultWeeklyLimitExceeded" -> Value -> Parser CanSendStoryResult
parseCanSendStoryResultWeeklyLimitExceeded Value
v
String
"canSendStoryResultMonthlyLimitExceeded" -> Value -> Parser CanSendStoryResult
parseCanSendStoryResultMonthlyLimitExceeded Value
v
String
_ -> Parser CanSendStoryResult
forall a. Monoid a => a
mempty
where
parseCanSendStoryResultWeeklyLimitExceeded :: A.Value -> AT.Parser CanSendStoryResult
parseCanSendStoryResultWeeklyLimitExceeded :: Value -> Parser CanSendStoryResult
parseCanSendStoryResultWeeklyLimitExceeded = String
-> (Object -> Parser CanSendStoryResult)
-> Value
-> Parser CanSendStoryResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"CanSendStoryResultWeeklyLimitExceeded" ((Object -> Parser CanSendStoryResult)
-> Value -> Parser CanSendStoryResult)
-> (Object -> Parser CanSendStoryResult)
-> Value
-> Parser CanSendStoryResult
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
retry_after_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"retry_after"
CanSendStoryResult -> Parser CanSendStoryResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CanSendStoryResult -> Parser CanSendStoryResult)
-> CanSendStoryResult -> Parser CanSendStoryResult
forall a b. (a -> b) -> a -> b
$ CanSendStoryResultWeeklyLimitExceeded
{ retry_after :: Maybe Int
retry_after = Maybe Int
retry_after_
}
parseCanSendStoryResultMonthlyLimitExceeded :: A.Value -> AT.Parser CanSendStoryResult
parseCanSendStoryResultMonthlyLimitExceeded :: Value -> Parser CanSendStoryResult
parseCanSendStoryResultMonthlyLimitExceeded = String
-> (Object -> Parser CanSendStoryResult)
-> Value
-> Parser CanSendStoryResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"CanSendStoryResultMonthlyLimitExceeded" ((Object -> Parser CanSendStoryResult)
-> Value -> Parser CanSendStoryResult)
-> (Object -> Parser CanSendStoryResult)
-> Value
-> Parser CanSendStoryResult
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
retry_after_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"retry_after"
CanSendStoryResult -> Parser CanSendStoryResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CanSendStoryResult -> Parser CanSendStoryResult)
-> CanSendStoryResult -> Parser CanSendStoryResult
forall a b. (a -> b) -> a -> b
$ CanSendStoryResultMonthlyLimitExceeded
{ retry_after :: Maybe Int
retry_after = Maybe Int
retry_after_
}
parseJSON Value
_ = Parser CanSendStoryResult
forall a. Monoid a => a
mempty