module TD.Data.BusinessConnection
(BusinessConnection(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified Data.Text as T
data BusinessConnection
= BusinessConnection
{ BusinessConnection -> Maybe Text
_id :: Maybe T.Text
, BusinessConnection -> Maybe Int
user_id :: Maybe Int
, BusinessConnection -> Maybe Int
user_chat_id :: Maybe Int
, BusinessConnection -> Maybe Int
date :: Maybe Int
, BusinessConnection -> Maybe Bool
can_reply :: Maybe Bool
, BusinessConnection -> Maybe Bool
is_enabled :: Maybe Bool
}
deriving (BusinessConnection -> BusinessConnection -> Bool
(BusinessConnection -> BusinessConnection -> Bool)
-> (BusinessConnection -> BusinessConnection -> Bool)
-> Eq BusinessConnection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BusinessConnection -> BusinessConnection -> Bool
== :: BusinessConnection -> BusinessConnection -> Bool
$c/= :: BusinessConnection -> BusinessConnection -> Bool
/= :: BusinessConnection -> BusinessConnection -> Bool
Eq, Int -> BusinessConnection -> ShowS
[BusinessConnection] -> ShowS
BusinessConnection -> String
(Int -> BusinessConnection -> ShowS)
-> (BusinessConnection -> String)
-> ([BusinessConnection] -> ShowS)
-> Show BusinessConnection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BusinessConnection -> ShowS
showsPrec :: Int -> BusinessConnection -> ShowS
$cshow :: BusinessConnection -> String
show :: BusinessConnection -> String
$cshowList :: [BusinessConnection] -> ShowS
showList :: [BusinessConnection] -> ShowS
Show)
instance I.ShortShow BusinessConnection where
shortShow :: BusinessConnection -> String
shortShow BusinessConnection
{ _id :: BusinessConnection -> Maybe Text
_id = Maybe Text
_id_
, user_id :: BusinessConnection -> Maybe Int
user_id = Maybe Int
user_id_
, user_chat_id :: BusinessConnection -> Maybe Int
user_chat_id = Maybe Int
user_chat_id_
, date :: BusinessConnection -> Maybe Int
date = Maybe Int
date_
, can_reply :: BusinessConnection -> Maybe Bool
can_reply = Maybe Bool
can_reply_
, is_enabled :: BusinessConnection -> Maybe Bool
is_enabled = Maybe Bool
is_enabled_
}
= String
"BusinessConnection"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"_id" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
_id_
, String
"user_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
user_id_
, String
"user_chat_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
user_chat_id_
, String
"date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
date_
, String
"can_reply" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_reply_
, String
"is_enabled" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_enabled_
]
instance AT.FromJSON BusinessConnection where
parseJSON :: Value -> Parser BusinessConnection
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
"businessConnection" -> Value -> Parser BusinessConnection
parseBusinessConnection Value
v
String
_ -> Parser BusinessConnection
forall a. Monoid a => a
mempty
where
parseBusinessConnection :: A.Value -> AT.Parser BusinessConnection
parseBusinessConnection :: Value -> Parser BusinessConnection
parseBusinessConnection = String
-> (Object -> Parser BusinessConnection)
-> Value
-> Parser BusinessConnection
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"BusinessConnection" ((Object -> Parser BusinessConnection)
-> Value -> Parser BusinessConnection)
-> (Object -> Parser BusinessConnection)
-> Value
-> Parser BusinessConnection
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
_id_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"id"
Maybe Int
user_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"user_id"
Maybe Int
user_chat_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"user_chat_id"
Maybe Int
date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"date"
Maybe Bool
can_reply_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_reply"
Maybe Bool
is_enabled_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_enabled"
BusinessConnection -> Parser BusinessConnection
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (BusinessConnection -> Parser BusinessConnection)
-> BusinessConnection -> Parser BusinessConnection
forall a b. (a -> b) -> a -> b
$ BusinessConnection
{ _id :: Maybe Text
_id = Maybe Text
_id_
, user_id :: Maybe Int
user_id = Maybe Int
user_id_
, user_chat_id :: Maybe Int
user_chat_id = Maybe Int
user_chat_id_
, date :: Maybe Int
date = Maybe Int
date_
, can_reply :: Maybe Bool
can_reply = Maybe Bool
can_reply_
, is_enabled :: Maybe Bool
is_enabled = Maybe Bool
is_enabled_
}
parseJSON Value
_ = Parser BusinessConnection
forall a. Monoid a => a
mempty